Behavior recognition method, device, equipment and storage medium
By generating sparse and dense detection frames, the multi-task recognition network model is used for behavior recognition in video sequences, which solves the problem of receptive field mismatch and position overlap in single object and group object recognition, and improves the accuracy and efficiency of behavior recognition. .
Patent Information
- Application Number
- CN202110447987.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-25
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-04-25
AI Technical Summary
When dealing with single objects and group objects, behavior recognition in videos has problems such as the uncertain number of action execution subjects, mismatch of spatial receptive fields, and overlapping spatial positions between subjects who do not have preset behavior and subjects who do occur, leading to interference in recognition results. .
By obtaining the detection results of each object in each frame of the video sequence, we generate sparse detection frames and dense detection frames, use the multi-task recognition network model to identify different types of behavioral sequences, and adaptively adjust the receptive field to improve recognition. Accuracy.
It effectively reduces the recognition difficulty of the behavior recognition model, improves the accuracy and efficiency of behavior recognition in video sequences, is suitable for behavior recognition of single objects and group objects, and reduces the amount of model calculations.
Smart Images

Figure CN113111838B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision, and is related to but not limited to behavior recognition methods and devices, equipment and storage media. Background Art
[0002] Behavior recognition in videos is an important application in the field of computer vision. The main problems that exist in practice include: the number of action performers of an event is uncertain (according to the number of action performers of an event, it can usually be divided into single-object behavior and group-object behavior); different types of behavior event recognition require different spatial receptive fields (in the recognition scenario, there may be behavior subjects with different positions and fields of view, and the location of the behavior event that actually needs to be detected usually only occupies a small area of the screen); there may be spatial overlap between the behavior subjects that have not performed the preset behavior and the behavior subjects that have performed the preset behavior, etc. All of the above problems will interfere with the behavior recognition results. Summary of the invention
[0003] The embodiments of the present application provide a behavior recognition method, apparatus, device and storage medium.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] In a first aspect, an embodiment of the present application provides a behavior recognition method, the method comprising:
[0006] Obtain a detection result of each object in each frame of an image in a video sequence to be identified; wherein the video sequence to be identified includes a single object and / or a group of objects; the group of objects includes at least two objects whose spatial distance is less than a distance threshold; generate at least one first sequence and / or at least one second sequence according to the detection result of each of the objects, wherein the first sequence and the second sequence both include one of the following: the same single object and the group of objects; use a trained multi-task recognition network model to perform behavior recognition on each of the first sequences and / or each of the second sequences, respectively, to obtain a behavior recognition result of each of the single objects and / or a behavior recognition result of the group of objects.
[0007] In some possible implementations, the detection result of the object includes at least a detection frame of the object and an object identifier associated with the detection frame; generating at least one first sequence based on the detection result of each of the objects includes: determining a sparse detection frame in each frame image based on a distribution of the detection frame of each of the objects in the corresponding frame image; wherein the number of overlaps between the sparse detection frame and other detection frames in each frame image except the sparse detection frame is less than a first number threshold; generating the at least one first sequence based on the sparse detection frame in each frame image and the object identifier associated with the sparse detection frame.
[0008] In this way, the detection frames of the sparse area, i.e., the sparse detection frames, are first determined by using the distribution of the detection frames in the frame images, and then the sparse detection frames in each frame image are preprocessed according to the object identifier to obtain at least one first sequence. This solves the problem of identifying the behavior of a single object in a video sequence, reduces the recognition difficulty of the behavior recognition model, and reduces the amount of model calculation.
[0009] In some possible implementations, generating at least one second sequence based on the detection result of each of the objects includes: determining a dense detection frame in each frame image based on the distribution of the detection frame of each object in the corresponding frame image; wherein the number of overlaps between the dense detection frame and other detection frames in each frame image except the dense detection frame is greater than or equal to a second number threshold, and the second number threshold is greater than the first number threshold; generating the at least one second sequence based on the dense detection frame in each frame image and the object identifier associated with the dense detection frame.
[0010] In this way, the distribution of the detection frames in the frame image is first used to determine the detection frames of the dense area, that is, the dense detection frames, and then the dense detection frames in each frame image are preprocessed to obtain at least one second sequence, thereby solving the problem of identifying group object behaviors. Combined with the preprocessing process of the sparse detection frames, the receptive fields of behaviors of different types, that is, different action execution subjects, can be adaptively adjusted, which can solve the problem of small effective perception range when identifying the full-view video sequence to be identified.
[0011] In some possible implementations, determining the sparse detection frames in each frame image according to the distribution of the detection frames of each object in the corresponding frame image includes: determining the number of detection frames included in each frame image; and when the number of detection frames is 1, determining the sparse detection frames in the corresponding frame image.
[0012] In this way, when each frame image includes a detection frame, the detection frame is directly used as a sparse detection frame to facilitate the subsequent generation of the first sequence of single object trajectory behavior, which can simplify the operation and effectively extract useful information.
[0013] In some possible implementations, sparse detection frames and dense detection frames in each frame image are determined according to the distribution of the detection frames of each object in the corresponding frame image, including: determining the number of detection frames included in each frame image; when the number of detection frames is greater than or equal to 2, generating an adjacency matrix corresponding to each frame image according to the intersection and union ratio between every two detection frames in each frame image; using the detection frames with zero matching times in the adjacency matrix as sparse detection frames in each frame image; using the detection frames with matching times greater than or equal to a third number threshold in the adjacency matrix as dense detection frames in each frame image; wherein the third number threshold is greater than the second number threshold.
[0014] In this way, for the case where each frame image includes multiple detection frames, by calculating the intersection-over-union ratio between any two detection frames and counting the number of matches of each detection frame, it is possible to accurately screen out sparse detection frames that do not overlap with other detection frames and dense detection frames that overlap with other detection frames the most times, so as to facilitate the subsequent generation of the first sequence of single object trajectory behavior and the second sequence of group object trajectory behavior, and effectively extract useful information in the video to be identified.
[0015] In some possible implementations, the video sequence to be identified is composed of frame images in a frame sequence buffer, and generating the at least one first sequence based on the sparse detection frame in each frame image and the object identifier associated with the sparse detection frame includes: for all frame images in the frame sequence buffer, taking the union of the sparse detection frames associated with each object identifier in spatial position to obtain a minimum enclosing frame of a single object corresponding to each object identifier; according to the size of the minimum enclosing frame, intercepting a first area image corresponding to the spatial position of the minimum enclosing frame in each frame image; according to the timestamp of each frame image, sequentially connecting the first area images to obtain a first sequence corresponding to each object identifier.
[0016] In this way, by calculating the minimum bounding box of each object identifier, that is, each single object, and intercepting each frame of the image with the minimum bounding box to obtain the first sequence, the loss of the relative position of the behavior subject can be avoided, and the performance of behavior detection with similar space but different motion rhythms can be improved.
[0017] In some possible implementations, the video sequence to be identified is composed of frame images in a frame sequence buffer, each frame image in the frame sequence buffer includes a dense detection frame, and generating the at least one second sequence based on the dense detection frame in each frame image and the object identifier associated with the dense detection frame includes: expanding the dense detection frame in each frame image in the frame sequence buffer outward by a specific proportion to obtain a dense area in each frame image and an object identifier associated with the dense area; wherein the dense area includes at least two objects; taking the union of the dense areas in each frame image in the frame sequence buffer to obtain a dense bounding box of the frame sequence buffer; according to the size of the dense bounding box, intercepting a second area image corresponding to the spatial position of the dense bounding box in each frame image; and connecting the second area images in sequence according to the timestamp of each frame image to generate a second sequence.
[0018] In this way, the dense detection frame predicted to be prone to group object behavior is expanded outward, so that the expanded dense area is centered on the object corresponding to the dense detection frame and surrounds all objects of group behavior as much as possible. At the same time, by determining the dense bounding box of the frame sequence buffer, each frame image is intercepted with the dense bounding box to obtain the second sequence, which can reduce the receptive field of group object behavior events, thereby improving the accuracy and efficiency of behavior recognition.
[0019] In some possible implementations, the group of objects included in each of the images in the second sequence includes at least the same object.
[0020] In this way, it is ensured that the generated second sequence includes at least the same object, and the group object behavior can be continuously detected, which is conducive to the subsequent detection system to automatically identify the object where the behavior occurs, bringing convenience to the departments with related needs.
[0021] In some possible implementations, the video sequence to be identified is composed of frame images in a frame sequence buffer, each frame image in the frame sequence buffer includes at least one dense detection frame, and the generating of the at least one second sequence according to the dense detection frame in each frame image and the object identifier associated with the dense detection frame includes: for each dense detection frame in each frame image, expanding outward by a specific proportion to obtain a dense area corresponding to each dense detection frame and an object identifier associated with the dense area; wherein the dense area includes at least two objects; according to the object identifier associated with the dense area, taking the union of the dense areas including the same object to obtain at least one dense bounding box including the same object; according to the size of each dense bounding box, intercepting a third area image corresponding to the spatial position of the dense bounding box in each frame image; according to the timestamp of each frame image, sequentially connecting the third area images to generate the at least one second sequence including the same object.
[0022] In this way, by identifying the object associated with the dense area, the dense bounding box containing the same object in the frame sequence buffer is determined, and each frame image is intercepted with the dense bounding box to obtain a second sequence containing the same object, which can reduce the receptive field of group object behavior events, thereby improving the accuracy and efficiency of behavior recognition. At the same time, it avoids the loss of the relative position of group object behavior, and has a good performance improvement for the detection of behaviors with similar space but different motion rhythms.
[0023] In some possible implementations, generating the at least one second sequence based on the dense detection box in each frame image and the object identifier associated with the dense detection box, further includes: determining whether a merge tag of the frame sequence buffer is true; wherein the merge tag is a tag that determines whether dense areas of the frame images in the frame sequence buffer are merged based on background similarity of the frame images in the frame sequence buffer; taking the union of the dense areas in each frame image in the frame sequence buffer to obtain the dense bounding box of the frame sequence buffer includes: when the merge tag is true, taking the union of the dense areas in each frame image in the frame sequence buffer to obtain the dense bounding box of the frame sequence buffer.
[0024] In this way, by setting the merge label, when the backgrounds of frame images in the frame sequence buffer are similar, the dense areas in each frame image are unioned to obtain a dense bounding box, that is, a larger area is used to intercept the regional image of each frame image, which can reduce the receptive field of group object behavior events, thereby improving the accuracy and efficiency of behavior recognition, and is suitable for shooting scenes with fixed backgrounds.
[0025] In some possible implementations, generating the at least one second sequence based on the dense detection box in each frame of image and the object identifier associated with the dense detection box further includes: when the merge label is false, respectively cropping each frame of image according to the dense area of each frame of image to obtain a fourth area image having a length and width of specific pixels; and connecting the fourth area images in sequence according to the timestamp of each frame of image to generate the at least one second sequence.
[0026] In this way, by setting the merge label, when the backgrounds of frame images in the frame sequence buffer are not similar, the fourth region image of each frame is captured using the dense area of each frame, and the region image of each frame is used to replace the original video sequence to be identified. This can reduce the receptive field of group object behavior events, thereby improving the accuracy and efficiency of behavior recognition, and is suitable for shooting scenes with changing backgrounds.
[0027] In some possible implementations, generating the at least one second sequence based on the dense detection frame in each frame image and the object identifier associated with the dense detection frame also includes: when there is a first frame image in the frame sequence buffer, using a regional image of the first frame image centered on the center point of the first frame image and with specific pixels as length and width as a fourth regional image of the first frame image; wherein the first frame image is a frame image that does not include a dense detection frame.
[0028] In this way, when there is a frame in the input video sequence to be identified that does not contain a dense detection frame, a fourth area image of a fixed size is captured based on the center position of the frame, and then sent to the model for recognition together with the fourth area images captured from other frames, thereby solving the problem of target loss in continuously detected group object behaviors, improving the accuracy of behavior recognition and enhancing the robustness of the model.
[0029] In some possible implementations, the video sequence to be identified is composed of frame images in a frame sequence buffer, and generating at least one first sequence based on the detection results of each of the objects also includes: determining the number of first object identifiers associated with the sparse detection frames in each frame image in the frame sequence buffer; when the number of the first object identifiers is less than a specific threshold, selecting candidate detection frames from dense areas in each frame image; wherein the number of overlaps between the candidate detection frame and other detection frames is less than the first number threshold; and generating the at least one first sequence based on the candidate detection frame and the object identifier associated with the candidate detection frame.
[0030] In this way, in the process of preprocessing the video sequence to be identified to generate the first sequence, when the first sequence generated based on the sparse detection frame does not meet the specific threshold, the first sequence can be generated by selecting candidate detection frames with a smaller number of overlaps in the dense area, thereby ensuring the accuracy of single object behavior recognition using limited computing power and improving the efficiency and performance of the model.
[0031] In some possible implementations, when the first number of object identifiers is less than a specific threshold, selecting a candidate detection frame from a dense area in each frame of the image includes: determining the specific threshold based on the number of second object identifiers associated with the dense detection frame in each frame of the image in the frame sequence buffer and specific processing parameters; determining the number of third object identifiers associated with the candidate detection frame based on the first number of object identifiers and the specific threshold; and selecting, according to the third number of object identifiers, a detection frame whose number of overlaps with other detection frames is less than the first number threshold from the dense area of each frame of the image as the candidate detection frame.
[0032] In this way, a specific threshold can be determined according to the number of object identifiers associated with the dense detection box in each frame image in the frame sequence buffer, thereby determining the number of object identifiers associated with the candidate detection box, so that the first sequence and the second sequence generated by the video sequence to be identified meet the maximum number of parallel computing paths allowed online, thereby improving the acquisition of effective information and further improving the efficiency and performance of the model.
[0033] In some possible implementations, the multi-task recognition network model is trained using a first sample data set of single object behavior and a second sample data set of group object behavior; wherein the multi-task recognition network model includes a backbone network and a classification network corresponding to the task to be recognized; the task to be recognized includes at least one of the following: a task type of single object behavior and a task type of group object behavior.
[0034] In this way, the basic network structure (multiple tasks share the backbone network) is trained using the first sample data set of single object behavior and the second sample data set of group object behavior, thereby obtaining a multi-task recognition network model that can simultaneously perform task recognition of single object behavior and task recognition of group object behavior. This improves the accuracy of multi-task recognition and greatly reduces the video memory consumption caused by adding tasks.
[0035] In some possible implementations, the multi-task recognition network model includes a first classification network for performing behavior recognition on the single object and a second classification network for recognizing the group objects, and using the trained multi-task recognition network model to perform behavior recognition on each of the first sequences and / or each of the second sequences, respectively, to obtain a behavior recognition result for each of the single objects and / or a behavior recognition result for the group objects, includes: in response to each of the first sequences including the single object, using the first classification network to recognize the at least one first sequence to obtain a behavior recognition result for each of the single objects; and / or, in response to each of the second sequences including the group object, using the second classification network to recognize the at least one second sequence to obtain a behavior recognition result for the group objects.
[0036] In some possible implementations, the method further includes: in a case where there is a single object behavior and / or a group object behavior in the video sequence to be identified, determining the spatial position and behavior category of the single object behavior and / or the group object behavior; wherein the behavior category includes the category of the single object behavior and / or the category of the group object behavior; determining an alarm content according to the spatial position and the behavior category; and sending an alarm notification to a terminal device corresponding to the spatial position according to the alarm content.
[0037] In this way, when single object behavior and / or group object behavior is detected, the system will automatically identify the type and area where the corresponding behavior occurs and issue an alarm, so that the automatic analysis of behavioral events in video content provides convenience and evidence collection capabilities for relevant departments, which is suitable for general indoor and outdoor scenarios.
[0038] In a second aspect, an embodiment of the present application provides a behavior recognition device, including an acquisition module, a generation module and a recognition module, wherein:
[0039] The acquisition module is used to acquire the detection result of each object in each frame of the video sequence to be identified; wherein the video sequence to be identified includes a single object and / or a group of objects; the group of objects includes at least two objects whose spatial distance is less than a distance threshold;
[0040] The generating module is used to generate at least one first sequence and / or at least one second sequence according to the detection result of each of the objects, wherein the first sequence and the second sequence each include one of the following: the same single object, the group of objects;
[0041] The recognition module uses a trained multi-task recognition network model to perform behavior recognition on each of the first sequences and / or each of the second sequences.
[0042] In a third aspect, an embodiment of the present application provides a device including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the steps in the above-mentioned behavior recognition method are implemented.
[0043] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above-mentioned behavior recognition method when executed by a processor.
[0044] The embodiments of the present application provide a behavior recognition method and apparatus, device and storage medium, which first obtains the detection results of each object in each frame of the image to determine the first sequence of single object behavior and / or the second sequence of group object behavior, and then performs behavior recognition on the first sequence and the second sequence respectively. A joint recognition method compatible with single object behavior and group object behavior is proposed, which can support different types of behavior detection requirements at the same time. At the same time, the video classification problem is converted into the recognition problem of different types of behavior sequences, which reduces the recognition difficulty of the behavior recognition model while improving the acquisition of effective information. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0046] Figure 1A A schematic diagram of a network architecture of a behavior recognition method provided in an embodiment of the present application;
[0047] Figure 1B A flowchart of a behavior recognition method provided in an embodiment of the present application;
[0048] Figure 2 A flowchart of another behavior recognition method provided in an embodiment of the present application;
[0049] Figure 3 A flowchart of another behavior recognition method provided in an embodiment of the present application;
[0050] Figure 4 A flowchart of another behavior recognition method provided in an embodiment of the present application;
[0051] Figure 5 A flowchart of another behavior recognition method provided in an embodiment of the present application;
[0052] Figure 6A flowchart of another behavior recognition method provided in an embodiment of the present application;
[0053] Figure 7 A flowchart of the training process of the multi-task recognition network model provided in the embodiment of the present application;
[0054] Fig. 8A A system block diagram of a single-person and multi-person behavior joint recognition algorithm provided in an embodiment of the present application;
[0055] Figure 8B A system block diagram of a single model training provided in an embodiment of the present application;
[0056] Figure 8C A system block diagram of a multi-task recognition network model training provided in an embodiment of the present application;
[0057] Fig.8D A flowchart of the adaptive sparse / dense area partitioning logic provided in an embodiment of the present application;
[0058] Fig. 9 A schematic diagram of the structure of a behavior recognition device provided in an embodiment of the present application;
[0059] Fig.10 A schematic diagram of a hardware entity of a behavior recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. The following embodiments are used to illustrate the present application, but are not intended to limit the scope of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0061] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0062] It should be pointed out that the terms "first\second\third" involved in the embodiments of the present application are merely to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0063] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as the general understanding of those skilled in the art in the field to which the embodiments of the present application belong. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0064] Behavior detection in videos is an important problem in the field of computer vision and has a wide range of applications in the field of smart cities, such as detecting illegal behaviors, traffic accidents, and some uncommon events. Most devices that collect video sources only record the dynamics of each moment, but do not have the ability to automatically identify (often requiring special personnel to be responsible for manual inspection). Due to the huge number of videos, it is obviously unrealistic to filter the content in the video by manpower alone. It is necessary to use computer vision and deep learning technology to automatically detect behavioral events occurring in the video.
[0065] Figure 1A A network architecture diagram of a behavior recognition method provided in an embodiment of the present application is shown in FIG. Figure 1AAs shown, the network architecture includes: a camera 101, an object detection module 102, a preprocessing module 103 and a video recognition module 104: wherein the object detection module 102, the preprocessing module 103 and the video recognition module 104 can be set in the server 100. In order to support an exemplary application, the camera 101 establishes a communication connection with the server 100 through the network. The video of a specific scene is captured by the camera 101, and then a video sequence 11 to be identified is sampled, i.e., a multi-frame image containing a target object, and the video sequence 11 to be identified is input into the object detection module 102; the object detection module 102 can make full use of relevant detection algorithms such as inter-frame difference method, background subtraction method, optical flow method, etc. to realize the positioning and analysis of the target object in the video sequence 11 to be identified, and obtain a multi-frame image 12 with detection results (detection frame and object identification of the target object are marked); then the multi-frame image 12 with the detection results is processed by the preprocessing module 103, and based on the detection frame and object identification of each object in each frame image, at least one first sequence 13 and / or at least one second sequence 14 are generated, wherein the first sequence is a trajectory sequence including the same object, and the second sequence is a behavior sequence including a group of objects; all the first sequences 13 and the second sequences 14 are input into the video recognition module 104 together; the video recognition module 104 can make full use of the relevant video understanding model to perform behavior recognition on each first sequence 13 and / or each second sequence 14, and finally output the recognition result at the video level. Based on this network architecture, a behavior recognition method framework can be designed, which includes two stages: object localization and behavior recognition. In the object localization stage, all existing object detection algorithms can be flexibly used. In the behavior recognition stage, a multi-task recognition network model is obtained by training based on sample data sets of single object behavior and sample data sets of group object behavior.
[0066] The embodiment of the present application provides a behavior recognition method, which is applied to a server, a terminal device or other devices, wherein the terminal device includes but is not limited to a mobile phone, a laptop computer, a tablet computer, a handheld Internet device, a multimedia device, a streaming media device, a mobile Internet device, a wearable device or other types of devices.
[0067] Figure 1B A flow chart of a behavior recognition method provided in an embodiment of the present application is shown as follows: Figure 1B As shown, the method comprises at least the following steps:
[0068] Step S110, obtaining the detection result of each object in each frame image in the video sequence to be identified.
[0069] Here, the video sequence to be identified includes a single object and / or a group of objects; the group of objects includes at least two objects whose spatial distance is less than a distance threshold, that is, the video sequence to be identified may include a single object behavior event, a group of object behavior event, or both of the above events. In implementation, the video sequence to be identified can be obtained by sampling a specific video source. For example, videos shot at a fixed angle often cover a wider field of view and contain more information, such as pedestrians, vehicles, animals, buildings, and other complex background information.
[0070] It can be understood that the video sequence to be identified is a frame sequence composed of multiple frames, wherein each frame may contain at least one object or no object, and different frames may contain different objects, but all frames of the video sequence to be identified contain at least two objects. The objects here can be pedestrians, moving vehicles, animals, etc., which are determined according to the actual scene in implementation, and the embodiments of the present application do not limit this.
[0071] The detection and location analysis of objects in video images can be achieved through relevant image or video processing technology. For example, the object detection algorithm pre-processes the video sequence to be identified to obtain multiple frames of images with detection frames, and then extracts the detection frame of the object in each frame. Among them, the detection algorithm, such as template matching, can be implemented for the detection of moving targets in the video through frame difference method, background subtraction method, optical flow method, etc., which is not limited in the embodiments of the present application.
[0072] Here, the object detection result at least includes the object detection frame and the object identifier associated with the detection frame. For different objects appearing in the video sequence to be identified, the detection frame of each object and the unique object identifier associated with the detection frame will be obtained after object detection. That is, the detection frames of different objects are distinguished by the corresponding object identifiers, so that the main object of the behavior can be automatically identified and processed in time.
[0073] Step S120: generating at least one first sequence and / or at least one second sequence according to the detection result of each of the objects.
[0074] Here, each of the first sequences and each of the second sequences includes one of the following: the same single object, the group object. In some embodiments, each of the first sequences includes the same single object, that is, the position sequence of a single behavior subject in each frame of the video sequence to be identified; each of the second sequence images includes a group object, that is, the sequence of active areas of the group object in each frame of the video sequence to be identified. In other embodiments, each of the first sequences includes a group object, and each of the second sequences includes the same single object. In implementation, it can be determined what type of objects the generated sequence includes based on actual conditions, and the embodiments of the present application are not limited here.
[0075] It can be understood that, according to the distribution of the detection frame in each frame image in the video sequence to be identified, each frame image can be divided into a sparse area and a dense area, and at least one first sequence can be generated by processing the sparse area where single object behavior is likely to occur; and at least one second sequence can be generated by processing the dense area where group object behavior is likely to occur. The number of first sequences can be determined according to the number of object identifiers associated with a single object in the sparse area in the video sequence to be identified, and the number of second sequences can be determined according to the number of dense areas in each frame image in the video sequence to be identified.
[0076] Step S130, using the trained multi-task recognition network model, respectively perform behavior recognition on each of the first sequences and / or each of the second sequences to obtain a behavior recognition result of each of the single objects and / or a behavior recognition result of the group of objects.
[0077] Here, at least one first sequence and / or at least one second sequence obtained in the previous step are sent together to the multi-task recognition network model, and behavior recognition is performed on each first sequence and / or each second sequence in the network model to obtain discrimination scores of different behaviors. For example, pedestrians are used as detection objects, and single object behaviors may include falling, climbing, handing out flyers, etc., and group object behaviors may include trampling, hugging, etc.
[0078] That is to say, different types of behavioral events in the video sequence to be identified are independently identified, and the first discriminant score of each first sequence after passing through the network model is confirmed. When there is at least one first discriminant score higher than a given first threshold, the behavior of a single object corresponding to the first sequence is output, such as an old man falling down, a child lying down, a puppy falling into water, etc.; or, the second discriminant score of each second sequence after passing through the network model is confirmed. When there is at least one second discriminant score higher than a given second threshold, the group object behavior corresponding to the first sequence is output, such as a group of students crossing the road in a group, a group of pedestrians trampling; when there is no discriminant score higher than the first threshold or the second threshold, it is determined that there is no single object behavior and group object behavior in the video sequence to be identified.
[0079] It should be noted that the multi-task recognition network model in step S130 can be trained by mixing data sets of multiple different tasks together and optimizing the backbone network, i.e., the feature extractor. The fully connected layer of the multi-task recognition model can also be distilled with the help of the network models of each single task, so that the accuracy of the multi-task recognition model is as equal to or higher than that of the network models of each task as possible.
[0080] In some embodiments, the multi-task recognition network model includes a first classification network for behavior recognition of the single object and a second classification network for recognition of the group object. In response to each of the first sequences including the single object, the first classification network is used to recognize the at least one first sequence to obtain the behavior recognition result of each single object; and / or, in response to each of the second sequences including the group object, the second classification network is used to recognize the at least one second sequence to obtain the behavior recognition result of the group object. The first sequence includes a single object, that is, the first sequence is formed by a sparse detection frame and is recognized by the first classification network, and the second sequence includes a group object, that is, the second sequence is formed based on a dense detection frame and is recognized by the second classification network. In this way, based on whether the objects included in the first sequence or the second sequence are single objects or group objects, the corresponding classification networks are used for recognition, respectively, which can improve the efficiency of behavior recognition.
[0081] In the embodiment of the present application, first, the detection result of each object in each frame of the video sequence to be identified is obtained; then, based on the detection result of each of the objects, at least one first sequence and / or at least one second sequence is generated; finally, the trained multi-task recognition network model is used to perform behavior recognition on each of the first sequences and / or each of the second sequences; thus, a joint recognition method compatible with single object behavior and group object behavior is proposed, which can simultaneously support different types of behavior detection requirements. At the same time, the video classification problem is converted into the recognition problem of different types of behavior sequences, which reduces the recognition difficulty of the behavior recognition model while improving the acquisition of effective information.
[0082] Figure 2 A flow chart of another behavior recognition method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the method comprises at least the following steps:
[0083] Step S210, obtaining the detection result of each object in each frame of the video sequence to be identified.
[0084] Here, the to-be-recognized video sequence includes at least two objects; the detection result of the object includes at least a detection frame of the object and an object identifier associated with the detection frame.
[0085] Step S220, determining a sparse detection frame and a dense detection frame in each frame image according to the distribution of the detection frame of each object in the corresponding frame image.
[0086] Here, the number of overlaps between the sparse detection frame and other detection frames in each frame image except the sparse detection frame is less than a first number threshold; the number of overlaps between the dense detection frame and other detection frames in each frame image except the dense detection frame is greater than or equal to a second number threshold, where the second number threshold is greater than the first number threshold.
[0087] For each frame image in the video sequence to be identified, the embodiment of the present application expects to find the detection frames of scattered single objects therein as sparse detection frames to generate a sequence including the same single object, and find the detection frames that overlap more with other detection frames as dense detection frames to generate a sequence including group objects.
[0088] In some implementations, the sparse detection frame and the dense detection frame in each frame of the image may be determined in the following manner:
[0089] Method 1: determining the number of detection frames included in each frame image; when the number of detection frames is 1, determining the detection frame as a sparse detection frame in the corresponding frame image.
[0090] Here, when each frame contains only one detection frame, it means that the detection frame is independent in spatial position, and the object corresponding to the detection frame is prone to single object behavior. Directly using the independent detection frame as a sparse detection frame to facilitate the subsequent generation of a sequence of single object trajectory behavior can simplify operations and effectively extract useful information.
[0091] It is worth noting that the sparse detection boxes in different frame images can be of the same object or different objects, and the sparse detection box of a certain object can appear in every frame image in the video sequence to be identified or only in part of the frames.
[0092] Method 2: Determine the number of detection frames included in each frame of image; when the number of detection frames is greater than or equal to 2, generate an adjacency matrix corresponding to each frame of image according to the intersection-and-union ratio between every two detection frames in each frame of image; use the detection frames with zero matching times in the adjacency matrix as sparse detection frames in each frame of image; use the detection frames with matching times in the adjacency matrix greater than or equal to a third number threshold as dense detection frames in each frame of image; wherein the third number threshold is greater than the second number threshold.
[0093] Here, the intersection over union (IoU) between each two detection boxes is the result of dividing the overlapping part of the two regions by the combined part of the two regions. The value of (i, j) in the adjacency matrix represents the IoU of detection box i and detection box j in the frame image. The number of values greater than 0 in the i-th row (except itself) is taken as the number of matches of detection box i.
[0094] If there are no other detection frames whose IoU ratio with detection frame i is greater than 0 in the adjacency matrix, then the number of matches of detection frame i is 0, indicating that there is no overlapping area between detection frame i and other detection frames in the frame image, and it can be used as a sparse detection frame in the frame image. If the IoU ratio between a detection frame j and multiple other detection frames is greater than 0, it means that there are many repetitions between detection frame j and other detection frames in the frame image, and there are multiple object detection frames around the location of detection frame j, which is prone to group object behavior, and detection frame j can be used as a dense detection frame in the frame image.
[0095] In some other embodiments, when each frame of the image includes at least two detection frames, first, the detection frame of each object is expanded outward by a specific ratio to obtain an expanded detection frame; at least two first detection frames are selected from the expanded detection frame; wherein the area of the first detection frame is larger than that of other detection frames in the expanded detection frame; and then, the intersection-and-union ratio between the at least two first detection frames is determined. For example, when the fixed ratio is 1.5 times, the length and width of each detection frame of the object are expanded by 1.5 times. This can increase the image resolution, thereby better calculating the intersection-and-union ratio between overlapping detection frames.
[0096] Step S230: generating the at least one first sequence according to the sparse detection frame in each frame of the image and the object identifier associated with the sparse detection frame.
[0097] Here, the sparse detection frames in different frames can be of the same object or different objects. The sparse detection frame of a certain object can appear in every frame of the video sequence to be identified or only in a part of the frames. The sparse detection frames associated with each object identifier or the larger area containing the sparse detection frame appearing in all the video sequences to be identified are connected in chronological order to generate each first sequence. In other words, the first sequence includes the same single object.
[0098] In some other embodiments, the sparse detection frame associated with each of the object identifiers is selected from the at least two first detection frames, and each of the sparse detection frames associated with the object identifier is first shrunk according to the specific ratio to obtain a sparse detection frame of the original size; then, the at least one first sequence is generated based on the sparse detection frame of the original size and the object identifier associated with the sparse detection frame. In this way, for the candidate detection frames selected from the at least two first detection frames, they need to be shrunk according to the original ratio before generating each first sequence, to ensure that the trajectory sequence that finally enters the behavior recognition stage is the original motion trajectory of a single object, avoiding the generation of additional calculations.
[0099] Step S240: generating the at least one second sequence according to the dense detection frame in each frame of the image and the object identifier associated with the dense detection frame.
[0100] Here, the dense detection frames in different frames may be of the same object or of different objects, and the dense detection frame of a certain object may appear in each frame of the video sequence to be identified or only in a part of the frames. In the case where there is only one dense detection frame in each frame of the video sequence to be identified, the dense detection frames in each frame of the video sequence to be identified and the areas where all the detection frames overlapping with the dense detection frames are located are connected in time order to generate a second sequence; in the case where there are at least two dense detection frames in each frame of the video sequence to be identified, the dense detection frames in each frame of the video sequence belonging to the same object identifier and the areas where all the detection frames overlapping with the dense detection frames are located are connected in time order to generate at least one second sequence. That is to say, the second sequence includes group objects.
[0101] In some other embodiments, each of the dense detection frames is selected from the at least two first detection frames, and each of the dense detection frames is first shrunk according to the specific ratio to obtain a dense detection frame of the original size; then, the at least one second sequence is generated based on the dense detection frame of the original size and the object identifier associated with the dense detection frame.
[0102] Step S250, using the trained multi-task recognition network model, respectively perform behavior recognition on each of the first sequences and each of the second sequences to obtain a behavior recognition result of each of the single objects and / or a behavior recognition result of the group of objects.
[0103] The implementation process of the above step S250 is similar to the implementation process of step S130, and will not be described here to avoid redundancy.
[0104] In some possible implementations, after the multi-task recognition network model obtains the recognition result, an alarm notification can also be sent to the relevant departments or platforms to achieve timely handling of behaviors that endanger the safety of oneself and others. A possible implementation is as follows: when there is a single object behavior and / or a group object behavior in the video sequence to be recognized, determine the spatial location and behavior category of the single object behavior and / or the group object behavior; wherein the behavior category includes the category of the single object behavior and / or the category of the group object behavior; determine the alarm content according to the spatial location and behavior category; send an alarm notification to the terminal device corresponding to the spatial location according to the alarm content, so that the administrator holding the terminal device can handle the behavior.
[0105] It is understandable that different location areas have corresponding managers holding terminal devices. By receiving notifications from the alarm system through the terminal devices, they can quickly locate and handle the behavior of a single object in the location area. When a behavior that endangers the safety of oneself and others occurs in outdoor urban street scenes and indoor rail transit scenes, the system will automatically identify the subject of the behavior and issue an alarm, providing personnel with relevant needs with an efficient and convenient detection capability.
[0106] In the embodiment of the present application, the sparse detection frame and the dense detection frame are first determined by using the distribution of the detection frame in the acquired frame image, and then the sparse detection frame in each frame image is preprocessed to obtain at least one first sequence, thereby solving the problem of identifying the behavior of a single object; at the same time, the dense detection frame in each frame image is preprocessed to obtain at least one second sequence, thereby solving the problem of identifying the behavior of a group of objects. A preprocessing logic that takes into account both the detection of the behavior of a single object and the detection of the behavior of a group of objects is proposed, which can adaptively adjust the receptive field of different types of behaviors, i.e., different action execution subjects, and can solve the problem of a small effective perception range when identifying a full-view video sequence to be identified.
[0107] Figure 3 A flow chart of another behavior recognition method provided in an embodiment of the present application is as follows: Figure 3 As shown, the process of "generating the at least one first sequence according to the sparse detection frame in each frame of the image and the object identifier associated with the sparse detection frame" in the above step S230 may at least include the following steps:
[0108] Step S310: for all frame images in the frame sequence buffer, taking the union of the sparse detection boxes associated with each object identifier in spatial position to obtain the minimum bounding box of a single object corresponding to each object identifier.
[0109] Here, the spatial position of the sparse detection frame associated with each object identifier in different frame images may be mobile. By taking the union, the sparse detection frames at different spatial positions can be merged into a larger area and used as the minimum bounding box of a single object corresponding to each object identifier. For example, the detection frames of pedestrians belonging to the same ID (Identity document) in the frame sequence buffer are taken in spatial position to obtain the minimum bounding box of the pedestrian in the frame sequence buffer.
[0110] Step S320: According to the size of the minimum bounding box, a first region image corresponding to the spatial position of the minimum bounding box in each frame image is captured.
[0111] Here, the first area image in each frame is captured with the minimum bounding box, which can avoid the loss of the relative position of the behavior subject and has a good performance improvement for the behavior detection of single objects with similar space but different motion rhythms.
[0112] It is worth noting that when capturing the first region image, there may be some frame images in which the sparse detection frame corresponding to the object identifier does not appear. In this case, the candidate detection frames belonging to the object identifier in other frame images in the video frame sequence can be used to perform a union operation to obtain the minimum bounding box belonging to the object identifier, and the minimum bounding box can be used to capture the pure color background as the first region image.
[0113] Step S330 : connecting the first region images in sequence according to the timestamp of each frame of the image to obtain a first sequence corresponding to each of the object identifiers.
[0114] Here, the first region images belonging to each object identifier are connected in time order, so as to obtain a first sequence corresponding to each object identifier.
[0115] In the embodiment of the present application, the sparse detection frames that are screened out and do not overlap with other detection frames are processed to generate the first sequence of single object trajectory behavior, thereby converting the problem of single object behavior recognition in the full-view video sequence to be recognized into the problem of first sequence recognition, which can simplify the operation and effectively extract useful information. At the same time, each frame of the image is intercepted with the minimum bounding box to obtain the first sequence, which can avoid the loss of the relative position of the behavior subject and has a good performance improvement for the detection of behaviors with similar space but different motion rhythms.
[0116] Figure 4 A flow chart of another behavior recognition method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the above step S240 "generating the at least one second sequence according to the dense detection frame in each frame of the image and the object identifier associated with the dense detection frame" includes at least the following steps:
[0117] Step S410, expanding the dense detection frame in each frame image in the frame sequence buffer outward by a specific ratio to obtain a dense area in each frame image and an object identifier associated with the dense area.
[0118] Here, the specific ratio may be an empirical value, or may be determined according to an actually captured application scene image, so that the expanded dense area (patch) can surround all execution entities where group object behaviors occur as much as possible.
[0119] It should be noted that after the area corresponding to the dense detection frame is adaptively expanded outward according to a specific ratio, the resulting area is still a rectangular area. In order to facilitate subsequent processing, the size of the dense areas after the expansion of different dense detection frames can be normalized. For example, the long side size of the dense area is adjusted to 224 pixels, and the short side of the dense area is scaled proportionally with the long side, and the short side that is less than 224 pixels after scaling is filled with black edges at the top and bottom.
[0120] Here, the dense area includes at least two objects, one of which is an object associated with the dense detection frame; and the object identifier associated with the dense detection frame is used as the object identifier associated with the dense area.
[0121] Step S420, determining whether the merge flag of the frame sequence buffer is true.
[0122] Here, the merge tag is a preset hyperparameter used to characterize whether dense areas of frame images in the frame sequence buffer are merged, and the value of the merge tag can be determined to be true or false according to the background similarity of the frame images in the frame sequence buffer.
[0123] For example, for a video sequence shot at a fixed angle, if the background of each frame is consistent, the merge label is set to true; for an image sequence shot by a handheld device, if the background of each frame changes significantly, the merge label is set to false.
[0124] Step S430 , when the merge tag is true, taking the union of the dense areas in each frame image in the frame sequence buffer, to obtain a dense bounding box of the frame sequence buffer.
[0125] Here, the ranges of dense areas in different frame images in the frame sequence buffer are merged to obtain a dense bounding box with a larger range.
[0126] Step S440: According to the size of the dense bounding frame, a second region image corresponding to the spatial position of the dense bounding frame in each frame image is intercepted.
[0127] Here, image segmentation technology or other image processing technology in related technologies can be used to intercept the second area image corresponding to the spatial position of the dense bounding box in each frame image, and the embodiment of the present application is not limited to this.
[0128] Step S450: connecting the second region images in sequence according to the timestamp of each frame of the image to generate a second sequence.
[0129] Here, each frame image in the video sequence to be identified carries its own timestamp, which can be a timestamp set when the camera or other acquisition device is acquiring the image, or a timestamp set in the subsequent sampling process of the original image sequence, or a timestamp set in other achievable ways, and the embodiments of the present application are not limited to this.
[0130] Step S460, when the merge tag is false, each frame of the image is respectively intercepted according to the dense area of each frame of the image to obtain a fourth region image with a length and a width of specific pixels.
[0131] Here, the merge tag is false, that is, the dense area in each frame image in the frame sequence buffer is not merged, which is suitable for the situation where the background of each frame image in the video sequence to be identified changes greatly.
[0132] Here, the specific pixel is an empirical value, such as 224*224, which represents a rectangular image with a length and a width of 224 pixels.
[0133] In some other embodiments, if a certain frame image in the frame sequence buffer lacks a dense detection frame, a rectangular frame of a fixed size at the center of the frame image may be used as the fourth region image.
[0134] The above step S460 can also be implemented by the following implementations:
[0135] When there is a first frame image in the frame sequence buffer, a regional image of the first frame image centered on the center point of the first frame image and with specific pixels as length and width is used as the fourth regional image of the first frame image; wherein the first frame image is a frame image that does not include a dense detection frame.
[0136] Step S470: sequentially connect the fourth region images according to the timestamp of each frame of the image to generate the at least one second sequence.
[0137] The above-mentioned step S430 is a non-essential step and can be omitted in certain special application scenarios. For example, in a fixed-angle shooting scenario, the merged label usually takes the true value by default, that is, the dense area of each frame image in the video sequence to be identified is merged by default. The above-mentioned steps S440 to S450 and steps S460 to S470 are two parallel schemes. In actual implementation, according to the value of the merged label, you can choose to execute only one of the schemes. In this way, the second area image in each frame image is obtained through step S440 or the fourth area image in each frame image is obtained through step S460 to replace the original video sequence to be identified and input into the network model, which can reduce the receptive field of the group object behavior event while maintaining the spatial relative position information of the behavior group.
[0138] In the embodiment of the present application, the dense detection frame predicted to be prone to group object behavior is expanded outward, so that the expanded dense area surrounds all objects of group behavior as much as possible. At the same time, by determining the dense bounding box of the frame sequence buffer, each frame image is intercepted with the dense bounding box to obtain the second sequence, which can reduce the receptive field of group object behavior events, thereby improving the accuracy and efficiency of behavior recognition.
[0139] In some other embodiments, the video sequence to be identified is composed of frame images in a frame sequence buffer, each frame image in the frame sequence buffer includes at least one dense detection box, and each group of objects included in the second sequence of images includes at least the same object. Figure 5 A flow chart of another behavior recognition method provided in an embodiment of the present application is shown as follows: Figure 5 As shown, the above step S240 "generating the at least one second sequence according to the dense detection frame in each frame of the image and the object identifier associated with the dense detection frame" includes at least the following steps:
[0140] Step S510: Expand each dense detection frame in each frame of the image outward by a specific ratio to obtain a dense area corresponding to each dense detection frame and an object identifier associated with the dense area.
[0141] Here, the dense area includes at least two objects, one of which is an object associated with the dense detection frame; and the object identifier associated with the dense detection frame is used as the object identifier associated with the dense area.
[0142] Step S520: based on the object identifiers associated with the dense regions, taking a union of the dense regions including the same object, to obtain at least one dense bounding box including the same object.
[0143] Here, the dense regions including the same object are associated with the same object identifier, and the dense regions corresponding to each object identifier are unioned to obtain a dense bounding box corresponding to each object identifier. Different object identifiers result in different dense bounding boxes.
[0144] Step S530 : According to the size of each dense bounding frame, a third region image corresponding to the spatial position of the dense bounding frame in each frame image is intercepted.
[0145] Here, the third area image is captured based on the dense bounding box determined by the same object identifier, ensuring that the generated second sequence includes at least the same object, which can continuously detect the behavior of group objects, and is conducive to the subsequent detection system to automatically identify the object where the behavior occurs, bringing convenience to departments with related needs.
[0146] Step S540: sequentially connect the third region images according to the timestamp of each frame of the image to generate the at least one second sequence including the same object.
[0147] Here, the third region image in the second sequence including the same object is captured according to the dense bounding box corresponding to the same object identifier, thereby generating a second sequence corresponding to the object identifier. Different second sequences can be generated according to dense bounding boxes corresponding to different object identifiers.
[0148] In the embodiment of the present application, by identifying the object associated with the dense area, a dense bounding box including the same object in the frame sequence buffer is determined, and each frame image is intercepted with the dense bounding box to obtain a second sequence including the same object, which can reduce the receptive field of group object behavior events, thereby improving the accuracy and efficiency of behavior recognition. At the same time, the relative position loss of the behavior group is avoided, and the performance of behavior detection with similar space but different movement rhythm is improved.
[0149] In some other embodiments, the video sequence to be identified is composed of frame images in a frame sequence buffer. Figure 6 A flow chart of another behavior recognition method provided in an embodiment of the present application is shown as follows: Figure 6 As shown, the “generating at least one first sequence according to the detection result of each of the objects” includes at least the following steps:
[0150] Step S610, determining a sparse detection frame in each frame image according to the distribution of the detection frame of each object in the corresponding frame image.
[0151] Step S620: Generate the at least one first sequence according to the sparse detection frame in each frame of the image and the object identifier associated with the sparse detection frame.
[0152] Here, the implementation process of step S610 to step S620 is similar to the implementation process of steps S220 to S230 in the above embodiment, and will not be described here to avoid repetition.
[0153] Step S630, determining the number of first object identifiers associated with the sparse detection boxes in each frame image in the frame sequence buffer.
[0154] Here, each sparse detection frame is associated with a corresponding object identifier, and the sparse detection frames in each frame image in the frame sequence buffer are counted to determine the number of first object identifiers.
[0155] Step S640: When the number of the first object identifiers is less than a specific threshold, select a candidate detection box from a dense area in each frame of the image.
[0156] Here, the specific threshold is determined according to the maximum number of parallel computing paths allowed on the line. When the number of first object identifiers is less than the specific threshold, the number of first sequences generated according to the sparse detection frames and the object identifiers associated with the sparse detection frames in the frame sequence buffer is also less than the specific threshold, and the detection frames that are prone to single object behavior can be screened out from the dense area in each frame image for subsequent processing, so that the total number of first sequences finally generated reaches the maximum threshold.
[0157] Here, the number of overlaps between the candidate detection frame and other detection frames is less than the first number threshold. That is, the candidate detection frame is a relatively independent detection frame in a dense area, and single object behavior may also occur.
[0158] In some possible implementations, the candidate detection frame can be determined by the following process: determining the specific threshold value based on the number of second object identifiers associated with the dense detection frame in each frame image in the frame sequence buffer and specific processing parameters; determining the number of third object identifiers associated with the candidate detection frame based on the first object identifier number and the specific threshold value; and selecting, according to the third object identifier number, a detection frame whose number of overlaps with other detection frames is less than the first number threshold from the dense area in each frame image as the candidate detection frame.
[0159] Here, assuming that the specific threshold is L and the number of first object identifiers is M, that is, M first sequences are determined based on the sparse detection frames, where L is an integer greater than or equal to 2, and M is any integer from 1 to L-1. Detection frames whose overlap times with other detection frames are less than the first number threshold can be selected from the dense area as candidate detection frames, and the object identifiers associated with these candidate detection frames are LM, so that LM first sequences can be generated later based on these candidate detection frames.
[0160] Step S650: Generate the at least one first sequence according to the candidate detection box and the object identifier associated with the candidate detection box.
[0161] Here, the method of generating the at least one first sequence may be the same as the method of generating the at least one first sequence according to the sparse detection frame and the object identifier associated with the sparse detection frame in step S620.
[0162] In an embodiment of the present application, in the process of preprocessing the video sequence to be identified to generate a first sequence, when the first sequence generated based on the sparse detection frame does not meet a specific threshold, it is possible to generate a first sequence by selecting candidate detection frames with a smaller number of overlaps in a dense area, thereby ensuring that effective computing power is used to achieve the accuracy of single object behavior recognition and improving the efficiency and performance of the model.
[0163] In some other embodiments, the multi-task recognition network model is obtained by training a behavior recognition model constructed using a first sample data set of single object behavior and a second sample data set of group object behavior; wherein the constructed behavior recognition model includes a backbone network and at least one classification network, and the multi-task recognition network model includes a multi-task backbone network obtained by training the backbone network and a multi-task classification network corresponding to the task to be identified obtained by training the classification network; the task to be identified includes at least one of the following: a task type for single object behavior and a task type for group object behavior.
[0164] The behavior recognition model built is a behavior recognition model that includes a backbone network and N classification networks (one-to-one correspondence with N tasks to be recognized). The backbone network is a network used for feature extraction, representing a part of the network, and is generally used for front-end extraction of image information for use by the subsequent network. VGGNet, Residual Neural Network (ResNet), and inception network models are usually used. Among them, VGGNet is a deep convolutional neural network. These backbone networks have strong feature extraction capabilities and can load the official model parameters trained on large data sets, and then connect their own networks for fine-tuning. The classification network can be implemented by fully connected layers (Fully Connected Layers, FC) or head networks. The fully connected layer plays the role of a "classifier" in the entire convolutional neural network. In the entire convolutional neural network, the convolution layer, pooling layer, and activation function layer are operations that map the original data to the hidden layer feature space, and the fully connected layer plays the role of mapping the learned "distributed feature representation" to the sample tag space. In actual use, the fully connected layer can be implemented by convolution operation to build a behavior recognition model trained using sample data sets of N tasks to be recognized, and N classification networks corresponding to the N tasks to be recognized in the multi-task behavior recognition model are obtained.
[0165] Figure 7 A flowchart of the training process of the multi-task recognition network model provided in the embodiment of the present application is shown in FIG. Figure 7 As shown, the process includes the following steps:
[0166] Step S710: Use the first sample data set and the second sample data set to respectively train the constructed behavior recognition model to obtain a first video recognition network for a single object and a second video recognition network for a group of objects.
[0167] Here, the first sample data set may be a sequence of image frames containing the behavior of a single object. For example, when the object is a person, it is generally believed that there is only one executor involved in a behavior that endangers its own safety, that is, a single object behavior, such as a single person's climbing, falling, or falling into water.
[0168] Here, the second sample data set may be an image frame sequence containing group object behaviors. For example, when the objects are people, it is generally considered that there are multiple execution subjects involved in behaviors that endanger the safety of others and themselves, namely group object behaviors. It should be noted that the first sample data set and the second sample data set should be image frame sequences obtained by processing the same sample video sequence.
[0169] Here, both the first video recognition network and the second video recognition network include the backbone network and at least one classification network. The first video recognition network is used to identify the behavior of a single object, and at least one classification network in the first video recognition network is used to identify the task type corresponding to each single object behavior. For example, in the behaviors of a single person such as climbing, falling, stealing, and damaging property, each behavior corresponds to its own classification network, but shares the same backbone network. The second video recognition network is used to identify the task type corresponding to the behavior of a group of objects. For example, in the behaviors of multiple people such as climbing and trampling, each behavior corresponds to its own classification network, but shares the same backbone network.
[0170] Step S720: Use the first video recognition network and the second video recognition network to train the backbone network to obtain the multi-task backbone network.
[0171] Here, the multi-task backbone network can be a backbone network suitable for multiple different tasks to be identified, so it is necessary to use sample data sets of different behavior types to train the backbone network in the constructed behavior recognition model to obtain a universal, fixed, multi-task backbone network that can identify different tasks to be identified.
[0172] In some possible implementations, the backbone network is trained to obtain a multi-task backbone network through the following process: obtaining a first feature vector of the first video recognition network and a second feature vector of the second video recognition network; using the first feature vector and the second feature vector as target features, training the backbone network in the constructed behavior recognition model, and obtaining the multi-task backbone network.
[0173] Here, the first feature vector of the first video recognition network and the second feature vector of the second video recognition network are used as target features to train the backbone network in the constructed behavior recognition model, and the features of all samples in each type of event can be obtained. In implementation, the feature results output by multiple single models such as the first video recognition network or the second video recognition network through the multi-task backbone network are applied as supervisory signals (L2 loss or KL loss) to the output results of the multi-task backbone network, and trained together with the cross entropy function (CE) to obtain the multi-task backbone network.
[0174] The loss function, also called the error function, is used to measure the operation of the algorithm and the degree of inconsistency between the model's predicted value and the true value. It is a non-negative real-valued function. The smaller the loss function, the better the robustness of the model. The loss function is the core part of the empirical risk function and an important part of the structural risk function. The loss function is used to evaluate the degree of difference between the predicted value and the true value. Usually, the better the loss function, the better the performance of the model. The cross entropy function is used to describe the gap between the model's predicted value and the true value. The larger the gap, the less similar it is. The cross entropy function can be derived from the maximum likelihood function under the condition of Bernoulli distribution.
[0175] The core idea of knowledge distillation is to transfer knowledge so as to obtain a small model that is more suitable for reasoning from a trained large model. Through the knowledge distillation method, the features of the multi-task recognition network model are aligned with the features of the first video recognition network or the second video recognition network, so as to obtain a better backbone network to meet the requirements of consistent features.
[0176] Step S730: Use the first sample data set and the second sample data set to train a first behavior recognition model to obtain the multi-task recognition network model.
[0177] Here, the first behavior recognition model includes the multi-task backbone network and the at least one classification network.
[0178] Here, the trained multi-task backbone network is combined with at least one classification network to obtain a first behavior recognition model, and the first behavior recognition model is trained using the first sample data set and the second sample data set to obtain a multi-task recognition network model.
[0179] The embodiment of the present application uses a first sample data set of single object behavior and a second sample data set of group object behavior to respectively train the basic network structure (multiple tasks share a backbone network), thereby obtaining a multi-task recognition network model that can simultaneously perform task recognition of single object behavior and task recognition of group object behavior. It is possible to extract features of different tasks to be recognized on a backbone network, effectively improving the feature extraction accuracy of the backbone network. At the same time, the accuracy of the multi-task backbone network obtained by knowledge distillation is not lower than the accuracy of the backbone network in the first video recognition network or the second video recognition network.
[0180] The above behavior recognition method is described below in conjunction with a specific embodiment. However, it should be noted that this specific embodiment is only for better illustrating the present application and does not constitute an improper limitation on the present application.
[0181] The embodiments of the present application are explained by taking pedestrians as an example. The number of people performing the action of an event in the acquired video source is uncertain (it can usually be divided into single-person behavior and multi-person behavior according to the number of people performing the action of the event), and different types of event recognition require different spatial receptive fields; in urban street scenes, there may be ordinary pedestrians in different positions and fields of view, and the location where the behavioral event that really needs to be detected usually only occupies a small area of the screen; there may be overlap in spatial position between ordinary pedestrians and pedestrians who perform preset behaviors, causing interference at the recognition level. Therefore, it is urgent to explore a method for joint detection of single / multi-person behaviors that is compatible, which can support common indoor and outdoor scenes such as urban streets and rail transit, so that the automatic analysis of behavioral events in video content can provide convenience and evidence collection capabilities for relevant departments.
[0182] The embodiment of the present application provides a single-person and multi-person behavior joint detection method for urban street scenes, which is explained by taking the first sequence as a trajectory sequence of a single person and the second sequence as a dense area sequence of multiple people. In the embodiment of the present application, sparse areas and dense areas are automatically divided mainly according to the crowd density distribution, and a unified detection framework is proposed that takes into account the single-person behavior detection preprocessing logic based on the trajectory sequence and the multi-person behavior detection preprocessing logic based on the dense area.
[0183] Fig. 8A A system block diagram of a single-person and multi-person behavior joint recognition algorithm provided in an embodiment of the present application; Fig. 8A As shown, the video sequence to be identified 81a is first passed through a preprocessor 82a to generate N2 trajectory sequences 822a and N1 dense area sequences 821a; then all trajectory sequences 822a and all dense area sequences 821a are input into a multi-task recognition network model 83a; after being processed by the multi-task recognition network model 83a, the recognition results of single-person behaviors such as climbing and falling and the recognition results of multi-person behaviors such as trampling and hugging are output.
[0184] based on Fig. 8A The framework shown in the figure includes four stages: single model training, single model testing, all-in-one training, and all-in-one testing. The event detection models for different types (single-person behavior / multi-person behavior) and different tasks (trampling, climbing, falling, etc.) are relatively independent, and are trained and tested on their own dataset annotations.
[0185] like Figure 8B As shown, the single model training process for single-person behavior is as follows: obtain single-person behavior training data 812b, then pass the multi-person behavior training data 811b through the preprocessor 82b to generate N1 dense area sequences 821b; then input the N1 dense area sequences 821b into the multi-task recognition network model 83b; after processing by the video recognition network 83b, the recognition results of multi-person behavior are output. The single model training process for multi-person behavior is as follows: obtain single-person behavior training data 812b, then pass the single-person behavior training data 812b through the preprocessor 82b to generate N2 trajectory sequences 822b; then input the N2 trajectory sequences 822b into the multi-task recognition network model 83b; after processing by the multi-task recognition network model 83b, the recognition results of single-person behavior are output.
[0186] Then multiple tasks are merged to complete different detection task requirements within one network model, which is the all-in-one model training process. Generally speaking, it is difficult to achieve the same accuracy as the single model under each task by directly mixing the data sets of multiple different tasks together to train the all-in-one model and optimizing the backbone network at the same time. In order to alleviate this problem and make the all-in-one model possible, knowledge distillation is required, that is, using the single models of each task obtained during the single model training process to distill the head branches (fully connected layers) of different tasks in the all-in-one model, so that the accuracy is as close as possible to or even exceeds the accuracy of the single model, thereby giving full play to the promotion of multiple tasks.
[0187] like Figure 8CAs shown, in the first stage, the backbone network is trained first, and the N1 dense area sequences 811c and the N2 trajectory sequences 812c are input together into the backbone network of the all-in-one model, that is, the multi-task recognition network model 82c, to obtain the multi-person behavior feature vector f(N1) and the single-person behavior feature vector f(N2). To ensure that the accuracy of each type of single model remains unchanged when training the all-in-one model. Through knowledge distillation, the feature results output by the single model of multi-person behavior and the single model of single-person behavior are applied as supervisory signals (L2 loss or KL loss) to the network output of the multi-task recognition network model 82c, and trained together with the standard cross entropy. In the second stage, the fully connected layer is trained again, and the N1 dense area sequences 811c and the N2 trajectory sequences 812c are input together into the fully connected layer of the multi-task recognition network model 82c, to obtain the classification results of multi-person behavior (fc1) and the classification results of single-person behavior (fc2).
[0188] After completing the all-in-one model training, it is necessary to conduct an online all-in-one test deployment. Since we often do not know the types of events that may be contained in online videos, we cannot directly determine whether to use the trajectory sequence-based preprocessing logic for a single person or the dense area-based preprocessing logic for multiple people. Therefore, the embodiment of the present application provides an adaptive sparse / dense area division logic to calculate the number of matches with surrounding pedestrians based on the distribution of pedestrians in the video screen. Fig.8D As shown, the process includes the following steps:
[0189] Step S801: extracting pedestrian detection results in the video sequence to be processed.
[0190] Here, firstly, the full-image video sequence captured by the device that collects the video source is obtained as the video sequence to be processed, and then the upstream structured detection component is called to extract the detection frames of pedestrians in the video sequence to be processed and the identification of the detection frame corresponding to each pedestrian in the video sequence to be processed.
[0191] Step S802: construct a spatial density map of the detection frame in the video sequence to be processed according to the detection result.
[0192] Here, the spatial density map can be presented in the form of an adjacency matrix, where the elements in the adjacency matrix are the intersection-and-union ratios between every two detection frames. In implementation, based on the density distribution of the detection frames of different pedestrians, all the detection frames of the current frame can be expanded outward by a specific ratio (the default is 1.5 times), and then sorted in descending order by area; the overlap ratio between every two detection frames among the detection frames with the largest areas (for example, 10) is calculated, and the number of matches for each detection frame is counted.
[0193] Step S803: determining the dense area and the sparse area of each frame image in the to-be-processed video sequence according to the spatial density map of the detection frame.
[0194] Here, the detection frame with 0 matching times in the previous step is defined as a sparse detection frame, and the area corresponding to the sparse detection frame is the sparse area; the detection frame with the most matching times is defined as a dense detection frame, and the area corresponding to the dense detection frame and all detection frames overlapping with the dense detection frame is the dense area. For example, the dense detection frame is reduced to the original resolution, and a larger expansion ratio is defined, and it is adaptively expanded outward according to the expansion ratio to obtain a larger rectangular frame as the dense area of the current frame. It is generally believed that multi-person behavior is prone to occur in dense areas, and the dense detection frame is the center of the multi-person behavior. Therefore, the rectangular frame obtained by expanding the dense detection frame outward, that is, the dense area, should surround the group where the multi-person behavior occurs as much as possible.
[0195] Step S804: Generate N2 trajectory sequences for single-person behavior recognition based on the sparse region.
[0196] Here, the sparse detection frame in the sparse area is reduced to the original resolution, and the pedestrians belonging to the sparse detection frame are connected according to the results of the previous and next frame sequences (including the detection frame and the associated identification) to form a single-person behavior trajectory sequence for each pedestrian as the trajectory sequence; at the same time, the value of N2 is determined according to the number of identifications corresponding to the sparse detection frame.
[0197] Step S805 , generating N1 dense area sequences for multi-person behavior recognition based on the dense areas.
[0198] Here, a merge label is defined according to whether to merge the dense areas determined in the video sequence to be recognized. If the merge label is true, the dense areas determined by the previous and next frame images are merged into a larger dense bounding box to capture each frame image, and finally the captured image sequence, i.e., the dense area sequence, is sent to the multi-task recognition network model for recognition; if the merge label is false, the dense areas determined by each frame image are captured separately, and finally the captured image sequence, i.e., the dense area sequence, is also sent to the model for recognition.
[0199] The value of N1 is determined according to the number of dense detection boxes in each frame of the video sequence to be identified, and is 1 by default. The sum of N1 and N2 is a specific value, which depends on the maximum number of parallel computing paths allowed on the line, for example, a maximum of 32.
[0200] When there are two dense detection frames in each frame of the video sequence to be identified, that is, when N1 is 2, the value of N2 is determined according to the sum of N1 and N2. If the number of sparse areas determined in step S803 is less than the value of N2, the detection frame of a single person is selected as the sparse detection frame in the dense area to generate a trajectory sequence.
[0201] Step S806: input the N1 dense area sequences and the N2 trajectory sequences together into a multi-task recognition network model for recognition.
[0202] Here, the N1 dense area sequences based on dense areas are sent to the corresponding multi-person task head branch, i.e., the fully connected layer, for multi-person action recognition after feature extraction by the backbone network; and the N2 trajectory sequences based on sparse areas are also sent to the corresponding single-person task head branch, i.e., the fully connected layer, for single-person action recognition after feature extraction.
[0203] In the above step S805, the process of intercepting the regional image in each frame image according to the dense area is as follows: first, the regional image in each frame image is intercepted according to the size of the dense area, and then the long side of the regional image is resized to 224 pixels, and then the short side of the regional image is scaled proportionally, and the upper and lower black edges are filled if it is less than 224 pixels. If there is no pedestrian in a frame image, when the merge tag is true, the regional image of the current frame is intercepted with the dense bounding box merged with other frame images; when the merge tag is true, a 224*224 regional image is intercepted with the center point of the current frame image as the center. If there is no pedestrian detection box result in the input video clips, a 224*224 regional image is uniformly extracted from each frame image with the center point of the image.
[0204] The embodiments of the present application can be applied to outdoor urban street scenes and indoor rail transit scenes. When events of different types / with different numbers of people occur in these scenes, the device collecting the video source will automatically identify the area and type of the event, and alarm the personnel with related needs, providing an efficient and convenient detection capability.
[0205] The embodiment of the present application realizes the automatic switching of two different pre-processing schemes under single / multi-person at the data processing level, and automatically divides sparse areas and dense areas according to the dense distribution of the number of people. It can be compatible with different types of behavior detection needs such as single / multi-person, forming a unified framework to provide support for subsequent multi-task training. At the model training level, it includes steps such as single model training / testing and all-in-one training / testing, so that the model accuracy under multi-task is not lower than the accuracy during single-task training, and greatly improves the efficiency and performance of the model. It realizes multi-task behavior detection application, without the need to train a model separately for each demand, resulting in redundancy of model capacity, and is easier to expand demand compared to previous technologies.
[0206] Based on the foregoing embodiments, the embodiments of the present application further provide a behavior recognition device, which includes the modules included, the sub-modules included in each module, and the units included in each sub-module, which can be implemented by a processor in the device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.
[0207] Fig. 9 A schematic diagram of the structure of a behavior recognition device provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the identification device 900 includes an acquisition module 910, a generation module 920 and an identification module 930, wherein:
[0208] The acquisition module 910 is used to acquire the detection result of each object in each frame of the video sequence to be identified; wherein the video sequence to be identified includes a single object and / or a group of objects; the group of objects includes at least two objects whose spatial distance is less than a distance threshold;
[0209] The generating module 920 is used to generate at least one first sequence and / or at least one second sequence according to the detection result of each of the objects, wherein the first sequence and the second sequence each include one of the following: the same single object, the group of objects;
[0210] The recognition module 930 is used to use the trained multi-task recognition network model to perform behavior recognition on each of the first sequences and / or each of the second sequences, respectively, to obtain a behavior recognition result of each of the single objects and / or a behavior recognition result of the group of objects.
[0211] In some possible embodiments, the detection result of the object includes at least a detection frame of the object and an object identifier associated with the detection frame; the generation module 920 includes a first determination submodule and a first generation submodule, wherein: the first determination submodule is used to determine the sparse detection frame in each frame image according to the distribution of the detection frame of each object in the corresponding frame image; wherein the number of overlaps between the sparse detection frame and other detection frames in each frame image except the sparse detection frame is less than a first number threshold; the first generation submodule is used to generate the at least one first sequence according to the sparse detection frame in each frame image and the object identifier associated with the sparse detection frame.
[0212] In some possible embodiments, the generation module 920 includes the first determination submodule and the second generation submodule, wherein: the first determination submodule is also used to determine the dense detection frame in each frame image according to the distribution of the detection frame of each object in the corresponding frame image; wherein the number of overlaps between the dense detection frame and other detection frames in each frame image except the dense detection frame is greater than or equal to a second number threshold, and the second number threshold is greater than the first number threshold; and the second generation submodule is used to generate the at least one second sequence according to the dense detection frame in each frame image and the object identifier associated with the dense detection frame.
[0213] In some possible embodiments, the first determination submodule includes a first determination unit and a second determination unit, wherein: the first determination unit is used to determine the number of detection boxes included in each frame image; the second determination unit is used to determine the sparse detection boxes in the corresponding frame image when the number of detection boxes is 1.
[0214] In some possible embodiments, the first determination submodule includes the first determination unit, the third determination unit, the fourth determination unit and the fifth determination unit, wherein: the third determination unit is used to generate the adjacency matrix corresponding to each frame of the image according to the intersection and union ratio between every two detection frames in each frame of the image when the number of the detection frames is greater than or equal to 2; the fourth determination unit is used to use the detection frames with zero matching times in the adjacency matrix as sparse detection frames in each frame of the image; the fifth determination unit is used to use the detection frames with matching times in the adjacency matrix greater than or equal to a third number threshold as dense detection frames in each frame of the image; wherein the third number threshold is greater than the second number threshold.
[0215] In some possible embodiments, the video sequence to be identified is composed of frame images in a frame sequence buffer, and the first generating submodule includes a first merging unit, a first intercepting unit and a first connecting unit, wherein: the first merging unit is used to take the union of the sparse detection frames associated with each object identifier in spatial position for all frame images in the frame sequence buffer to obtain the minimum enclosing frame of a single object corresponding to each object identifier; the first intercepting unit is used to intercept the first area image corresponding to the spatial position of the minimum enclosing frame in each frame image according to the size of the minimum enclosing frame; the first connecting unit is used to connect the first area images in sequence according to the timestamp of each frame image to obtain a first sequence corresponding to each object identifier.
[0216] In some possible embodiments, the video sequence to be identified is composed of frame images in a frame sequence buffer, and the second generating submodule includes a first expansion unit, a second merging unit, a second interception unit and a second connection unit, wherein: the first expansion unit is used to expand the dense detection frame in each frame image in the frame sequence buffer outward by a specific proportion to obtain a dense area in each frame image and an object identifier associated with the dense area; wherein the dense area includes at least two objects; the second merging unit is used to take the union of the dense areas in each frame image in the frame sequence buffer to obtain a dense bounding box of the frame sequence buffer; the second interception unit is used to intercept a second area image corresponding to the spatial position of the dense bounding box in each frame image according to the size of the dense bounding box; the second connection unit is used to connect the second area images in sequence according to the timestamp of each frame image to generate a second sequence.
[0217] In some possible embodiments, the group of objects included in each of the images in the second sequence includes at least the same object.
[0218] In some possible embodiments, the video sequence to be identified is composed of frame images in a frame sequence buffer, each frame image in the frame sequence buffer includes at least one dense detection frame, and the second generation submodule includes a second expansion unit, a third merging unit, a third interception unit and a third connection unit, wherein: the second expansion unit is used to expand each dense detection frame in each frame image outward by a specific proportion to obtain a dense area corresponding to each dense detection frame and an object identifier associated with the dense area; wherein the dense area includes at least two objects; the third merging unit is used to take the union of dense areas including the same object according to the object identifier associated with the dense area, to obtain at least one dense bounding box including the same object; the third interception unit is used to intercept a third area image corresponding to the spatial position of the dense bounding box in each frame image according to the size of each dense bounding box; the third connection unit is used to connect the third area images in sequence according to the timestamp of each frame image to generate the at least one second sequence including the same object.
[0219] In some possible embodiments, the second generating submodule further includes a sixth determining unit, which is used to determine whether the merge label of the frame sequence buffer is true; wherein the merge label is a label for determining whether the dense areas of the frame images in the frame sequence buffer are merged according to the background similarity of the frame images in the frame sequence buffer; accordingly, the second merging unit is also used to take the union of the dense areas in each frame image in the frame sequence buffer when the merge label is true, so as to obtain a dense bounding box of the frame sequence buffer.
[0220] In some possible embodiments, the second generation submodule also includes a fourth cropping unit and a fourth connection unit, wherein: the fourth cropping unit is used to, when the merge label is false, crop each frame image according to the dense area of each frame image, to obtain a fourth area image whose length and width are both specific pixels; the fourth connection unit is used to connect the fourth area images in sequence according to the timestamp of each frame image to generate the at least one second sequence.
[0221] In some possible embodiments, the fourth interception unit is also used to, when there is a first frame image in the frame sequence buffer, use a regional image of the first frame image centered on the center point of the first frame image and with specific pixels as the length and width as the fourth regional image of the first frame image; wherein the first frame image is a frame image that does not contain a dense detection frame.
[0222] In some possible embodiments, the video sequence to be identified is composed of frame images in a frame sequence buffer, and the generation module 920 also includes a second determination submodule, a screening submodule and a third generation submodule, wherein: the second determination submodule is used to determine the number of first object identifiers associated with the sparse detection box in each frame image in the frame sequence buffer; the screening submodule is used to select a candidate detection box from a dense area in each frame image when the number of the first object identifiers is less than a specific threshold; wherein the number of overlaps between the candidate detection box and other detection boxes is less than the first number threshold; and the third generation submodule is used to generate the at least one first sequence based on the candidate detection box and the object identifier associated with the candidate detection box.
[0223] In some possible embodiments, the screening submodule includes a sixth determination unit, a seventh determination unit and a selection unit, wherein: the sixth determination unit is used to determine the specific threshold value based on the number of second object identifiers associated with the dense detection frame in each frame image in the frame sequence buffer and specific processing parameters; the seventh determination unit is used to determine the number of third object identifiers associated with the candidate detection frame based on the first object identifier number and the specific threshold; the selection unit is used to select, from the dense area in each frame image, a detection frame whose number of overlaps with other detection frames is less than the first number threshold according to the third object identifier number, as the candidate detection frame.
[0224] In some possible embodiments, the multi-task recognition network model is trained using a first sample data set of single object behavior and a second sample data set of group object behavior; wherein the multi-task recognition network model includes a backbone network and a classification network corresponding to the task to be recognized; the task to be recognized includes at least one of the following: a task type of single object behavior and a task type of group object behavior.
[0225] In some possible embodiments, the multi-task recognition network model includes a first classification network for performing behavior recognition on the single object and a second classification network for recognizing the group object. The recognition module 930 includes a first recognition submodule and a second recognition submodule, wherein: the first recognition submodule is used to, in response to each of the first sequences including the single object, use the first classification network to recognize the at least one first sequence to obtain a behavior recognition result of each of the single objects; the second recognition submodule is used to, in response to each of the second sequences including the group object, use the second classification network to recognize the at least one second sequence to obtain a behavior recognition result of the group object.
[0226] In some possible embodiments, the recognition device 900 also includes a first training module, a second training module and a third training module, wherein: the first training module is used to use the first sample data set and the second sample data set to respectively train the constructed behavior recognition model to obtain a first video recognition network for a single object and a second video recognition network for a group of objects; wherein the first video recognition network and the second video recognition network both include the backbone network and at least one classification network; the second training module is used to use the first video recognition network and the second video recognition network to train the backbone network to obtain the multi-task backbone network; the third training module is used to use the first sample data set and the second sample data set to train the first behavior recognition model to obtain the multi-task recognition network model; wherein the first behavior recognition model includes the multi-task backbone network and the at least one classification network.
[0227] In some possible embodiments, the second training module includes an acquisition subunit and a training subunit, wherein: the acquisition subunit is used to acquire the first feature vector of the first video recognition network and the second feature vector of the second video recognition network; the training subunit is used to train the backbone network in the constructed behavior recognition model using the first feature vector and the second feature vector as target features to obtain the multi-task backbone network.
[0228] In some possible embodiments, the identification device 900 also includes a first determination module, a second determination module and an alarm module, wherein: the first determination module is used to determine the spatial position and behavior category of the single object behavior and / or group object behavior when there is a single object behavior and / or group object behavior in the video sequence to be identified; wherein the behavior category includes the category of the single object behavior and / or the category of the group object behavior; the second determination module is used to determine the alarm content according to the spatial position and the behavior category; the alarm module is used to send an alarm notification to the terminal device corresponding to the spatial position according to the alarm content.
[0229] It should be noted that the description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0230] It should be noted that in the embodiment of the present application, if the above-mentioned behavior recognition method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable the device (which can be a smart phone with a camera, a tablet computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0231] Correspondingly, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in any of the behavior recognition methods described in the above embodiments are implemented. Correspondingly, in an embodiment of the present application, a chip is also provided, and the chip includes a programmable logic circuit and / or program instructions, and when the chip is running, it is used to implement the steps in any of the behavior recognition methods described in the above embodiments. Correspondingly, in an embodiment of the present application, a computer program product is also provided, and when the computer program product is executed by a processor of a device, it is used to implement the steps in any of the behavior recognition methods described in the above embodiments.
[0232] Based on the same technical concept, an embodiment of the present application provides a behavior recognition device for implementing the behavior recognition method recorded in the above method embodiment. Fig.10 A hardware entity diagram of a behavior recognition device provided in an embodiment of the present application, such as Fig.10 As shown, the identification device 1000 includes a memory 1010 and a processor 1020. The memory 1010 stores a computer program that can be run on the processor 1020. When the processor 1020 executes the program, the steps in any behavior identification method described in the embodiments of the present application are implemented.
[0233] The memory 1010 is configured to store instructions and applications executable by the processor 1020, and can also buffer data to be processed or processed by the processor 1020 and various modules in the device (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0234] When the processor 1020 executes the program, the steps of any of the above-mentioned behavior recognition methods are implemented. The processor 1020 generally controls the overall operation of the device 1000.
[0235] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application are not specifically limited.
[0236] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM) and the like; it can also be various devices including one or any combination of the above-mentioned memories, such as a mobile phone, a computer, a tablet device, a personal digital assistant, etc.
[0237] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0238] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.
[0239] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0240] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0241] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present application.
[0242] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0243] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for the automatic test line of the device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks or optical disks.
[0244] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0245] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0246] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A behavior recognition method, characterized in that: The method comprises: Obtaining a detection result of each object in each frame of a video sequence to be identified; wherein the video sequence to be identified includes a single object and / or a group of objects; the group of objects includes at least two objects whose spatial distance is less than a distance threshold; generating at least one first sequence and / or at least one second sequence according to the detection result of each of the objects, wherein each of the first sequence and each of the second sequence includes one of the following: the same single object, the group of objects; Generating at least one first sequence and / or at least one second sequence according to the detection result of each of the objects comprises: Determine a sparse detection frame in each frame of image according to the distribution of the detection frame of each object in the corresponding frame of image; When the number of overlaps between the sparse detection frame and other detection frames in each frame of image except the sparse detection frame is less than a first number threshold; generating the at least one first sequence according to the sparse detection frame in each frame of the image and the object identifier associated with the sparse detection frame; The number of overlaps between the dense detection frame and other detection frames in each frame of the image except the dense detection frame is greater than or equal to a second number threshold; when the second number threshold is greater than the first number threshold; Generate at least one second sequence based on the dense detection frame in each frame of the image and the object identifier associated with the dense detection frame; use the trained multi-task recognition network model to perform behavior recognition on each of the first sequences and / or each of the second sequences, respectively, to obtain a behavior recognition result for each of the single objects and / or a behavior recognition result for the group of objects; the multi-task recognition network model includes a multi-task backbone network obtained by training the backbone network and a multi-task classification network corresponding to the task to be recognized obtained by training the classification network.
2. The method according to claim 1, characterized in that The determining of the sparse detection frame in each frame image according to the distribution of the detection frame of each object in the corresponding frame image includes: Determining the number of detection frames included in each frame of image; When the number of the detection frame is 1, the detection frame is determined as a sparse detection frame in the corresponding frame image.
3. The method according to claim 1, characterized in that The determining, according to the distribution of the detection frame of each object in the corresponding frame image, a sparse detection frame and a dense detection frame in each frame image, comprises: Determining the number of detection frames included in each frame of image; When the number of the detection frames is greater than or equal to 2, generating an adjacency matrix corresponding to each frame of the image according to an intersection-and-union ratio between every two detection frames in each frame of the image; Using the detection frames with zero matching times in the adjacency matrix as the sparse detection frames in each frame of the image; The detection frames whose matching times in the adjacency matrix are greater than or equal to a third number threshold are used as dense detection frames in each frame of the image; wherein the third number threshold is greater than the second number threshold.
4. The method according to any one of claims 1 to 3, characterized in that The to-be-recognized video sequence is composed of frame images in a frame sequence buffer, and generating the at least one first sequence according to the sparse detection frame in each frame image and the object identifier associated with the sparse detection frame includes: For all frame images in the frame sequence buffer, taking a union of the sparse detection frames associated with each of the object identifiers in spatial positions to obtain a minimum bounding box of a single object corresponding to each of the object identifiers; According to the size of the minimum bounding box, intercepting a first area image corresponding to the spatial position of the minimum bounding box in each frame of the image; The first region images are sequentially connected according to the timestamp of each frame of image to obtain a first sequence corresponding to each object identifier.
5. The method according to any one of claims 1 to 3, characterized in that: The to-be-recognized video sequence is composed of frame images in a frame sequence buffer, each frame image in the frame sequence buffer includes a dense detection frame, and generating the at least one second sequence according to the dense detection frame in each frame image and an object identifier associated with the dense detection frame includes: Expanding the dense detection frame in each frame of the image in the frame sequence buffer outward by a specific ratio to obtain a dense area in each frame of the image and an object identifier associated with the dense area; wherein the dense area includes at least two objects; Taking a union of dense regions in each frame image in the frame sequence buffer to obtain a dense bounding box of the frame sequence buffer; According to the size of the dense bounding frame, intercepting a second region image corresponding to the spatial position of the dense bounding frame in each frame image; The second region images are sequentially connected according to the timestamp of each frame of the image to generate a second sequence.
6. The method according to any one of claims 1 to 3, characterized in that: The group objects included in each of the images in the second sequence include at least the same object, the to-be-recognized video sequence is composed of frame images in a frame sequence buffer, each frame image in the frame sequence buffer includes at least one dense detection frame, and generating the at least one second sequence according to the dense detection frame in each frame image and the object identifier associated with the dense detection frame includes: For each dense detection frame in each frame of the image, expand outward a specific ratio to obtain a dense area corresponding to each dense detection frame and an object identifier associated with the dense area; wherein the dense area includes at least two objects; Taking a union of dense regions including the same object according to object identifiers associated with the dense regions, to obtain at least one dense bounding box including the same object; According to the size of each dense bounding frame, intercepting a third region image corresponding to the spatial position of the dense bounding frame in each frame image; The third region images are sequentially connected according to the timestamp of each frame of image to generate at least one second sequence including the same object.
7. The method according to claim 5, characterized in that The step of generating the at least one second sequence according to the dense detection frame in each frame of the image and the object identifier associated with the dense detection frame further includes: Determine whether the merge tag of the frame sequence buffer is true; wherein the merge tag is a tag for determining whether a dense area of the frame images in the frame sequence buffer is to be merged according to the background similarity of the frame images in the frame sequence buffer; The step of taking a union of dense regions in each frame image in the frame sequence buffer to obtain a dense bounding box of the frame sequence buffer includes: When the merge tag is true, a union of dense regions in each frame image in the frame sequence buffer is taken to obtain a dense bounding box of the frame sequence buffer.
8. The method according to claim 7, characterized in that The step of generating the at least one second sequence according to the dense detection frame in each frame of the image and the object identifier associated with the dense detection frame further includes: When the merged label is false, each frame of the image is intercepted according to the dense area of each frame of the image to obtain a fourth region image with a length and a width of specific pixels; The fourth region images are sequentially connected according to the timestamp of each frame of image to generate the at least one second sequence.
9. The method according to claim 8, characterized in that The step of generating the at least one second sequence according to the dense detection frame in each frame of the image and the object identifier associated with the dense detection frame further includes: In a case where the first frame image exists in the frame sequence buffer, taking a regional image of the first frame image with the central point of the first frame image as the center and the specific pixel as the length and width as the fourth regional image of the first frame image; The first frame image is a frame image that does not contain a dense detection frame.
10. The method according to any one of claims 1 to 3, wherein the video sequence to be identified is composed of frame images in a frame sequence buffer, and generating at least one first sequence according to the detection result of each object further comprises: Determine the number of first object identifiers associated with the sparse detection box in each frame image in the frame sequence buffer; When the number of the first object identifiers is less than a specific threshold, selecting a candidate detection frame from a dense area in each frame of the image; wherein the number of overlaps between the candidate detection frame and other detection frames is less than the first number threshold; The at least one first sequence is generated according to the candidate detection frame and the object identifier associated with the candidate detection frame.
11. The method according to claim 10, characterized in that When the number of the first object identifiers is less than a specific threshold, selecting a candidate detection frame from a dense area in each frame of the image includes: Determining the specific threshold value according to the number of second object identifiers associated with the dense detection box in each frame image in the frame sequence buffer and specific processing parameters; Determining the number of third object identifiers associated with the candidate detection frame according to the number of the first object identifiers and the specific threshold; According to the third object identification quantity, a detection frame whose number of overlaps with other detection frames is less than the first number threshold is selected from the dense area in each frame of the image as the candidate detection frame.
12. The method according to any one of claims 1 to 3, characterized in that: The multi-task recognition network model is trained using a first sample data set of single object behavior and a second sample data set of group object behavior; The multi-task recognition network model includes a backbone network and a classification network corresponding to the task to be recognized, and the task to be recognized includes at least one of the following: a task type of a single object behavior and a task type of a group object behavior.
13. The method according to any one of claims 1 to 3, characterized in that: The multi-task recognition network model includes a first classification network for performing behavior recognition on the single object and a second classification network for recognizing the group of objects. The method of using the trained multi-task recognition network model to perform behavior recognition on each of the first sequences and / or each of the second sequences to obtain a behavior recognition result of each of the single objects and / or a behavior recognition result of the group of objects includes: In response to each of the first sequences including the single object, using the first classification network to identify the at least one first sequence to obtain a behavior recognition result of each of the single objects; and / or, In response to each of the second sequences including the group object, the at least one second sequence is identified using the second classification network to obtain a behavior recognition result of the group object.
14. A behavior recognition device, characterized in that: The device comprises an acquisition module, a generation module and an identification module, wherein: The acquisition module is used to acquire the detection result of each object in each frame of the video sequence to be identified; wherein the video sequence to be identified includes a single object and / or a group of objects; the group of objects includes at least two objects whose spatial distance is less than a distance threshold; The generating module is used to generate at least one first sequence and / or at least one second sequence according to the detection result of each object, wherein the first sequence and the second sequence both include one of the following: the same single object and the group of objects; the generating module according to the detection result of each object includes: determining the sparse detection frame in each frame image according to the distribution of the detection frame of each object in the corresponding frame image; wherein when the number of overlaps between the sparse detection frame and other detection frames in each frame image except the sparse detection frame is less than a first number threshold; generating the at least one first sequence according to the sparse detection frame in each frame image and the object identifier associated with the sparse detection frame; the number of overlaps between the dense detection frame and other detection frames in each frame image except the dense detection frame is greater than or equal to a second number threshold; when the second number threshold is greater than the first number threshold; generating the at least one second sequence according to the dense detection frame in each frame image and the object identifier associated with the dense detection frame; The recognition module is used to use the trained multi-task recognition network model to perform behavior recognition on each of the first sequences and / or each of the second sequences, respectively, to obtain the behavior recognition results of each of the single objects and / or the behavior recognition results of the group of objects; the multi-task recognition network model includes a multi-task backbone network obtained by training the backbone network and a multi-task classification network corresponding to the task to be recognized obtained by training the classification network.
15. A behavior recognition device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the steps in the method according to any one of claims 1 to 13 are implemented.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.
