Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present disclosure more apparent, the present disclosure will be further described in detail with reference to the accompanying drawings, and the described embodiments should not be construed as limiting the present disclosure, and all other embodiments obtained by those skilled in the art without making inventive efforts are within the scope of protection of the present disclosure.
The inventor of the present disclosure has found through research that, in a conventional behavior recognition method, data of a full graph of an input video sequence is usually enhanced or other preprocessed and then sent to a behavior recognition model for prediction, however, this method is only applicable to human-centered video behavior recognition, and such data are commonly found in a published video academic dataset. The video shot by the monitoring camera often contains more information, the covered visual field is larger, and meanwhile, the occurrence position and the human body scale of the target event are random, so that the simple input of the full graph serving as a model is obviously unreasonable, and more irrelevant information in the picture can interfere with behavior recognition, thereby influencing the accuracy of behavior recognition and the recognition accuracy of a behavior executor.
In this regard, the inventors of the present disclosure have studied that it is possible to input a partial area instead of a whole image into a behavior recognition model to classify the behaviors, so that the interference of most of irrelevant information in a picture can be reduced, and the accuracy of behavior recognition is improved, but on this basis, it is also necessary to consider the aspect of how to accurately position a specific behavior executor after the search range of the behavior recognition model is narrowed.
For this reason, the embodiments of the present disclosure provide a behavior recognition method capable of improving recognition accuracy of abnormal behavior recognition and an abnormal target object (behavior executor) associated with the abnormal behavior recognition. Before explaining the embodiments of the present disclosure in further detail, terms and terminology involved in the embodiments of the present disclosure are explained, and the terms and terminology involved in the embodiments of the present disclosure are applicable to the following explanation.
1) CNN (Convolutional Neural Networks), a convolutional neural network, is a deep neural network with a convolutional structure, is essentially an input-to-output mapping, can learn a large number of mapping relationships between inputs and outputs, is trained by a known mode, has mapping capability between input and output pairs, and is commonly used in the field of image recognition.
2) CAM (Class Activation Map), referred to as class activation thermodynamic diagrams, or class activation thermodynamic diagrams for short, is a two-dimensional diagram, essentially a two-dimensional feature score network associated with a particular output class, with each location of the grid representing the degree of importance for that class. For a picture that is input to the CNN model and classified as a "dog," the degree of similarity of each location in the picture to the "dog" class may be presented in a thermodynamic diagram. Class activation maps help to know which part of a picture causes the convolutional neural network to make the final decision.
The following describes exemplary applications of the electronic device provided by the embodiments of the present disclosure, where the electronic device provided by the embodiments of the present disclosure may be implemented as various types of user terminals (hereinafter referred to as terminals) such as AR glasses, notebook computers, tablet computers, desktop computers, set-top boxes, mobile devices (e.g., mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable game devices), and the like, and may also be implemented as servers.
In the following, an exemplary application when the electronic device is implemented as a terminal will be described. Fig. 1 is a schematic flow chart of an alternative behavior recognition method provided in an embodiment of the present disclosure, and will be described with reference to the steps shown in fig. 1.
S101, classifying and identifying important areas of each image frame in at least one image frame of the obtained image frame sequence to obtain an identification result corresponding to the at least one image frame, wherein the important areas are determined according to the detection frame area where the target object in the at least one image frame is located.
The electronic device may input the important areas of each image frame in the at least one image frame of the image frame sequence into the behavior recognition model at the same time to perform classification recognition to obtain a recognition result corresponding to the at least one image frame under the condition that the important areas of each image frame in the at least one image frame are obtained, and the important areas of each image frame are determined according to the detection frame areas where all the target objects in the at least one image frame are located, for example, the electronic device may input the important areas of each image frame in the 8 image frames of each obtained image frame sequence into the behavior recognition model at the same time to perform classification recognition to obtain a recognition result corresponding to the 8 image frames.
Here, the electronic device may crop out important areas of each of the at least one image frame, and classify and identify the cropped important areas.
In the embodiment of the disclosure, the detection frames are used to mark the positions of target objects in the image frame, where each target object corresponds to one detection frame, for example, there are two detection frames corresponding to two target objects one to one in fig. 3 described below.
In some embodiments, the electronic device may obtain the at least one image frame and the important region of each image frame in the image frame sequence directly from the other device, so as to perform classification identification according to the important region of each image frame in the at least one image frame, thereby obtaining an identification result corresponding to the at least one image frame.
In the embodiment of the disclosure, the behavior recognition model is a pre-trained neural network model, such as Two-Stream model, 3D (3-dimensional) ConvNets model, 2D (2-dimensional) ConvNets model, and the like, which is not limited by the embodiment of the disclosure. The electronic device can determine whether abnormal events such as frame play, alarming, traffic accidents and the like exist in the at least one image frame by classifying and identifying important areas of each image frame in the at least one image frame.
In some embodiments, the image frame sequence may be a video stream acquired by an acquisition device such as a camera disposed in a specific scene, where the at least one image frame may be a continuous frame in the video stream, and the specific scene may be a street, a mall, a scenic spot, or the like, which is not limited by the embodiments of the present disclosure.
S102, under the condition that the identification result represents that a preset abnormal event exists, determining an activation center of a class activation diagram corresponding to the identification result of each image frame to obtain at least one activation center of at least one image frame, wherein one activation center represents an abnormal position in the class activation diagram of the corresponding image frame.
When the electronic device recognizes that a preset abnormal event exists in the at least one image frame (namely, a category of the preset abnormal event is recognized), an activation center of a class activation image corresponding to each image frame in the at least one image frame can be determined, so that at least one activation center corresponding to the at least one image frame is obtained, wherein the class activation image is a class activation image related to the category corresponding to the recognition result, and an activation center characterizes an abnormal position in the class activation image of the corresponding one image frame. For example, as shown in fig. 2, in the case where the preset abnormal event of the framing is identified according to 8 consecutive image frames of y1, y2, y3, y4, y5, y6, y7 and y8, the areas with the greatest information provided for the class of the preset abnormal event identified by the model in the respective image frames may be generated, where the areas r1, r2, r3, r4, r5, r6, r7 and r8 are respectively represented by the areas r1, r2, r3, r8 in the class activation diagrams w1, w2, w3, w4, w5, w6, w7 and w8, and the areas r1 in the class activation diagrams w1 represent the areas with the greatest information provided for the class of the preset abnormal event identified by the model in the image frames y 1; and, the activation centers of the 8 class activation maps, such as j1, j2, j3, j4, j5, j6, j7 and j8 in fig. 2, are also determined (since the sizes of the 8 class activation maps are consistent with the sizes of the 8 corresponding image frames, the activation centers of the class activation maps are directly marked in the corresponding image frames in fig. 2, and as shown in fig. 2, the activation centers are marked with pentagonal shapes).
In the embodiment of the present disclosure, the preset abnormal event may be, for example, a frame, a crowd alarm, a traffic accident, etc., which is not limited in the embodiment of the present disclosure.
S103, identifying abnormal target objects of the image frames based on at least one activation center.
In the embodiment of the disclosure, in the case that the activation center of each image frame in the at least one image frame is determined, for each image frame, the electronic device may determine whether an abnormal target object exists in the image frame according to the activation center of the image frame, and identify the existing abnormal target object if the abnormal target object exists.
In some embodiments, since each activation center corresponds to an image frame, for each activation center, the electronic device may determine a location of the activation center in the corresponding one of the image frames, and if the location is located in any one of the detection frame areas in the image frames, determine a target object corresponding to the any one of the detection frame areas as an abnormal target object in the image frame, so that for the at least one activation center, an abnormal target object of each of the at least one image frames corresponding to the at least one activation center may be obtained. For example, as shown in fig. 3, for the image frame a, in the case where the activation center 31 is located at two different human body detection frames 32 and 33, it may be determined that two pedestrians corresponding to the human body detection frames 32 and 33 are abnormal target objects in the image frame a.
Here, for each activation center, in the case where the position of the activation center in the corresponding one of the image frames does not belong to any of the detection frame areas in the image frame, it may be determined that there is no abnormal target object in the image frame.
In the embodiment of the disclosure, the important areas of the determined image frames are classified and identified, so that compared with the identification of the data according to the whole image of each image frame, the search range of each image frame during identification is effectively reduced, and meanwhile, the identification accuracy is improved, on the other hand, the abnormal center (activation center) of each image frame is positioned by determining the abnormal position of the class activation image corresponding to the identification result of each image frame, the abnormal target object in the corresponding image frame is identified according to the obtained abnormal center, and the class activation image corresponding to the identification result can characterize the target object related to the identification result in the image frame, so that the abnormal target object of each image frame identified later can be more accurate, the identification accuracy of the abnormal target object is improved, and meanwhile, the search range of the model is reduced during identification without influencing the identification of the subsequent abnormal target object.
Fig. 4 is a schematic flow chart of an alternative behavior recognition method according to an embodiment of the present disclosure, as shown in fig. 4, S102 may be implemented through S1021-S1023, which will be described with reference to fig. 4.
S1021, under the condition that the identification result represents that a preset abnormal event exists, determining a group of activation values corresponding to the identification result of each image frame, wherein the group of activation values are used for generating a class activation diagram of the image frame, and each pixel position in the class activation diagram corresponds to one activation value in the group of activation values one by one.
When the electronic device recognizes that a preset abnormal event exists in at least one image frame through the behavior recognition model, for each image frame, the electronic device can determine a group of activation values corresponding to the preset abnormal event of the image frame through a class activation mapping method, wherein the group of activation values are used for drawing a class activation image corresponding to the preset abnormal event of the image frame, each pixel position in the class activation image corresponds to one pixel position in the group of activation values one by one, and in the process of drawing the class activation image of the image frame according to the group of activation values, for example, when one activation value represents that the color of one pixel point corresponding to the activation value is red, red is generated at the pixel position corresponding to the activation value, and the class activation image corresponding to the group of activation values is drawn through the method, namely, the contribution of different pixel points to the recognition result is represented by different dark colors in the class activation image.
In the embodiment of the disclosure, the size of the class activation image of the image frame drawn according to the set of activation values is consistent with the size of the image frame, so that the abnormal target object in the original image frame can be accurately positioned according to the abnormal position in the class activation image of the image frame.
In some embodiments, fig. 5 is a schematic flow chart of an alternative behavior recognition method provided in the embodiments of the present disclosure, as shown in fig. 5, S1021 may be implemented through S201-S203, which will be described in connection with fig. 5.
S201, generating a group of initial class activation mapping values corresponding to the identification result for each image frame.
For each image frame, the electronic device may generate a set of initial class activation map values for the image frame corresponding to the recognition result if the recognition result for the image frame is obtained.
In some embodiments, the step S201 may be implemented by generating, for each image frame, a set of initial class activation mapping values corresponding to a recognition result based on weights of classification layers corresponding to the recognition result and feature maps output by convolution layers in a behavior recognition model, where the recognition result is obtained by classifying and recognizing an important area by using the behavior recognition model, and the behavior recognition model includes the classification layers and the convolution layers. In some embodiments, the electronic device may employ a behavior recognition model including a classification layer and a plurality of convolution layers to classify and identify a significant region of each of the at least one image frame to identify an event category of a preset anomaly event. For each image frame, the last convolution layer in the behavior recognition model can generate a y Zhang Tezheng diagram of an important area of the image frame, each feature diagram mainly extracts features related to one of y categories, for example, y feature diagrams can be expressed as a 1,A2,…,Ay, y neurons are correspondingly included in the classification layer, one neuron corresponds to one category, each neuron corresponds to y weight values, for example, w 1,w2,…,wy, and in the case that the event category of the preset abnormal event is c categories, a set of initial category activation mapping values corresponding to the image frame can be calculated by the following formula (1):
wherein i represents the ith neuron, A weight value of class c corresponding to the ith neuron is represented, a i represents a feature map corresponding to the ith neuron,An initial set of class activation value map values is characterized.
S202, up-sampling the initial class activation mapping value to obtain a group of intermediate activation values, wherein the group of intermediate activation values are used for generating a class activation diagram corresponding to an important area of the image frame.
S203, fusing the intermediate activation value with the original pixel value of the image frame to obtain a group of activation values.
Here, for an image frame, the class activation map that can be drawn by the obtained set of initial class activation mapping values is consistent with the size of the feature map generated by the last convolution layer, so the electronic device may perform an upsampling operation on the set of initial class activation mapping values to generate a set of intermediate activation values, and the size of the class activation map that can be drawn by the generated set of intermediate activation values is consistent with the size of the important area of the image frame, so as to obtain a class activation map corresponding to the important area of the image frame; on the basis, the electronic equipment can further perform fusion processing on the group of intermediate activation values and a group of original pixel values of the image frame to obtain a group of activation values corresponding to the image frame, and the size of a class activation image which can be drawn by the obtained group of activation values is consistent with the size of an original image of the image frame, so that superposition of the original image of the image frame and the class activation image corresponding to an important area of the image frame is realized, and finally, the class activation image which corresponds to the image frame and is consistent with the size of the image frame is obtained. For example, fig. 6 shows 8 class activation graphs w10, w20, w30, w40, w50, w60, w70 and w80, which are generated in a one-to-one correspondence with 8 consecutive image frames of y10, y20, y30, y40, y50, y60, y70 and y80 and correspond to the racking event, in the case that the racking event is identified according to 8 consecutive image frames of y10, y20, y30, y50, y60, y70 and y80 (not shown in fig. 6), wherein the corresponding areas r10, r20, r30, r40, r50, r60, r70 and r80 are marked, and the area r10 in the class activation graph w10 represents the area of the respective image frames that provides the most information when the model identifies the class of the preset abnormal event, for example, the area r10 in the class activation graph w10 represents the most information provided for the identified model of the racking event in the image frame y 10.
Explanation of S1022 to S1023 in FIG. 4 is continued as follows:
s1022, determining the maximum activation value in a group of activation values of each image frame, and determining the pixel position corresponding to the maximum activation value as the abnormal position.
For each image frame, the electronic device may determine a maximum activation value of a set of activation values corresponding to the image frame and determine a pixel location corresponding to the maximum activation value as an outlier location for the image frame. Since the class activation map is a two-dimensional image, the anomaly location (pixel location) may be represented using two-dimensional coordinates, e.g., X (i, j), to characterize the location of the anomaly location in the class activation map or in the image frame.
S1023, obtaining an activation center of the image frame based on the abnormal position of the image frame, and correspondingly obtaining at least one activation center for at least one image frame.
For each image frame, the electronic device may determine an abnormal position in the class activation map of the image frame as an activation center of the class activation map of the image frame, so that for the at least one image frame, at least one activation center may be correspondingly obtained.
Fig. 7A is a schematic flow chart of an alternative behavior recognition method according to an embodiment of the present disclosure, as shown in fig. 7A, S103 may be implemented through S1031-S1032, and will be described with reference to fig. 7A by taking fig. 1 as an example.
S1031, determining a target activation center according to at least one activation center.
Because the positions of the activation centers in different types of activation graphs may be offset, the electronic device can determine a target activation center according to the obtained activation centers under the condition that all the activation centers corresponding to at least one image frame are determined, so that the drift phenomenon of the activation centers can be relieved, the abnormal target object of each image frame in the at least one image frame determined by the target activation center is more accurate, and the recognition accuracy of the abnormal target object is improved.
In some embodiments, the electronic device may calculate an average value of all activation centers corresponding to the at least one image frame, and take the average value as the target activation center. Here, since each activation center is actually a two-dimensional coordinate of one pixel point, the electronic device may obtain the target activation center by calculating a coordinate average value of these two-dimensional coordinates, for example, an average value of x coordinates and an average value of y coordinates may be calculated, respectively.
S1032, identifying abnormal target objects in each image frame according to the target activation center.
The electronic device may determine, for each image frame, whether an abnormal target object exists in the image frame according to the target activation center when determining that one target activation center corresponding to the at least one image frame, and identify, when determining that the abnormal target object exists, the existing abnormal target object.
Here, for each image frame, the electronic device may determine a position of the target activation center in the image frame, and if the position is located in any detection frame region in the image frame, determine a target object corresponding to the any detection frame region as an abnormal target object in the image frame, so that for the at least one image frame, an abnormal target object of each image frame in the at least one image frame may be obtained. For example, 32 and 33 in fig. 3 described above are abnormal target objects in the image frame a.
Fig. 7B is a schematic flow chart of an alternative behavior recognition method according to an embodiment of the present disclosure, as shown in fig. 7B, S103 may also be implemented through S1033-S1034, and fig. 1 will be taken as an example, and description will be made with reference to fig. 7B.
S1033, clustering at least one activation center in an unsupervised clustering mode to obtain a target activation center.
S1034, identifying abnormal target objects in each image frame according to the target activation center.
Under the condition that at least one activation center corresponding to at least one image frame one by one is determined, the electronic equipment can determine a target activation center according to the at least one activation center in an unsupervised clustering mode, and can relieve the drift phenomenon of the activation center, so that the abnormal target object of each image frame in the at least one image frame determined by the target activation center in the follow-up process is more accurate, and the recognition accuracy of the abnormal target object is improved.
In some embodiments, the electronic device may use a K-Means clustering method to cluster all activation centers corresponding to the at least one image frame, so that drift points can be removed by Means of unsupervised clustering, so that an abnormal target object of each image frame in the at least one image frame determined by using the target activation center later is more accurate, and the recognition accuracy of the abnormal target object is improved.
Here, the unsupervised clustering method may be other clustering methods, which is not specifically limited in the embodiment of the present disclosure.
In some embodiments, S1031 described above may also be implemented by S1033 described above.
In some embodiments, S1033 described above may be implemented by S301-S302:
s301, clustering at least one activation center in an unsupervised clustering mode to obtain a center cluster with the largest number of the activation centers.
The electronic device may cluster all the active centers corresponding to the at least one image frame in an unsupervised clustering manner, so as to obtain a plurality of clusters (clusters), where each cluster includes at least one active center, and then, a cluster with the largest number of active centers included in the plurality of clusters may be selected from the plurality of clusters, so as to obtain a center cluster.
S302, determining an average value of the activation centers contained in the center cluster, and determining the average value as a target activation center.
Under the condition that the central cluster is determined, the electronic equipment can calculate the average value of all the activation centers contained in the central cluster, and takes the average value as a target activation center. Similarly, since each activation center is actually a two-dimensional coordinate of one pixel, the electronic device may obtain the target activation center by calculating a coordinate average value of these two-dimensional coordinates, for example, obtain the target activation center X (i, j). FIG. 8 shows that in the case where the presence of the preset abnormal event of the framing is identified according to 8 consecutive image frames of y11, y22, y33, y44, y55, y66, y77 and y88, the areas corresponding to the 8 consecutive image frames of y11, y22, y33, y44, y55, y66, y77 and y88 are generated, one by one, and the 8 class activation images w11, w22, w33, w44, w55, w66, w77 and w88 corresponding to the framing event are generated, wherein the class activation images w11, w22, w33, w44, w55, w66, w77 and w88 are marked in correspondence with the areas r11, r22, r33, r44, r55, r66, r77 and r88, and represent the areas of the respective image frames that are most informative when the model identifies the class of the preset abnormal event, for example, the areas r11 in the class activation image w11 represent the areas of the image frames that the j type of the frame is most informative when the model is identified, and the areas of j in the class activation images w11, and the areas of the classes of j11, and the areas of the center 8, such as the areas of the center 8, w11, w33, w55, w66, w77 and w88 are marked in correspondence with the areas of the class activation images w11, w33, w55, w66, w77 and w 88.
In some embodiments, for at least one image frame in S101 described above, and the important areas of each image frame in the at least one image, the electronic device may also obtain itself by some method, such as the method shown in fig. 9. Fig. 9 is a schematic flowchart of an alternative behavior recognition method according to an embodiment of the present disclosure, as shown in fig. 9, S001-S003 may be further performed before S101, and will be described with reference to fig. 9 by taking fig. 1 as an example.
S001, carrying out target detection on the current image frame of the image frame sequence, and determining at least one detection frame area corresponding to at least one existing target object.
The electronic device may obtain a video stream of a specific scene acquired in real time from an acquisition device such as a camera provided in the specific scene, and perform real-time target detection on the video stream acquired in real time by using an image frame as a unit, in the target detection process, the electronic device may use a pre-trained target detection network for the current image frame to detect whether a target object exists in the current image frame, and in the case that the target object exists, mark all the target objects in the current image frame with a detection frame, so as to obtain detection frame areas corresponding to all the target objects in the current image frame, for example, two detection frame areas 32 and 33 corresponding to two target objects one by one exist in the image frame a in fig. 3.
In the embodiment of the present disclosure, the target detection network may be a CNN network, or may be another network, or the like, which is not limited in the embodiment of the present disclosure.
For an image frame, there may or may not be a target object, and the present disclosure is described with respect to the case where there is a target object in the image frame.
S002, determining a center detection frame area in at least one detection frame area.
S003, when at least one image frame is detected, determining important areas of each image frame in the at least one image frame based on at least one central detection frame area corresponding to the at least one image frame.
For each image frame, the electronic device may determine one detection frame area as a central detection frame area from among all detection frame areas in the image frame, so that when the electronic device obtains at least one image frame, at least one central detection frame area may be correspondingly obtained, and the important area of each image frame in the at least one image frame may be determined according to the at least one central detection frame area.
In the embodiment of the disclosure, the electronic device may determine that at least one image frame has been detected if it is determined that the preset condition is satisfied. The electronic device may determine that the preset condition is met when the detected duration reaches the preset duration, and obtain detected image frames when the detected duration reaches the preset duration, where the preset duration may be set according to actual needs, for example, the preset duration may be 6 seconds, then the electronic device may use the detected image frames in every 6 seconds as detected image frames, that is, the electronic device may determine the important areas of each image frame in the at least one image frame every 6 seconds, and the electronic device may further determine that the preset condition is met when the number of detected image frames reaches the preset number, and obtain detected image frames, where the preset number may be set according to actual needs, for example, when the preset number is 8, the electronic device detects 8 image frames each time, that is, determines the 8 image frames as detected image frames, that is, each time the electronic device detects 8 image frames, and determines the important areas of each image frame in the 8 image frames.
In some embodiments, fig. 10 is a schematic flow chart of an alternative behavior recognition method provided in the embodiments of the present disclosure, as shown in fig. 10, S002 may be implemented through S401-S404, which will be described with reference to fig. 10.
S401, expanding at least one detection frame area by a first preset proportion to obtain at least one first area corresponding to the at least one detection frame area.
For all detection frame regions in each image frame, the electronic device may expand the areas of all detection frame regions by a first preset ratio to obtain first regions corresponding to all detection frame regions, e.g., in case that N detection frame regions exist in each image frame, the electronic device may expand the areas of the N detection frame regions by a first preset ratio to obtain N first regions, where N is an integer greater than 0. The enlarging the area of one detection frame region by the first preset ratio means enlarging the range included in the detection frame region by the first preset ratio, thereby obtaining a first region having a larger included range.
In the embodiment of the present disclosure, the first preset ratio may be set according to actual needs, for example, the first preset ratio may be 1.5, which is not limited in the embodiment of the present disclosure.
S402, determining a matching result between any two first areas based on the area intersection ratio between any two first areas in at least one first area, wherein the matching result represents whether any two first areas are matched.
For the first areas corresponding to all the detection frame areas in each image frame, the electronic device can calculate the area intersection ratio between any two first areas, and determine whether the any two first areas are matched according to the size relation between the obtained area intersection ratio and a preset threshold value. For example, in the case where one image frame corresponds to 3 first areas (first area 1, first area 2, and first area 3), the electronic device may calculate an area intersection ratio between first area 1 and first area 2, an area intersection ratio between first area 1 and first area 3, and an area intersection ratio between first area 2 and first area 3, and determine that there is no match between first area 1 and first area 2 in the case where the area intersection ratio between first area 1 and first area 2 is smaller than a preset threshold, and determine that first area 1 is matched with first area 3 in the case where the area intersection ratio between first area 1 and first area 3 is greater than or equal to a preset threshold, and determine that first area 2 is matched with first area 3 in the case where the area intersection ratio between first area 2 and first area 3 is greater than or equal to a preset threshold.
In the embodiment of the present disclosure, the preset threshold may be set according to actual needs, for example, may be 0, which is not limited to the embodiment of the present disclosure.
S403, based on the matching result, determining the matching times of each first area, and determining the first area with the largest matching times.
For each image frame, under the condition that the matching results among all the first areas of the image frame are determined, the electronic device can determine the number of other first areas matched with each first area according to the matching results, take the number as the matching times, and perform descending order or ascending order arrangement on the matching times of all the first areas, and determine one or more first areas with the largest matching times according to the ordering results. Continuing with the above example, since it is determined that the first region 1 and the first region 2 are not matched by the area overlap ratio, the first region 1 is matched with the first region 3, and the first region 2 is matched with the first region 3, it can be determined that the other first regions to which the first region 1 is matched are the first region 3, the other first regions to which the first region 2 is matched are the first region 3, and the other first regions to which the first region 3 is matched are the first region 1 and the first region 2, and thus it is possible to obtain that the number of times of matching of the first region 1 is 1, the number of times of matching of the first region 2 is 1, the number of times of matching of the first region 3 is 2, and the first region 3 is the first region with the largest number of times of matching.
S404, determining a dense center according to the first area with the largest matching times, and determining a detection frame area corresponding to the dense center as a center detection frame area.
For each image frame, when the electronic device obtains the first area with the largest matching frequency of the image frame, the dense center of the image frame can be determined according to the first area with the largest matching frequency, and the detection frame area corresponding to the dense center is determined as the center detection frame area of the image frame. For example, in the case where the detection frame region corresponding to the dense center is 33 as an example in fig. 3, the detection frame region may be 33 as the center detection frame region of the image frame a.
In some embodiments, the determining the dense center according to the first region with the largest matching number in S404 may be implemented by determining the first region with the largest matching number as the dense center when there is one first region with the largest matching number, and determining the first region with the largest area among the two or more first regions with the largest matching number as the dense center when there are two or more first regions with the largest matching number, so that the accuracy of the obtained dense center may be improved.
In some embodiments, fig. 11 is a schematic flow chart of an alternative behavior recognition method provided in the embodiments of the present disclosure, as shown in fig. 11, S003 may be implemented through S501-S503, which will be described in connection with fig. 11.
S501, expanding at least one central detection frame area corresponding to at least one image frame by a second preset proportion to obtain at least one second area corresponding to at least one detection frame area when at least one image frame is detected.
For all detection frame regions of each of the at least one image frame, the electronic device may expand the areas of all detection frame regions by a second set proportion to obtain second regions corresponding to all detection frame regions, e.g., in case that N detection frame regions are present in each image frame, the electronic device may expand the areas of the N detection frame regions by a second preset proportion to obtain N second regions, where N is an integer greater than 0. The enlarging the area of one detection frame region by the second preset ratio means enlarging the range included in the detection frame region by the second preset ratio, thereby obtaining a second region having a larger included range.
In the embodiment of the present disclosure, the second preset ratio may be set according to actual needs, for example, the second preset ratio may be 2, which is not limited in the embodiment of the present disclosure.
S502, determining the position of the summarized region according to the position of each second region in at least one second region in the affiliated image frame.
In some embodiments, for all the obtained second areas corresponding to the at least one image frame, the electronic device may determine, according to the position information of each second area in the corresponding image frame, one summarized area position corresponding to all the second areas corresponding to the at least one image frame, and make the area corresponding to the summarized area position include any one of the second areas corresponding to the at least one image frame.
Here, the summarized region position may be a region coordinate, and for all the second regions corresponding to the at least one image frame, the summarized region position may be a union of the region coordinates of all the second regions corresponding to the at least one image frame, for example, may be a minimum union. For example, when 2 second regions corresponding to 2 image frames are obtained, and the region coordinates of the first second region m11 in the 1 st image frame are (x 11, y 11), (x 12, y 12), the region coordinates of the second region m12 in the 2 nd image frame are (x 21, y 21), (x 22, y 22), and the minimum coordinate union of the region coordinates of x11< x12< x21< x22, y21< y22< y11< y12 is (x 11, y 21), (x 22, y 12), wherein the minimum coordinate union is the region corresponding to the 1 st image frame and includes the first second region m11, and the minimum coordinate union is the region corresponding to the 2 nd image frame and includes the second region m12. For example, fig. 12 shows an area 111 corresponding to the minimum coordinate union between the second area m11 (x 11, y 11) (x 12, y 12) in the 1 st image frame and the second area m12 in the 2 nd image frame, where the area 111 includes an area 112 corresponding to the area coordinate (x 11, y 11) (x 12, y 12), and an area 113 corresponding to the area coordinate (x 21, y 21), (x 22, y 22).
S503, for each image frame, determining the corresponding region of the summarized region position in the image frame as the important region of the image frame, wherein the important region of each image frame comprises the second region corresponding to the image frame.
In the case that one summarized region position corresponding to all the regions of interest of the at least one image frame is obtained, for each image frame in the at least one image frame, the electronic device may determine a region of the summarized region position in the image frame, and take the determined region as an important region of the image frame, where the important region of the image frame includes a second region of the image frame.
The disclosure further provides a behavior recognition device, and fig. 13 is a schematic structural diagram of the behavior recognition device provided by the embodiment of the disclosure, as shown in fig. 13, the behavior recognition device 1 comprises a recognition unit 11, a recognition unit 11 and a determination unit 12, wherein the recognition unit is used for classifying and recognizing important areas of each image frame in at least one image frame of an obtained image frame sequence to obtain a recognition result corresponding to the at least one image frame, the important areas are determined according to a detection frame area where a target object in the at least one image frame is located, the determination unit 12 is used for determining an activation center of a class activation diagram corresponding to the recognition result of each image frame to obtain at least one activation center of the at least one image frame when the recognition result represents a preset abnormal event, and the recognition unit 11 is also used for recognizing the abnormal target object of the each image frame based on the at least one activation center.
In some embodiments of the present disclosure, the determining unit 12 is further configured to determine a set of activation values of each image frame corresponding to the identification result, where the set of activation values is used to generate a class activation map of each image frame, and each pixel position in the class activation map corresponds to one activation value in the set of activation values one by one, determine a largest activation value in the set of activation values of each image frame, and determine a pixel position corresponding to the largest activation value as the abnormal position, and obtain an activation center of each image frame based on the abnormal position of each image frame, and for the at least one image frame, the at least one activation center is obtained correspondingly.
In some embodiments of the present disclosure, the identifying unit 11 is further configured to determine a position of each activation center in a corresponding one of the image frames, and determine, when the position is located in any one of the detection frame areas in the image frames, a target object corresponding to the any one of the detection frame areas as an abnormal target object in the image frames, and for the at least one activation center, obtain the abnormal target object of each of the image frames correspondingly.
In some embodiments of the present disclosure, the identifying unit 11 is further configured to determine a target activation center according to the at least one activation center, and identify an abnormal target object in each image frame according to the target activation center.
In some embodiments of the present disclosure, the identifying unit 11 is further configured to cluster the at least one activation center by using an unsupervised clustering manner to obtain a target activation center, and identify an abnormal target object in each image frame according to the target activation center.
In some embodiments of the present disclosure, the identifying unit 11 is further configured to cluster the at least one activation center by using an unsupervised clustering manner, to obtain a center cluster with the largest number of activation centers, determine an average value of activation centers included in the center cluster, and determine the average value as the target activation center.
In some embodiments of the present disclosure, the determining unit 12 is further configured to generate a set of initial class activation mapping values of each image frame corresponding to the identification result, perform upsampling processing on the initial class activation mapping values to obtain a set of intermediate activation values, where the set of intermediate activation values is used to generate a class activation map corresponding to an important area of each image frame, and perform fusion processing on the set of intermediate activation values and original pixel values of each image frame to obtain the set of activation values.
In some embodiments of the present disclosure, the behavior recognition apparatus 1 further includes a detection unit 13, where the detection unit 13 is configured to perform, before the recognition result corresponding to at least one image frame is obtained by classifying and recognizing an important area of each image frame in the at least one image frame of the obtained image frame sequence, object detection on a current image frame in the image frame sequence, and determine at least one detection frame area corresponding to at least one object that exists, the determination unit 12 is further configured to determine a center detection frame area in the at least one detection frame area, and determine, in a case where the at least one image frame has been detected, the important area of each image frame in the at least one image frame based on the at least one center detection frame area corresponding to the at least one image frame.
In some embodiments of the present disclosure, the determining unit 12 is further configured to enlarge the at least one detection frame area by a first preset ratio to obtain at least one first area corresponding to the at least one detection frame area, determine a matching result between any two first areas based on an area intersection ratio between the any two first areas in the at least one first area, where the matching result indicates whether the any two first areas are matched, determine a matching number of each first area based on the matching result, and determine a first area with a largest matching number, determine a dense center according to the first area with the largest matching number, and determine a detection frame area corresponding to the dense center as the center detection frame area.
In some embodiments of the present disclosure, the determining unit 12 is further configured to enlarge at least one central detection frame area corresponding to the at least one image frame by a second preset proportion, obtain at least one second area corresponding to the at least one detection frame area, determine a summarized area position according to a position of each second area in the at least one second area in the image frame to which the at least one second area belongs, determine, for each image frame, an area corresponding to the summarized area position in the each image frame as the important area of the each image frame, where the important area of the each image frame includes the second area corresponding to the each image frame.
In some embodiments of the present disclosure, the determining unit 12 is further configured to determine, when there is one first area with the largest matching number, the first area with the largest matching number as the dense center, and determine, when there are two or more first areas with the largest matching number, the first area with the largest area among the two or more first areas with the largest matching number as the dense center.
The embodiment of the present disclosure further provides an electronic device, and fig. 14 is a schematic structural diagram of the electronic device provided by the embodiment of the present disclosure, as shown in fig. 14, where the electronic device 2 includes a memory 21 and a processor 22, and the memory 21 and the processor 22 are connected through a bus 23, the memory 21 is configured to store an executable computer program, and the processor 22 is configured to implement a method provided by the embodiment of the present disclosure when executing the executable computer program stored in the memory 21, for example, a behavior recognition method provided by the embodiment of the present disclosure.
The disclosed embodiments provide a computer readable storage medium storing a computer program for, when executed by a processor 22, implementing a method provided by the disclosed embodiments, for example, a behavior recognition method provided by the disclosed embodiments.
In some embodiments of the present disclosure, the storage medium may be FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM, or various devices including one or any combination of the above.
In some embodiments of the present disclosure, a computer program may be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and it may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment, in the form of software, software modules, scripts, or code.
As an example, a computer program may, but need not, correspond to a file in a file system, may be stored as part of a file that holds other programs or data, e.g., in one or more scripts in a hypertext markup language (HTML, hyper Text Markup Language) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
As an example, a computer program may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
In summary, by adopting the technical implementation scheme, on one hand, because the important areas of the determined image frames are classified and identified, compared with the identification according to the data enhancement of the whole image of each image frame, the search range during identification is effectively reduced, and meanwhile, the interference during identification is reduced, so that the identification accuracy is improved; on the other hand, the abnormal center (activation center) of each image frame is positioned by determining the abnormal position in the class activation diagram corresponding to the identification result of each image frame, the abnormal target object in the corresponding image frame is identified according to the obtained abnormal center, and the class activation diagram corresponding to the identification result can characterize the target object related to the identification result in the image frame, so that the identified abnormal target object of each image frame is more accurate, and the identification accuracy of the abnormal target object is improved.
The foregoing is merely exemplary embodiments of the present disclosure and is not intended to limit the scope of the present disclosure. Any modifications, equivalent substitutions, improvements, etc. that are within the spirit and scope of the present disclosure are intended to be included within the scope of the present disclosure.