[0022] In order to describe the technical content, structural features, achieved goals and effects of the present invention in detail, the following will be described in detail in conjunction with the embodiments and accompanying drawings.
[0023] see figure 1 , a kind of video surveillance method that the present invention provides is characterized in that, comprises the following steps:
[0024] S100: Collect a video stream that needs to be analyzed currently; specifically, the video stream includes a network video stream provided by a hard disk video recorder, a video stream provided by a video capture card, and a file video stream.
[0025] S200: Detect whether there is a moving target in the video stream, analyze the image information of the collected video stream, if there is a moving target, perform adaptive background modeling, initially obtain the foreground, perform morphological processing on the foreground, and fill the target area And reduce the small fragment area in the image, use the HSV space shadow detection method to remove the shadow of the target to obtain the final target area; if it does not exist, loop detection;
[0026] S300: Use particle filter or Kalman filter to track the moving target;
[0027] S400: Analyze the shape information and motion characteristics of the tracked moving target, analyze the abnormal situation by using the dispersion and area information, classify the moving target, and complete the identification, processing and analysis of abnormal behavior;
[0028] S500: Identify, process and analyze data according to abnormal behavior, and initiate an emergency alarm when there is an abnormal situation in the video stream.
[0029] In step S200, in principle, any background modeling method can be used for the frame of the text. Here, an adaptive background modeling method is used, and the mean value of the previous n frames of images is used as the background B, and the image data of the Kth frame is set as I K , the corresponding background image is B K. The background update is:
[0030] Bk+1=a*Ik+(1-a)*Bk
[0031] The detection module obtains the foreground data Fk based on the following formula:
[0032] Fk+1=|Ik-Bk|>T
[0033] The threshold T can be acquired adaptively. Specifically, the self-adaptation refers to: 1. automatic update of the background; 2. no need to use background frame samples as input for model training. Calculate the difference image Dk=|Ik-Ik-1| of the two frames of images. The size of the image divides the differential image into several sub-regions, and the size of each sub-region is m*m (0
[0034]
[0035] Wherein F(k-1)i is the foreground data detected in frame k-1 corresponding to the Dki sub-block. When there are relatively many foreground pixels in F(k-1)i, it is judged as foreground, and vice versa.
[0036] The final threshold T is:
[0037] T = 1 M Σ i = 1 M T i
[0038]In step S200, in order to obtain a complete moving target area and reduce false scenes, the morphological method is used to post-process the foreground Fk extracted by background modeling. Let the size of the structural element S be s*s (0
[0039]
[0040] in, for corrosion operations; for expansion operations.
[0041] When performing shadow removal, the HSV space shadow detection method is used. The basic principle is that the hue of the same object (background or foreground) in the shadow area and the non-shadow area is approximately the same. The shadow mainly changes the brightness in the area, and the shadow The part must be lower in brightness than the background.
[0042] Convert the current frame image Ik and background image Bk to HSV space. The hue H and brightness V of the region corresponding to the initially detected foreground Fk' are extracted.
[0043]
[0044] Among them, F" k Identify images for the final detected moving objects. FALSE represents background information, and TRUE represents foreground information. H(B k (F' k )) represents the chromaticity information of the sub-region of the background image Bk corresponding to the foreground in the HVS space. t1 and t2 are threshold parameters, and the values are 0
[0045] In step S300, when tracking the moving target, it is judged whether blocking occurs, specifically, the following methods are included:
[0046] Judging whether there is an intersection between a foreground area in the Kth frame and the predicted position of more than one moving target in the K-1th frame, if there is an intersection, it is judged that there is a blockage, and a particle filter method based on color features is used; if not If it is judged that there is no blockage, the connected area matching method based on Kalman filter is used. First, the Kalman filter is used to predict the state of the moving target in the Kth frame, and then the predicted state and the foreground connected area detected in the Kth frame are calculated. The best match is obtained, and the best match obtained is the state of the moving target in the Kth frame, and the parameters of the Kalman filter are corrected accordingly. Specifically, when a new target is detected, the Kalman filter is used to track the target immediately, and the Kalman filter is used to predict the state of the moving target in the Kth frame, and match and correlate with the moving target detection result of the Kth frame to Obtain the real state of the moving target in the Kth frame, and correct the parameters of the Kalman filter according to the real state. When multiple predicted moving target positions are associated with the detected foreground connected areas, it is considered that the target occlusion has occurred. At this time, respectively, in Particle sampling is performed at the position predicted by the Kalman filter in frame K-1, and the algorithm is switched to particle filter tracking. During the particle filter tracking process, when the position predicted by the particle filter is associated with multiple detected target sub-regions, Then it is considered that the occluded targets are separated again, and at this time, Kalman filter tracking will be performed on the targets respectively.
[0047] In step S400, the moving objects are classified. Specifically, the moving objects are divided into: people, vehicles and chaotic disturbances. The classification principle is based on the dispersion and area information of the moving objects. Specifically, people are displayed as long on the image. The bar is shaped and occupies a relatively small area, and the car is approximately square. When multiple targets are relatively concentrated, it is considered a chaotic disturbance. Calculate the area Os of the target, that is, the number of pixels occupied by the target, and make a preliminary judgment on the target according to the criterion Os>th1 (300 th1, it is considered that the detected target is a car, otherwise, the target is further judged by combining the target area Os and the perimeter Oc. When (Oc)2/Os>th2 (0.2
[0048] Suppose there are N targets (N>1), the center of gravity of the i-th target is Oi, and the center of gravity of the foreground is Calculate the dispersion Od of the target according to the center of gravity:
[0049] Od = 1 N Σ i = 1 N | | O i - O ‾ | |
[0050] When Od
[0051] The abnormal situation analysis specifically includes: identifying the configuration of the monitoring environment and the configuration of the abnormal behavior category. The configuration of the monitoring environment includes: the position, direction, length and size of the warning line, and the retrograde direction angle of the moving target; the abnormal behavior category includes : Crossing the warning line, entering the warning area, retrograde, staying, wandering, abnormal speed and abnormal density. The seven abnormal behaviors are divided into three categories according to the required target information: a) Abnormal behaviors identified based on moving target classification information, including density abnormalities; b) Abnormal behaviors identified based on moving target tracking information, including entering warning areas and crossing Warning line; c) Abnormal behaviors identified based on the joint information of moving object classification and moving object tracking, including retrograde, lingering, wandering, and abnormal speed.
[0052] (1) Abnormal density: when the content of the moving target is chaotic disturbance, it is considered that there is an abnormal density;
[0053] (2) Crossing the warning line and entering the warning area: when the video stream is collected, the location, direction and length information of the warning line is collected, and the center of gravity of the tracking target is calculated according to the tracked target, the warning line is converted into a line segment equation, and the target When the center of gravity of is transferred from one side of the line segment equation to the other (the warning line is regarded as a judgment surface with constraints), it is considered that there is an abnormality. Transform the four sides of the warning area (here only considering the regular area) into four straight line equations, and judge whether the center of gravity of the target is in the warning area according to the four straight line equations.
[0054] (3) Retrograde: Retrograde mainly means that the driving direction of the car is opposite to the specified direction. The data analysis of the retrograde direction has been completed when the video stream is collected. According to the data analysis of the classification of moving objects, it is judged that the moving object is not a car. , then stop anomaly detection, estimate the trajectory of the moving object based on the tracking of the moving object, use a straight line to fit the trajectory of the moving object, and calculate the slope angle θ' of the line, when the specified direction angle θ and the inclination angle θ' of the line meet the following conditions , it is considered retrograde.
[0055] mod(θ-θ′+360, 360)
[0056] Where mod() is the modulo operation, tθ is the threshold, and the value range is 0 <30
[0057] (4) wandering
[0058] Wandering mainly refers to the reciprocating motion of a person. When classifying moving objects, it is judged whether the object is a person. Track the center of gravity of the human target when tracking the moving target. Consider image data of M (M>100) frames. Let the center of gravity of the target in the kth frame be Ok, and it will be judged as wandering when the following conditions are met:
[0059] | Σ i = 1 M ( O k + i - O k ) | t p
[0060] Among them, O k+i -O k is a vector, and tp is a threshold that determines the length of wandering.
[0061] (5) Abnormal speed
[0062] Speed abnormality is to detect whether the car is speeding. Determine whether the target is a car by motion classification. When the relative position of the car between two frames is large, it is considered that the speed is abnormal (the car is considered to be moving in a straight line here). The choice of threshold is determined by scene constraints.
[0063] In step S500, it is possible to carry out various linked alarm modes such as sound and light, and short message to perform an alarm, and to receive the alarm mode that is considered to be set and related additional information.
[0064] refer to figure 2 , the technical solution also provides a video surveillance system, specifically including:
[0065] The collection module is used to collect the video stream that needs to be analyzed currently, and complete the capture of the intelligent surveillance video stream. This module enables it to support network video stream capture by developing and encapsulating the network video hard disk video recorder; the system captures video streams by developing and encapsulating the API functions provided by the video capture card, so that it can support the camera for video stream capture; through Different video files develop corresponding video capture modules, so that it can support file video stream capture. The video stream input in the acquisition module can be video information in any format. Specifically, the acquisition module can be a camera, video camera, micro camera and other equipment. The acquisition module extracts image data from the incoming video stream, and converts the image data Pass in the image data queue to provide the detection image for the detection module.
[0066] The detection module is used to detect whether there is a moving target in the video stream. If there is a moving target, perform adaptive background modeling, initially obtain the foreground, perform morphological processing on the foreground, fill the target area and reduce the small fragmented area in the image. The HSV space shadow detection method removes the shadow of the target to obtain the final target area; obtains the moving target through background modeling detection, preprocessing and shadow removal
[0067] Tracking module, using particle filter or Kalman filter two tracking methods to track moving targets;
[0068] The analysis module is used to analyze the shape information and motion characteristics of the tracked moving target, analyze the abnormal situation by using the dispersion and area information, classify the moving target, and complete the identification, processing and analysis of abnormal behavior; the classification of the moving target is mainly to classify the moving target Disturb for people, cars and chaos. Then, according to the characteristics of the moving target such as speed and area, information such as the trajectory of the moving target obtained by the tracking module, abnormal behavior categories, and configuration information of video signal scenes are used to identify abnormal behaviors. When there is an abnormal behavior in the video stream, the alarm information is sent to the alarm module, thereby driving the alarm module to alarm.
[0069] The alarm module can identify, process and analyze data according to abnormal behavior, and initiate an emergency alarm when there is an abnormal situation in the video stream. The alarm module develops the driver program of the underlying alarm device, specifically, including the SMS modem driver, the alarm light signal driver, the sound card driver, etc., and receives the set alarm mode and related additional information, such as: mobile phone number, alarm sound Etc. After receiving the abnormal event of the video intelligent analysis module, the corresponding driver program is mobilized to alarm. In addition, the alarm module can save each alarm information, which is convenient for alarm query.
[0070] The above is only an embodiment of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technologies fields, all of which are equally included in the scope of patent protection of the present invention.