Violence detection method and system based on hybrid strategy, and storage medium

By adopting a hybrid strategy in violent behavior detection and using a deep neural network model combined with the average optical flow threshold to process different types of videos, the problem of insufficient generalization ability in the existing technology is solved, and the accuracy and coverage of detection are improved, making The system is feasible in a real environment.

CN111860286BInactive Publication Date: 2024-09-24ABACUS INFO SHENZHEN
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010685116.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-14
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing violent behavior detection methods have weak generalization capabilities in real environments and cannot effectively cover diverse and complex violent behavior scenarios, resulting in low detection accuracy and coverage.

Method used

Using a method based on a hybrid strategy, by obtaining the trained first deep neural network model and the second deep neural network model, they are used to identify the intensity of motion and videos containing only human body features respectively, combined with the average optical flow threshold for detection, using Different models process different optical flow videos to improve detection accuracy.

Benefits of technology

It achieves more comprehensive coverage of violent behavior scenarios, improves detection accuracy and generalization capabilities, and enables the system to be effectively applied in real environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000
    Figure 00000000_0000
Patent Text Reader

Abstract

The present invention discloses a method and system for detecting violent behavior based on a hybrid strategy, and a computer-readable storage medium. The method includes the following steps: obtaining a trained first deep neural network model and a second deep neural network model; extracting all video frames of the surveillance video within the prediction interval and calculating the average optical flow of all video frames; when the average optical flow is greater than or equal to the optical flow threshold, using the trained first deep neural network model to detect violent behavior; when the average optical flow is less than the optical flow threshold, using the trained second deep neural network model to detect violent behavior. The present invention solves the problem of weak generalization ability existing in traditional technologies, realizes coverage of more comprehensive violent behavior scenarios, thereby improving the accuracy and generalization ability of violent behavior detection, and achieving the effect of enabling it to be applied in real environments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of computer software application, and in particular to a hybrid strategy-based violent behavior detection method and system, and a computer-readable storage medium. Background Art

[0002] Violence is an act that targets personal injury and property, uses violent means, causes great damage to the victim's physical and mental health and the safety of life and property, and directly endangers people's life, health and freedom. The occurrence of violent behavior will cause property losses and casualties to society, and is an important factor affecting social stability. Therefore, early detection and evidence collection of violent behavior are of great significance. At present, various regions mainly use the method of installing video surveillance in public places and detecting violent behavior manually or by machine to detect and curb violent behavior. Among them, compared with the manual detection method, the machine-based violence detection method can achieve 7×24 hours of uninterrupted detection, improve the detection coverage, effectively prevent the occurrence of missed detection, and save a lot of labor costs.

[0003] At present, the methods related to violent behavior detection mainly include: (1) simple motion detection methods, such as speed detection, acceleration detection, and optical flow method; (2) traditional machine learning methods, such as support vector machine (SVM), nearest neighbor algorithm (KNN), and Adaboost algorithm; (3) detection methods based on deep learning, such as convolutional neural networks (CNN) and long short-term memory network (LSTM). The motion detection method detects violent behavior by judging the motion state of the object (such as speed, acceleration, and direction). This method is based on two assumptions: (1) violent behavior has the characteristics of motion; (2) the motion state of violent behavior can be distinguished from the motion state of other behaviors. However, in some situations, the above assumptions do not hold, resulting in missed detection or false alarms. For example, in a fight on the spot, the motion characteristics of this behavior may not be significant, making assumption (1) invalid. Traditional machine learning methods require manual feature engineering. However, violent behavior scenarios are relatively diverse and complex, and the lack of scientific and systematic feature construction, feature extraction, and feature selection standards has resulted in a large bottleneck in traditional machine learning methods. Models based on deep learning rely on large amounts of data. However, there are currently few known public datasets on violent behavior, which is an important factor hindering the application of deep learning models in violent behavior detection. In addition, the data composition of the currently known public datasets on violent behavior is relatively simple, and the amount of data is small, which makes the trained deep learning models have limited generalization capabilities and are only applicable to a few simple scenarios. In summary, current violent behavior detection methods perform well in specific scenarios, but are always limited by weak generalization capabilities and cannot be used in real environments. This is a problem that needs to be urgently addressed in the field of violent behavior detection. Summary of the invention

[0004] The embodiments of the present application provide a hybrid strategy-based violent behavior detection method and system, and a computer-readable storage medium, which solve the problem of weak generalization ability in traditional technologies, achieve coverage of more comprehensive violent behavior scenarios, thereby improving the accuracy and generalization ability of violent behavior detection, and achieving the effect of enabling it to be applied in real environments.

[0005] The embodiment of the present application provides a method for detecting violent behavior based on a hybrid strategy, the method comprising the following steps:

[0006] Obtaining a trained first deep neural network model and a second deep neural network model; wherein the first deep neural network model is used to identify videos with a motion intensity reaching a preset value; and the second deep neural network model is used to identify videos containing only human features;

[0007] Extract all video frames of the surveillance video within the prediction interval and calculate the average optical flow of all the video frames;

[0008] When the average optical flow is greater than or equal to the optical flow threshold, using the trained first deep neural network model to perform violent behavior detection;

[0009] When the average optical flow is less than the optical flow threshold, the trained second deep neural network model is used to perform violent behavior detection.

[0010] In one embodiment, the step of obtaining the trained first deep neural network model specifically includes:

[0011] Obtain a video frame dataset for a first deep neural network model;

[0012] Performing standardization processing on the video frame data in the video frame data set to obtain a standardized video frame data set;

[0013] Performing difference processing between adjacent video frames on the standardized video frame data set to obtain a difference video frame data set;

[0014] The first deep neural network model is trained, verified and tested using a training set, a validation set and a test set divided from the difference video frame data set, respectively, to obtain a trained first deep neural network model.

[0015] In one embodiment, the step of obtaining a video frame dataset for a first deep neural network model specifically includes:

[0016] Videos that meet set conditions are obtained, and video frames are extracted from each of the videos to obtain a video frame dataset of a first deep neural network model.

[0017] In one embodiment, the step of obtaining the trained second deep neural network model specifically includes:

[0018] Obtaining a video frame dataset containing only human features for a second deep neural network model;

[0019] Performing standardization processing on the video frame data in the video frame data set to obtain a standardized video frame data set;

[0020] The second deep neural network model is trained, verified and tested using a training set, a validation set and a test set divided from the standardized video frame data set, respectively, to obtain a trained second deep neural network model.

[0021] In one embodiment, the step of obtaining a video frame dataset containing only human features for the second deep neural network model specifically includes:

[0022] Obtain videos that meet set conditions, and extract video frames from each of the videos to obtain a video frame dataset of a second deep neural network model;

[0023] A human body in the video frame is identified, and a channel value of pixels in other non-human areas on each channel is set to 0.

[0024] In one embodiment, the step of performing standardization processing on the video frame data in the video frame data set to obtain a standardized video frame data set specifically includes:

[0025] Using a five-dimensional array to store the channel value of each pixel in the video frame data set on each channel to obtain a five-dimensional array for training; wherein the dimensions of the five-dimensional array for training respectively represent the video number, the video frame number, the pixel horizontal coordinate, the pixel vertical coordinate, and the channel number;

[0026] Mapping the channel values ​​stored in the training five-dimensional array to floating point numbers between 0 and 1;

[0027] Calculate the mean and standard deviation of the channel values ​​of the training five-dimensional array on each channel respectively;

[0028] In the five-dimensional array for training, the channel values ​​on each channel are respectively standardized by standard deviation to obtain a standardized five-dimensional array for training, which is used as a standardized video frame data set.

[0029] In one embodiment, the step of using the trained first deep neural network model to detect violent behavior specifically includes:

[0030] Extracting a video frame from all the video frames, and using a five-dimensional array to store the channel value of each pixel in the video frame on each channel, to obtain a five-dimensional array for detection; wherein the dimensions of the five-dimensional array for detection respectively represent the video number, the video frame number, the pixel horizontal coordinate, the pixel vertical coordinate, and the channel number;

[0031] Mapping the channel values ​​stored in the five-dimensional array for detection into floating point numbers between 0 and 1;

[0032] In the five-dimensional array for detection, standardizing the channel values ​​on each channel by standard deviation respectively, to obtain a standardized five-dimensional array for detection;

[0033] Performing difference processing between adjacent video frames in the standardized five-dimensional array for detection to obtain a five-dimensional array of difference values ​​for detection;

[0034] The detection difference five-dimensional array is input into the trained first deep neural network model to perform violent behavior detection.

[0035] In one embodiment, the step of using the trained second deep neural network model to detect violent behavior specifically includes:

[0036] Extracting a video frame from all the video frames, and using a five-dimensional array to store the channel value of each pixel in the video frame on each channel, to obtain a five-dimensional array for detection; wherein the dimensions of the five-dimensional array for detection respectively represent the video number, the video frame number, the pixel horizontal coordinate, the pixel vertical coordinate, and the channel number;

[0037] Identify a human body in the video frame, and set the channel value of pixels in other non-human areas on each channel to 0;

[0038] Mapping the channel values ​​stored in the five-dimensional array for detection into floating point numbers between 0 and 1;

[0039] In the five-dimensional array for detection, standardizing the channel values ​​on each channel by standard deviation respectively, to obtain a standardized five-dimensional array for detection;

[0040] The detection standardized five-dimensional array is input into the trained second deep neural network model to perform violent behavior detection.

[0041] An embodiment of the present application also provides a violent behavior detection system, which includes a processor, a memory, and a violent behavior detection program stored in the memory and executable on the processor. When the violent behavior detection program is executed by the processor, the steps of the hybrid strategy-based violent behavior detection method are implemented.

[0042] The embodiment of the present application further provides a computer-readable storage medium, on which a violent behavior detection program is stored. When the violent behavior detection program is executed by a processor, the steps of the violent behavior detection method based on the hybrid strategy as described above are implemented.

[0043] The technical solution of a hybrid strategy-based violent behavior detection method and system, and a computer-readable storage medium provided in the embodiments of the present application has at least the following technical effects:

[0044] The invention adopts a technical method of obtaining a first deep neural network model and a second deep neural network model that have been trained; wherein the first deep neural network model is used to identify videos with a preset intensity of motion; the second deep neural network model is used to identify videos that only contain human features; extracting all video frames of the surveillance video within the prediction interval and calculating the average optical flow of all video frames; when the average optical flow is greater than or equal to the optical flow threshold, using the trained first deep neural network model to detect violent behavior; when the average optical flow is less than the optical flow threshold, using the trained second deep neural network model to detect violent behavior. By using different trained deep neural network models to detect violent behavior for videos with different optical flows, the problem of weak generalization ability existing in traditional technologies is effectively solved, and more comprehensive coverage of violent behavior scenes is achieved, thereby improving the accuracy and generalization ability of violent behavior detection, and achieving the effect of enabling it to be applied in real environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 A schematic diagram of the structure of a violent behavior detection system according to an embodiment of the present application;

[0046] Figure 2 This is a flow chart of a first embodiment of a violent behavior detection method based on a hybrid strategy of the present application;

[0047] Figure 3 A schematic diagram of the structure of a first deep neural network model involved in an embodiment of the present application;

[0048] Figure 4 Schematic diagram of the structure of the Mask-R-CNN model involved in the embodiment of the present application;

[0049] Figure 5 A schematic diagram of the structure of a second deep neural network model involved in an embodiment of the present application;

[0050] Figure 6 This is a flow chart of a second embodiment of the violent behavior detection method based on a hybrid strategy of the present application;

[0051] Figure 7 This is a flow chart of the third embodiment of the violent behavior detection method based on the hybrid strategy of the present application. DETAILED DESCRIPTION

[0052] In order to solve the problem of weak generalization ability in traditional technologies, the present application adopts a technical solution of obtaining a first deep neural network model and a second deep neural network model that have been trained; wherein the first deep neural network model is used to identify videos with a motion intensity reaching a preset value; the second deep neural network model is used to identify videos that only contain human features; all video frames of the surveillance video within the prediction interval are extracted and the average optical flow of all video frames is calculated; when the average optical flow is greater than or equal to the optical flow threshold, the trained first deep neural network model is used to detect violent behavior; when the average optical flow is less than the optical flow threshold, the trained second deep neural network model is used to detect violent behavior. By using different trained deep neural network models to detect violent behavior for videos with different optical flows, more comprehensive coverage of violent behavior scenes is achieved, thereby improving the accuracy and generalization ability of violent behavior detection, and achieving the effect of enabling it to be applied in real environments.

[0053] In order to better understand the above technical solution, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0054] Combination Figure 1 As shown, it is a hardware structure diagram of the violent behavior detection system involved in each embodiment of the present application. The violent behavior detection system may include: a processor 101, a memory 102, a camera 103 and other components. Those skilled in the art can understand that Figure 1 The hardware structure of the violent behavior detection system shown does not constitute a limitation on the violent behavior detection system. The violent behavior detection system may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.

[0055] Combine the following Figure 1 The following is a detailed introduction to the various components of the violent behavior detection system:

[0056] The processor 101 is the control center of the violent behavior detection system, connecting the various parts of the entire violent behavior detection system, and performing various functions of the violent behavior detection system or processing data by running or executing programs stored in the memory 102 and calling data stored in the memory 102, thereby monitoring the violent behavior detection system as a whole. In addition, the processor 101 includes at least a graphics processor GPU, which is used to train and load deep neural network models and detect violent behavior in videos.

[0057] The memory 102 can be used to store various programs and various data in the violent behavior detection system. The memory 102 mainly includes a program storage area and a data storage area, wherein the program storage area at least stores the programs required for violent behavior detection; the data storage area can store various data of the violent behavior detection system. In addition, the memory 102 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0058] The camera 103 can be used to obtain surveillance video for violent behavior detection. In the violent behavior detection system, one or more cameras can be included. Among them, the multiple cameras can be of the same model or different models. In addition, one processor in the processor 101 can correspond to multiple cameras.

[0059] According to the above technical solution, this embodiment adopts a technical solution of obtaining a first deep neural network model and a second deep neural network model that have been trained; wherein the first deep neural network model is used to identify videos with a motion intensity reaching a preset value; the second deep neural network model is used to identify videos that only contain human features; all video frames of the surveillance video within the prediction interval are extracted and the average optical flow of all video frames is calculated; when the average optical flow is greater than or equal to the optical flow threshold, the trained first deep neural network model is used to detect violent behavior; when the average optical flow is less than the optical flow threshold, the trained second deep neural network model is used to detect violent behavior. By using different trained deep neural network models to detect violent behavior for videos with different optical flows, the problem of weak generalization ability existing in traditional technologies is effectively solved, and more comprehensive coverage of violent behavior scenes is achieved, thereby improving the accuracy and generalization ability of violent behavior detection, and achieving the effect of enabling it to be applied in real environments.

[0060] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0061] Combination Figure 2 As shown, in the first embodiment of the present application, the hybrid strategy-based violent behavior detection method of the present application specifically includes the following steps:

[0062] Step S110, obtaining a trained first deep neural network model and a trained second deep neural network model.

[0063] In this embodiment, the first deep neural network model is used to identify videos with a preset intensity of motion, that is, to detect violent behavior in videos with a preset intensity of motion. The first deep neural network model may have different structures as needed. For example, in one embodiment, the first deep neural network model may be as follows: Figure 3 The ResNet (residual network) shown has the following characteristics: its input is a new video frame sequence after a group of continuous video frames are subtracted from each other, and the sequence only retains the motion information between adjacent video frames; it can include five convolution blocks, and these five convolution blocks can respectively include 1, 9, 12, 69, and 9 convolution layers, wherein the second convolution block can also include a pooling layer; the first deep neural network model can also include a Bi-LSTM block, and the Bi-LSTM block is composed of two unidirectional LSTM networks, and the two unidirectional LSTM networks are in opposite directions; the first deep neural network model can include a pooling layer and four fully connected layers in the overall structure. After the first deep neural network model is trained, it can be used to detect violent behavior in videos with a preset intensity of motion.

[0064] The second deep neural network model is used to identify videos containing only human features, that is, to detect violent behavior in videos containing only human features. The second deep neural network model can have different structures as needed. For example, in one embodiment, the second deep neural network model can be as follows: Figure 5 The ResNet shown in the figure has the following characteristics: its input is a set of continuous video frames, which can be firstly obtained by Figure 4The Mask-R-CNN model shown identifies the area where the human body is located in the video frame (where class, box and mask are three representation methods, FPN (Feature Pyramid Network) is a method of using a conventional CNN model to efficiently extract features of various dimensions in a picture, RPN (Region Proposal Network) is a method of extracting candidate regions, and ROI (Region of Interest) Align is a method of regional feature aggregation), and then keeps the channel value of the pixels in the human body area in the video frame unchanged on each channel, and sets the channel value of the pixels in other non-human areas on each channel to 0; it can also include five convolution blocks, and these five convolution blocks can respectively include 1, 9, 12, 69, and 9 convolution layers, wherein the second convolution block can also include a pooling layer; the second deep neural network model can also include a Bi-LSTM block, and the Bi-LSTM block is composed of two unidirectional LSTM networks, and the two unidirectional LSTM networks are in opposite directions; the second deep neural network model can include a pooling layer and four fully connected layers in the overall structure. After the second deep neural network model is trained, it can be used to detect violent behavior in videos that only contain human features.

[0065] Step S120: extract all video frames of the surveillance video within the prediction interval and calculate the average optical flow of all the video frames.

[0066] In this embodiment, the extraction of all video frames of the surveillance video within the prediction interval can be the extraction of all video frames within the prediction interval in the surveillance video obtained in real time through the surveillance camera, or the extraction of all video frames within the prediction interval in the recorded surveillance video. The former can monitor violent behavior in real time, while the latter can detect violent behavior in surveillance videos that are not detected in real time. The prediction interval is a pre-set interval for detecting violent behavior.

[0067] The optical flow refers to the speed of the brightness pattern in the video, which reflects the intensity of the movement of the object in the video. By calculating the average optical flow of all video frames in a video, the intensity of the movement of the object in the video can be obtained, so that different deep neural network models can be selected according to the intensity of the object's movement to detect violence in the video, thereby improving the generalization ability of violence detection.

[0068] Step S130: When the average optical flow is greater than or equal to the optical flow threshold, use the trained first deep neural network model to perform violent behavior detection.

[0069] In this embodiment, the fact that the average optical flow is greater than or equal to the optical flow threshold means that the intensity of the movement of the object in the video has reached a preset value, so the trained first deep neural network model can be used to perform violent behavior detection on all video frames extracted from the video. However, since the original video frame data cannot meet the input conditions of the first deep neural network model, the video frame data needs to be processed before using the trained first deep neural network model to perform violent behavior detection on the video frame data. In one embodiment, the processing may include: extracting video frames, converting video frames into video frame data in array form, and performing standard deviation standardization on the video frame data. After performing violent behavior detection, the results of the violent behavior detection may be displayed.

[0070] Step S140: When the average optical flow is less than the optical flow threshold, use the trained second deep neural network model to perform violent behavior detection.

[0071] In this embodiment, the fact that the average optical flow is less than the optical flow threshold means that the intensity of the movement of the object in the video has not reached the preset value. Therefore, the trained first deep neural network model cannot be used to detect violent behavior on all video frames extracted from the video. It is necessary to use the trained second deep neural network model to detect violent behavior after extracting human features from all video frames of the video. However, since the original video frame data cannot meet the input conditions of the second deep neural network model, the video frame data needs to be processed before using the trained second deep neural network model to detect violent behavior on the video frame data. In one embodiment, the processing may include: extracting video frames, converting video frames into video frame data in array form, processing non-human area features, and performing standard deviation standardization on video frame data. After performing violent behavior detection, the results of violent behavior detection can be displayed.

[0072] The above method uses different trained deep neural network models to detect violent behavior in videos with different optical flows, which effectively solves the problem of weak generalization ability existing in traditional technologies and achieves coverage of more comprehensive violent behavior scenes, thereby improving the accuracy and generalization ability of violent behavior detection and achieving the effect of enabling it to be applied in real environments.

[0073] like Figure 6 As shown, in combination with the above embodiment, a method for obtaining a trained first deep neural network model is provided, comprising the following steps:

[0074] Step S211, obtaining a video frame dataset for a first deep neural network model.

[0075] In this embodiment, to obtain a trained deep neural network model, it is necessary to first obtain a data set for training, verifying and testing the deep neural network model. Since the first deep neural network model is a deep neural network model for detecting violent behavior in a video, it is necessary to first obtain a video frame data set related to violent behavior for the first deep neural network model. In one embodiment, obtaining a video frame data set for the first deep neural network model may include the following steps.

[0076] Step a: obtain videos that meet set conditions, and extract video frames from each of the videos to obtain a video frame dataset of a first deep neural network model.

[0077] The video used to obtain the video frame data set for training the first deep neural network model needs to be consistent in terms of format, etc., so that each data input into the first deep neural network model is consistent in terms of specifications, quantity, etc. Therefore, it is necessary to require the video to meet the set conditions, and the set conditions may include: having the same resolution and a set value, having the same video duration and a set value, having the same and specific video format, and having the same and specific naming rules. The set value of the resolution is determined by the resolution of the video that needs to be detected for violent behavior; the set value of the video duration is a predetermined value and it determines the time interval for detecting violent behavior; the specific video format can be MP4 format or AVI format, and other formats can be selected if necessary; the specific naming rule can be a naming rule named with "videofora" plus a number, or other feasible naming rules. It is worth noting that since the first deep neural network model is used to identify videos with a preset intensity of motion, it is also necessary to pre-set an optical flow threshold f T , and it is required that the average optical flow of all video frames in the video used to obtain the video frame dataset is greater than or equal to the optical flow threshold.

[0078] After obtaining the videos that meet the set conditions, it is only necessary to extract some video frames from each of the videos by a certain method to obtain information such as image features in the video, without extracting all the video frames. In one embodiment, the method for extracting video frames is to extract some video frames from each video at intervals of length l. A Uniform extraction A After obtaining the video frame, the video frame needs to be saved to a specified path. After extracting the video frame, a video frame data set of the first deep neural network model can be obtained.

[0079] Step S212, performing standardization processing on the video frame data in the video frame data set to obtain a standardized video frame data set.

[0080] In this embodiment, standardizing the video frame data in the video frame data set can effectively shorten the time for training the deep neural network model. After each video frame data in the video frame data set is standardized, a new video frame data set can be obtained, which is called a standardized video frame data set. In one embodiment, standardizing the video frame data in the video frame data set to obtain a standardized video frame data set can include the following four steps.

[0081] Step a: Use a five-dimensional array to store the channel value of each pixel in the video frame data set on each channel to obtain a five-dimensional array for training.

[0082] The deep neural network model cannot process the video frames directly, so it is necessary to convert the video frames into a data type that can be directly processed by the deep neural network model. Here, the video frame data set is converted into a video frame data set in the form of a five-dimensional array. The five dimensions of the five-dimensional array for training respectively represent the video number, video frame number, pixel horizontal coordinate, pixel vertical coordinate, and channel number, which stores the channel value of each pixel of each video frame of each video on each channel. For a video frame data set with M videos, N frames extracted from each video, a resolution of X×Y, and RGB 3 channels, the five-dimensional array is A[M][N][X][Y][3]. For the pixel at the coordinate (x, y) of the nth frame of video m, its channel value A[m][n][x][y][i] on the i-th channel is c i , where m∈{0,1,…,M-1}, n∈{0,1,…,N-1}, x∈{0,1,…,X-1}, y∈{0,1,…,Y-1}, i∈{0,1,2}, c i ∈{0,1,…,255}. After conversion, a five-dimensional array for training can be obtained.

[0083] Step b: Mapping the channel values ​​stored in the training five-dimensional array to floating point numbers between 0 and 1.

[0084] In RGB images, the channel value of each channel is an integer from 0 to 255. We need a method to map the channel values ​​ranging from 0 to 255 to floating-point numbers ranging from 0 to 1, such as dividing all channel values ​​by 255. For videos containing more channels, or combining some channels, or with different channel arrangements, the mapping of the channel values ​​of each channel is similar.

[0085] Step c, respectively calculating the mean value and standard deviation of the channel value of the training five-dimensional array on each channel.

[0086] To standardize the standard deviation of the channel values ​​on each channel, it is necessary to find the mean and standard deviation of the channel values ​​on each channel, that is, divide all the channel values ​​in the five-dimensional array for training according to the channels they belong to, and then calculate their mean and standard deviation respectively, so as to get the mean and standard deviation of the channel values ​​on each channel.

[0087] Step d, performing standard deviation standardization on the channel values ​​on each channel in the five-dimensional array for training, to obtain a standardized five-dimensional array for training, and using it as a standardized video frame data set.

[0088] The mean value and standard deviation of the channel values ​​on each channel obtained in the above steps are used to standardize the standard deviation of all channel values ​​on each channel, that is, for each channel value on each channel, the mean value of the channel to which it belongs is first subtracted and then divided by the standard deviation of the channel to which it belongs. After standardizing the standard deviation of each channel value stored in the training five-dimensional array, a new five-dimensional array can be obtained, which is called the standardized five-dimensional array for training.

[0089] Step S213, performing difference processing between adjacent video frames on the standardized video frame data set to obtain a difference video frame data set.

[0090] In this embodiment, each video frame data in the standardized video frame data set is subjected to difference processing between adjacent video frames, that is, adjacent video frame data are subtracted in each video to obtain new video frame data. Assume that the data on the video frame sequence in the vth video are: f1, f2, ..., f n , then the difference between adjacent video frame data is to make f i =f i+1 -f i , a new video frame sequence with n-1 video frames is obtained, and each video frame data in the new video frame sequence is the difference between the previous adjacent video frame data. The difference processing between adjacent video frames for each video frame data in the standardized video frame data set is to obtain the motion information in the video frame data set. After the difference processing between adjacent video frames is performed on each video frame data in the standardized video frame data set, a new video frame data set can be obtained, which is called the difference video frame data set.

[0091] Step S214: training, verifying and testing the first deep neural network model using the training set, verification set and test set divided from the difference video frame data set to obtain a trained first deep neural network model.

[0092] In this embodiment, in order to obtain a trained first deep neural network model, three data sets are required to train, verify and test the first deep neural network model respectively. Therefore, the difference video frame data set needs to be divided into three data sets according to a certain ratio, which are respectively used as a training set, a verification set and a test set. The ratio adopted here is 6:2:2. According to actual conditions and different needs, the data sets can also be divided according to other ratios. After the first deep neural network model is trained, verified and tested using the training set, verification set and test set, the trained first deep neural network model can be obtained and saved.

[0093] In combination with the above embodiment, a method for obtaining a trained second deep neural network model is provided, comprising the following steps:

[0094] Step S215, obtaining a video frame dataset containing only human features for the second deep neural network model.

[0095] In this embodiment, the video frame dataset containing only human features for the second deep neural network model is obtained because the video frame dataset needs to be used to train, verify and test the second deep neural network model. In one embodiment, obtaining the video frame dataset containing only human features for the second deep neural network model may include the following two steps.

[0096] Step a: obtain videos that meet set conditions, and extract video frames from each of the videos to obtain a video frame dataset for a second deep neural network model.

[0097] The setting conditions that need to be satisfied by the video used to obtain the video frame data set for training the second deep neural network model are basically the same as the setting conditions that need to be satisfied by the video used to obtain the video frame data set for training the first deep neural network model, with the only difference being that the average optical flow of all video frames in the video used to obtain the video frame data set for training the second deep neural network model needs to be less than a pre-given optical flow threshold f T .

[0098] After obtaining the videos that meet the set conditions, it is only necessary to extract some video frames from each of the videos by a certain method to obtain information such as image features in the video, without extracting all the video frames. In one embodiment, the method for extracting video frames is to extract some video frames from each video at intervals of length l. B Uniform extraction B After obtaining the video frame, the video frame needs to be saved to a specified path. After extracting the video frame, a video frame data set of the second deep neural network model can be obtained.

[0099] Step b: identifying the human body in the video frame, and setting the channel value of pixels in other non-human areas on each channel to 0.

[0100] The Mask-R-CNN model or other methods can be used to identify the area where the human body is located in the video frame, and then the channel value of the pixels in the human body area in the video frame on each channel is kept unchanged, and the channel value of the pixels in other non-human areas on each channel is set to 0. This can extract only the human features in the video frame and ignore other non-human features. For videos with an average optical flow less than the optical flow threshold, such processing can make it easier for the second deep neural network model to extract features related to violent behavior in the video.

[0101] Step S216, performing standardization processing on the video frame data in the video frame data set to obtain a standardized video frame data set.

[0102] In this embodiment, standardizing the video frame data in the video frame data set of the second deep neural network model to obtain a standardized video frame data set can also include the following four steps, and the specific operations in the steps are the same as the specific operations of the steps of standardizing the video frame data in the video frame data set of the first deep neural network model.

[0103] Step a: Use a five-dimensional array to store the channel value of each pixel in the video frame data set on each channel to obtain a five-dimensional array for training.

[0104] Step b: Mapping the channel values ​​stored in the training five-dimensional array to floating point numbers between 0 and 1.

[0105] Step c, respectively calculating the mean value and standard deviation of the channel value of the training five-dimensional array on each channel.

[0106] Step d, performing standard deviation standardization on the channel values ​​on each channel in the five-dimensional array for training, to obtain a standardized five-dimensional array for training, and using it as a standardized video frame data set.

[0107] Step S217: Use the training set, verification set and test set divided from the standardized video frame data set to train, verify and test the second deep neural network model respectively to obtain a trained second deep neural network model.

[0108] In this embodiment, in order to obtain a trained second deep neural network model, it is also necessary to use three data sets to train, verify and test the second deep neural network model respectively. Therefore, the difference video frame data set needs to be divided into three data sets according to a certain ratio, respectively as a training set, a verification set and a test set. The ratio used here is 6:2:2. According to actual conditions and different needs, the data sets can also be divided according to other ratios. After using the training set, verification set and test set to train, verify and test the second deep neural network model, the trained second deep neural network model can be obtained and saved.

[0109] It can be understood that there is no requirement for the order of obtaining the trained first deep neural network model and the second deep neural network model. One can be trained first and then the other, or both can be trained at the same time.

[0110] The above embodiment provides a method for obtaining a trained first deep neural network model and a second deep neural network model. Among them, by standardizing the original video frame data set for deep neural network model training, the time consumed for deep neural network model training is effectively shortened; by performing difference processing on the video frame data set for the first deep neural network model training and extracting only human features from the video frame data set for the second deep neural network model training, the deep neural network model can better extract features related to violent behavior in the video data set, thereby improving the accuracy of violent behavior detection.

[0111] like Figure 7 As shown, in combination with the above embodiment, a method for detecting violent behavior using the trained first deep neural network model is provided, comprising the following steps:

[0112] Step S331, extracting a video frame from all the video frames, and using a five-dimensional array to store the channel value of each pixel in the video frame on each channel, to obtain a five-dimensional array for detection.

[0113] In this embodiment, after obtaining all the video frames, it is only necessary to extract some video frames from the entire video frames by a certain method to obtain information such as image features in the entire video frames, without using all the video frames. The method for extracting video frames is a method for extracting video frames from a video used to obtain a video frame dataset for training a first deep neural network model. In one embodiment, the method is to extract a portion of the video frames from the entire video frames at intervals of length l. A Uniform extraction A video frames.

[0114] Since the first deep neural network model cannot directly process the video frame, it is necessary to convert the video frame into a data type that can be directly processed by the deep neural network model. Here, the video frame data is converted into video frame data in the form of a five-dimensional array. The five dimensions of the five-dimensional array used for detection represent the video number, video frame number, pixel horizontal coordinate, pixel vertical coordinate, and channel number, respectively, which stores the channel value of each pixel of each video frame of the video frame on each channel. It is worth noting that there is only one video number in the video number dimension. For the video frame with N video frames, a resolution of X×Y and RGB 3 channels, the five-dimensional array is A[1][N][X][Y][3]. For the pixel at the coordinate (x, y) of the nth frame, its channel value A[1][n][x][y][i] on the i-th channel is c i , where n∈{0,1,…,N-1}, x∈{0,1,…,X-1}, y∈{0,1,…,Y-1}, i∈{0,1,2}, c i ∈{0,1,…,255}. After transformation, a five-dimensional array for detection can be obtained.

[0115] Step S332: Map the channel values ​​stored in the five-dimensional array for detection into floating point numbers between 0 and 1.

[0116] In this embodiment, the channel value of each channel in the RGB image is an integer ranging from 0 to 255, and we need to adopt a method to map the channel values ​​ranging from 0 to 255 to floating point numbers ranging from 0 to 1, such as dividing all channel values ​​by 255. For videos containing more channels, or combining certain channels, or having different channel arrangements, the mapping of the channel value of each channel therein is similar.

[0117] Step S333 , performing standard deviation standardization on the channel values ​​on each channel in the five-dimensional array for detection to obtain a standardized five-dimensional array for detection.

[0118] In this embodiment, the mean value and standard deviation of the channel value on each channel obtained in the step of standardizing the video frame data set of the first deep neural network model are used to standardize all channel values ​​of the five-dimensional array for detection on each channel, that is, for each channel value on each channel, the mean value of the channel to which it belongs is first subtracted and then divided by the standard deviation of the channel to which it belongs. After standardizing the standard deviation of each channel value stored in the five-dimensional array for detection, a new five-dimensional array for detection can be obtained, which is called a standardized five-dimensional array for detection.

[0119] Step S334, performing difference processing between adjacent video frames in the standardized five-dimensional array for detection to obtain a five-dimensional array of differences for detection.

[0120] In this embodiment, the video frame data in the standardized five-dimensional array for detection is subjected to difference processing between adjacent video frames, that is, adjacent video frame data are subtracted to obtain new video frame data. Assume that the data on the video frame sequence are: f1, f2, ..., f n , then the difference between adjacent video frame data is to make f i =f i+1 -f i , a new video frame sequence with n-1 video frames is obtained, and each video frame data in the new video frame sequence is the difference between the previous adjacent video frame data. The difference processing between adjacent video frames of the video frame data in the standardized five-dimensional array for detection is to obtain the motion information of the video frame data. After the difference processing between adjacent video frames is performed on each video frame data in the standardized five-dimensional array for detection, a new five-dimensional array can be obtained, which is called the difference five-dimensional array for detection.

[0121] Step S335: input the detection difference five-dimensional array into the trained first deep neural network model to perform violent behavior detection.

[0122] In combination with the above embodiment, a method for detecting violent behavior using the trained second deep neural network model is provided, comprising the following steps:

[0123] Step S341, extracting a video frame from all the video frames, and using a five-dimensional array to store the channel value of each pixel in the video frame on each channel, to obtain a five-dimensional array for detection.

[0124] In this embodiment, after obtaining all the video frames, it is only necessary to extract some video frames from the entire video frames by a certain method to obtain information such as image features in the entire video frames, without using all the video frames. The method for extracting video frames is a method for extracting video frames from a video used to obtain a video frame dataset for training a second deep neural network model. In one embodiment, the method is to extract a portion of the video frames from the entire video frames at intervals of length l. B Uniform extraction B video frames.

[0125] Since the second deep neural network model cannot directly process the video frames, it is necessary to convert the video frames into data types that can be directly processed by the deep neural network model. Here, the video frame data is also converted into video frame data in the form of a five-dimensional array. The five dimensions of the five-dimensional array for detection respectively represent the video number, video frame number, pixel horizontal coordinate, pixel vertical coordinate, and channel number, which stores the channel value of each pixel of each video frame of the video frame on each channel. It is worth noting that there is also only one video number in the video number dimension. After the conversion, a five-dimensional array for detection can be obtained.

[0126] Step S342, identifying the human body in the video frame, and setting the channel value of pixels in other non-human areas on each channel to 0.

[0127] In this embodiment, the area where the human body is located in the video frame can be identified by the Mask-R-CNN model or other methods, and then the channel value of the pixels in the human body area in the video frame on each channel is kept unchanged, and the channel value of the pixels in other non-human areas on each channel is set to 0. This can have the effect of extracting only the human body features in the video frame and ignoring other non-human features. For videos with an average optical flow less than the optical flow threshold, such processing can make it easier for the second deep neural network model to extract features related to violent behavior in the video.

[0128] Step S343: Map the channel values ​​stored in the five-dimensional array for detection into floating point numbers between 0 and 1.

[0129] In this embodiment, the channel value of each channel in the RGB image is an integer ranging from 0 to 255, and we need to adopt a method to map the channel values ​​ranging from 0 to 255 to floating point numbers ranging from 0 to 1, such as dividing all channel values ​​by 255. For videos containing more channels, or combining certain channels, or having different channel arrangements, the mapping of the channel value of each channel therein is similar.

[0130] Step S344, performing standard deviation standardization on the channel values ​​on each channel in the five-dimensional array for detection, to obtain a standardized five-dimensional array for detection.

[0131] In this embodiment, the mean value and standard deviation of the channel value on each channel obtained in the step of standardizing the video frame data set of the second deep neural network model are used to standardize all channel values ​​of the five-dimensional array for detection on each channel, that is, for each channel value on each channel, the mean value of the channel to which it belongs is first subtracted and then divided by the standard deviation of the channel to which it belongs. After standardizing the standard deviation of each channel value stored in the five-dimensional array for detection, a new five-dimensional array for detection can be obtained, which is called a standardized five-dimensional array for detection.

[0132] Step S345: input the standardized five-dimensional array for detection into the trained second deep neural network model to perform violent behavior detection.

[0133] The above embodiment provides a method for processing video frames when using the trained first or second deep neural network model to detect violent behavior. Among them, by standardizing the original video frame data, the time consumed for violent behavior detection is effectively shortened; by performing difference processing on the video frame data and extracting only human body features from the video frame data, the deep neural network model can better extract features related to violent behavior in the video data set, thereby improving the accuracy of violent behavior detection.

[0134] Based on the same inventive concept, an embodiment of the present application further provides a violent behavior detection system, which includes a training subsystem, a video management subsystem and a violent behavior detection subsystem.

[0135] The training subsystem includes a data set management module, a data standardization module, a model training module, and a model management module. The data set management module is responsible for downloading, storing, loading, format conversion, compressing, and slicing original videos from different sources; the data standardization module standardizes the constructed data set into the data input format required for training the deep neural network model; the model training module inputs the standardized data into the deep neural network for training and generates the corresponding training results; the model management module is responsible for loading and saving the deep neural network model, as well as saving and displaying the training results output by the model training module.

[0136] The video management subsystem includes a camera access module, a camera video frame reading module, a camera video frame preprocessing module, and a camera video frame sending module. The camera access module is used to connect to surveillance cameras, supports simultaneous access to multiple models of cameras, and supports multiple data transmission protocols; the camera video frame reading module reads images from the connected cameras in frame order; the camera video frame preprocessing module reads the image data output by the camera video frame module, and performs preliminary processing (such as scale transformation) on the image according to the requirements of the violent behavior prediction subsystem; the camera video frame sending module sends the output data of the video frame preprocessing module to the violent behavior prediction subsystem for analysis.

[0137] The violent behavior detection subsystem includes a video image processing module, a motion detection module and a violent behavior detection module. The video image processing module is responsible for receiving video frames sent by the video management subsystem and completing the standardization of the video frames; the motion detection module is responsible for detecting whether a group of video frames output by the video image processing module exceeds the optical flow threshold; according to the detection results of the motion detection module, the violent behavior detection module is responsible for initializing the deep neural network model, and inputting the standardized video frames into the deep neural network model for prediction, and then displaying the prediction results.

[0138] Since the violent behavior detection system provided in the embodiment of the present application is a violent behavior detection system used in the method of the embodiment of the present application, based on the method introduced in the embodiment of the present application, the person skilled in the art can understand the specific structure and deformation of the violent behavior detection system, so it is not repeated here. All violent behavior detection systems used in the method of the embodiment of the present application belong to the scope of protection of this application.

[0139] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium, on which a violent behavior detection program is stored. When the violent behavior detection program is executed by a processor, the various processes of the violent behavior detection method embodiment based on the hybrid strategy described above are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0140] Since the computer-readable storage medium provided in the embodiments of the present application is a computer-readable storage medium used to implement the method of the embodiments of the present application, based on the method introduced in the embodiments of the present application, those skilled in the art can understand the specific structure and deformation of the computer-readable storage medium, so it is not repeated here. All computer-readable storage media used in the methods of the embodiments of the present application belong to the scope of protection of this application.

[0141] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0142] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0143] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0144] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0145] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claim. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.

[0146] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0147] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A violent behavior detection method based on a hybrid strategy, characterized in that: The method comprises the following steps: Obtaining a trained first deep neural network model and a second deep neural network model; wherein the first deep neural network model is used to identify videos with a motion intensity reaching a preset value; and the second deep neural network model is used to identify videos containing only human features; Extract all video frames of the surveillance video within the prediction interval and calculate the average optical flow of all the video frames; When the average optical flow is greater than or equal to the optical flow threshold, using the trained first deep neural network model to perform violent behavior detection; When the average optical flow is less than the optical flow threshold, using the trained second deep neural network model to perform violent behavior detection; The step of obtaining the trained first deep neural network model specifically includes: Obtain a video frame dataset for a first deep neural network model; Using a five-dimensional array to store the channel value of each pixel in the video frame data set on each channel to obtain a five-dimensional array for training; wherein the dimensions of the five-dimensional array for training respectively represent the video number, the video frame number, the pixel horizontal coordinate, the pixel vertical coordinate, and the channel number; Mapping the channel values ​​stored in the training five-dimensional array to floating point numbers between 0 and 1; Calculate the mean and standard deviation of the channel values ​​of the training five-dimensional array on each channel respectively; In the five-dimensional array for training, standard deviation of the channel values ​​on each channel is respectively normalized to obtain a standardized five-dimensional array for training, which is used as a standardized video frame data set; Performing difference processing between adjacent video frames on the standardized video frame data set to obtain a difference video frame data set; The first deep neural network model is trained, verified and tested using a training set, a validation set and a test set divided from the difference video frame data set, respectively, to obtain a trained first deep neural network model.

2. The hybrid strategy based violent behavior detection method according to claim 1, characterized in that: The step of obtaining a video frame data set for the first deep neural network model specifically includes: Videos that meet set conditions are obtained, and video frames are extracted from each of the videos to obtain a video frame dataset of a first deep neural network model.

3. The hybrid strategy based violent behavior detection method according to claim 1, characterized in that: The step of obtaining the trained second deep neural network model specifically includes: Obtaining a video frame dataset containing only human features for a second deep neural network model; Performing standardization processing on the video frame data in the video frame data set to obtain a standardized video frame data set; The second deep neural network model is trained, verified and tested using a training set, a validation set and a test set divided from the standardized video frame data set, respectively, to obtain a trained second deep neural network model.

4. The hybrid strategy based violent behavior detection method according to claim 3, characterized in that: The step of obtaining a video frame data set containing only human features for the second deep neural network model specifically includes: Obtain videos that meet set conditions, and extract video frames from each of the videos to obtain a video frame dataset of a second deep neural network model; A human body in the video frame is identified, and a channel value of pixels in other non-human areas on each channel is set to 0.

5. The hybrid strategy based violent behavior detection method according to claim 1, characterized in that: The step of using the trained first deep neural network model to detect violent behavior specifically includes: Extracting a video frame from all the video frames, and using a five-dimensional array to store the channel value of each pixel in the video frame on each channel, to obtain a five-dimensional array for detection; wherein the dimensions of the five-dimensional array for detection respectively represent the video number, the video frame number, the pixel horizontal coordinate, the pixel vertical coordinate, and the channel number; Mapping the channel values ​​stored in the five-dimensional array for detection into floating point numbers between 0 and 1; In the five-dimensional array for detection, standardizing the channel values ​​on each channel by standard deviation respectively, to obtain a standardized five-dimensional array for detection; Performing difference processing between adjacent video frames in the standardized five-dimensional array for detection to obtain a five-dimensional array of difference values ​​for detection; The detection difference five-dimensional array is input into the trained first deep neural network model to perform violent behavior detection.

6. The hybrid strategy based violent behavior detection method according to claim 1, characterized in that: The step of using the trained second deep neural network model to detect violent behavior specifically includes: Extracting a video frame from all the video frames, and using a five-dimensional array to store the channel value of each pixel in the video frame on each channel, to obtain a five-dimensional array for detection; wherein the dimensions of the five-dimensional array for detection respectively represent the video number, the video frame number, the pixel horizontal coordinate, the pixel vertical coordinate, and the channel number; Identify a human body in the video frame, and set the channel value of pixels in other non-human areas on each channel to 0; Mapping the channel values ​​stored in the five-dimensional array for detection into floating point numbers between 0 and 1; In the five-dimensional array for detection, standardizing the channel values ​​on each channel by standard deviation respectively, to obtain a standardized five-dimensional array for detection; The detection standardized five-dimensional array is input into the trained second deep neural network model to perform violent behavior detection.

7. A violent behavior detection system, characterized in that: The violent behavior detection system includes a processor, a memory, and a violent behavior detection program stored in the memory and executable on the processor. When the violent behavior detection program is executed by the processor, the steps of the hybrid strategy-based violent behavior detection method according to any one of claims 1 to 6 are implemented.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a violent behavior detection program, and when the violent behavior detection program is executed by the processor, the steps of the hybrid strategy-based violent behavior detection method according to any one of claims 1 to 6 are implemented.