A method for detecting abnormal events on highways
Through the combination of deep learning and camera internal and external parameters, the extraction and dynamic clustering of vehicle three-dimensional trajectories are realized, which solves the problem of low accuracy of existing two-dimensional trajectory analysis and improves the accuracy and robustness of highway abnormal event detection.
Patent Information
- Application Number
- CN202111456180.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-01
AI Technical Summary
Existing video-based highway abnormal event detection methods mainly rely on two-dimensional trajectory analysis, which is limited by factors such as video shooting angle and vehicle occlusion, making it difficult to accurately extract vehicle trajectory information and affecting detection accuracy.
A method based on deep learning is used, combined with internal and external parameters of the camera and the vehicle model, to convert the vehicle's two-dimensional to three-dimensional coordinates, design a dynamic clustering method, extract the vehicle's trajectory information in the three-dimensional space, and use the Yolov3-5layer model and attention-based The dual-stage hourglass model is used for vehicle detection and key point detection, GIOU and Kalman filtering are used for target tracking, and dynamic clustering is used to identify abnormal behaviors.
It improves the accuracy and robustness of vehicle abnormal event detection, can more accurately identify the vehicle's trajectory and road traffic status in three-dimensional space, reduces the impact of video angles and occlusions, and enhances the reliability of detection.
Smart Images

Figure CN114170580B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of road traffic safety and deep learning technology, and in particular to a method for detecting abnormal events on highways. Background Art
[0002] With the development of my country's economy and the improvement of urbanization, highway construction has entered a period of rapid development. The transportation network formed by highways has become an important basic transportation facility. However, under the background of the continuous increase in urban population and traffic vehicles, the operation and management of highways has become increasingly difficult. Traffic congestion and traffic accidents have become very prominent problems, and the resulting highway safety issues cannot be ignored. Highway safety accidents have not only brought tremendous pressure to traffic safety, but also caused a large amount of property losses and casualties.
[0003] The driver's irregular driving behavior is one of the important reasons for highway traffic accidents. Therefore, timely detection and early warning of abnormal behavior events of highway vehicles are particularly important. The use of advanced technical means to improve the level of highway intelligence, realize the rapid collection and accurate processing of highway information, obtain abnormal behavior events on the road, and deal with them in time can help the road to quickly restore smooth driving and prevent traffic accidents to a certain extent.
[0004] Abnormal event detection is an important topic in the intelligent development of highways. It helps to identify abnormal behaviors of vehicles on highways in a timely manner, issue safety warnings in a timely manner, provide technical support for rapid response to events, and provide detailed information for investigation and evidence collection. Among them, the video-based vehicle abnormal behavior detection method is one of the commonly used detection methods. The video-based vehicle abnormal behavior detection method mainly monitors traffic conditions in real time through cameras installed on both sides of the highway, bridges, tunnels and other locations, obtains abnormal behavior events in the monitoring screen through a certain algorithm, and reports them to management personnel in a timely manner.
[0005] However, most of the current abnormal event detection methods based on video processing directly analyze the two-dimensional coordinates of the vehicle in the video screen to obtain the vehicle's trajectory information, and then judge the vehicle's running status by analyzing the vehicle trajectory. Due to the limitations of video shooting angles, vehicle occlusions, etc., this method is difficult to extract accurate trajectory information, thus affecting the accuracy of event detection. Summary of the invention
[0006] The purpose of the present invention is to propose a highway abnormal event detection method based on three-dimensional vehicle trajectory in view of the shortcomings of the current two-dimensional vehicle trajectory detection, adopt a vehicle detection and vehicle key point detection method based on a deep learning method, design a vehicle two-dimensional-three-dimensional coordinate conversion method combining the information of the camera internal and external parameters and the vehicle model, realize the extraction of the vehicle's three-dimensional space operation trajectory, propose a dynamic clustering method, and use this method to analyze the vehicle's three-dimensional trajectory and road traffic status, thereby realizing the accurate prediction of abnormal vehicle behavior and abnormal road traffic status events in highway monitoring scenarios.
[0007] The technical solution to achieve the purpose of the present invention is: a method for detecting abnormal events on highways, the method comprising the following steps:
[0008] Step 1, read the real-time video stream, decode the video, and obtain the image frame;
[0009] Step 2, preprocessing the image frame, including color space conversion, image scaling, and image normalization;
[0010] Step 3: Load the vehicle detection model, perform reasoning on the preprocessed image, and parse the reasoning results to obtain the vehicle location and category information;
[0011] Step 4: Load the vehicle key point detection model, perform key point detection on each detected vehicle target, and post-process the inference results to obtain the key point position of the vehicle and select the main key points of the vehicle;
[0012] Step 5, according to the detected coordinates of the key points of the vehicle, use the camera internal and external parameter matrix and the vehicle model parameters to calculate the three-dimensional coordinates of the main key points of the vehicle;
[0013] Step 6, calculating the center point of the vehicle in the three-dimensional space according to the calculated three-dimensional coordinates of the main key points of the vehicle;
[0014] Step 7, taking the center point of the three-dimensional coordinates of the main key points of the vehicle as the tracking target, using GIOU as the evaluation index, using the Hungarian algorithm to match the detected target, and using the Kalman filter to track the target;
[0015] Step 8, recording the position and time point of the three-dimensional coordinate center point of the tracking target from appearance to disappearance as the vehicle's driving trajectory;
[0016] Step 9: According to the extracted vehicle driving trajectories, a dynamic clustering algorithm is used to dynamically cluster the vehicle trajectories, and the vehicle trajectory categories are marked, so as to identify abnormal behavior events of the vehicles;
[0017] Step 10, traffic statistics within the time period are counted at fixed time intervals, the statistical state at different times is dynamically clustered, and the traffic state categories are marked to identify different traffic operation states, thereby determining abnormal events in traffic operation.
[0018] Furthermore, the vehicle detection model in step 3 adopts the Yolov3-5layer model, which is based on open source datasets and self-built datasets. The model anchor is calculated using the open source datasets and self-built datasets, and the final weight file is obtained by training on the open source datasets and self-built datasets. The open source datasets include COCO and VOC, and the self-built datasets are obtained by collecting video data in different traffic scenarios and manually annotating them. The detection results of the Yolov3-5layer model include vehicle categories and vehicle locations, and the categories include small vehicles, medium-sized vehicles and large vehicles.
[0019] Furthermore, the vehicle key point detection model in step 4 is a two-stage hourglass model based on an attention mechanism, which introduces an attention mechanism into the hourglass model, and the final weight of the model is trained on a self-built data set; when the self-built data set is established, the left front bottom of the vehicle, the right front bottom, the left front headlight, the right front headlight, the left front window bottom, the right front window bottom, the left front upper corner, the right front upper corner, the left rear upper corner, the right rear upper corner, the left rear light, the right rear light, the left rear bottom, and the right rear bottom of the vehicle are customized and selected and labeled according to the actual shape of the vehicle. 14 sites are used as key points, and 8 sites including the side front bottom, the right front bottom, the left rear bottom, the right rear bottom, the left front upper corner, the right front upper corner, the left rear upper corner, and the right rear upper corner are selected as the main key points.
[0020] Furthermore, in step 4, the vehicle key point detection model is loaded, key point detection is performed on each detected vehicle target, and the inference result is post-processed to obtain the key point position of the vehicle, specifically including:
[0021] Step 4-1, for the output of each stage in the two stages, calculate the maximum value of the pixel points of each channel respectively, and record the coordinate position of the maximum value;
[0022] Step 4-2, for each channel, calculate the distance between the maximum coordinate positions of the two stages corresponding to the channel. If the distance is greater than 5, it is considered that the outputs of the two stages of the channel do not match and the key point corresponding to the channel is not detected; otherwise, it is considered that the key point corresponding to the channel is detected;
[0023] Step 4-3, traverse each channel and repeat step 4-2 until all 14 channels are processed.
[0024] Furthermore, in step 5, the three-dimensional coordinates of the main key points of the vehicle are calculated based on the detected coordinates of the key points of the vehicle using the camera internal and external parameter matrix and the vehicle model parameters. The specific process includes:
[0025] Step 5-1, obtain the camera's intrinsic parameter matrix K, camera rotation matrix R and translation matrix t through camera calibration, where the camera rotation matrix and translation matrix constitute the camera's extrinsic parameter matrix, and K and R are 3×3 real matrices, and t is a 3×1 vector;
[0026] Step 5-2, for each detected main key point, its two-dimensional pixel coordinates on the image are expressed as p = [u, v, 1], where u represents the horizontal coordinate of the point and v represents the vertical coordinate of the point; for the main key point that is not detected, the following steps 5-3 and 5-4 are not performed;
[0027] Step 5-3, calculate the coefficients. When the camera intrinsic parameter matrix and extrinsic parameter matrix are known, estimate the equation coefficients. The formula is:
[0028] [x a ,y a ,z a ] T =R -1 K -1 p
[0029] [x b ,y b ,z b ] T =R -1 t
[0030] s=(z b +z) / z a
[0031] Among them, R -1 represents the inverse matrix of the extrinsic rotation matrix, K -1 represents the inverse matrix of the internal parameter matrix, [x a ,y a ,z a ] T Represents R -1 K -1 The intermediate result vector obtained after p operation, z a Represents the vertical component of the intermediate result vector, x b ,y b ,z b Represents R -1 The intermediate result vector obtained after t operation, z brepresents the vertical component of the intermediate result vector, and z represents the value of the preset key point in the vertical direction; the four points of the left front bottom, the right front bottom, the left rear bottom, and the right rear bottom take z=0; the left front upper corner, the right front upper corner, the left rear upper corner, and the right rear upper corner take z=z model , where z model According to the category of the detection target, z is obtained by looking up the table. For small vehicles, model =1.4m; for medium-sized vehicles, z model =1.85m; for large vehicles, z model =3.3m;
[0032] Step 5-4, calculate the three-dimensional coordinate point x in the real world based on the two-dimensional coordinate point p of the key point, and the calculation formula is:
[0033] x=[XYZ] T =sR -1 K -1 pR -1 t
[0034] Where X, Y, and Z represent the components of the three-dimensional coordinate point in the x, y, and z directions of space, respectively.
[0035] Furthermore, in step 6, the center point of the vehicle in the three-dimensional space is calculated based on the calculated three-dimensional coordinates of the main key points of the vehicle. The specific process includes:
[0036] Step 6-1, calculate the maximum and minimum values of the three-dimensional spatial coordinates of all detected key points in the x, y, and z directions, and obtain x min ,x max ,y min ,y max ,z min ,z max ;
[0037] Step 6-2: For each of the three directions x, y, and z, calculate the mean of the maximum and minimum values in that direction and get x mean ,y mean ,y mean , with X c =(x mean ,y mean ,y mean ) as the center point of the vehicle in three-dimensional space.
[0038] Furthermore, in step 7, the center point of the three-dimensional coordinates of the main key points of the vehicle is used as the tracking target, GIOU is used as the evaluation index, the Hungarian algorithm is used to match the detected target, and the Kalman filter is used to track the target, which specifically includes:
[0039] Step 7-1, assuming that the current frame has M t detection frames, and up to the last frame, it has been determined that M t-1 detection frames, and calculate the error matrix E based on the two sets of detection frames, where E ij =1-GIOU(B t,i ,B t-1,j ), B t,i represents the i-th detection box in the current frame, B t-1,j represents the jth detection box in the existing detection box, and the calculation formula of GIOU is:
[0040]
[0041] In the formula, A∩B represents the intersection area of detection frames A and B, A∪B represents the area of detection frames A and B combined, and C represents the area of the smallest box that can enclose detection frames A and B;
[0042] Step 7-2, using the Hungarian algorithm to calculate the best match between the detection frame of the current frame and the existing detection frame according to the error matrix E, and obtain the corresponding relationship between the two sets of detection frames;
[0043] Step 7-3, for each detection frame in the current frame that matches an existing detection frame, use the Kalman filter to correct the center point position according to the detected corresponding three-dimensional center point position of the vehicle; for the detection frame in the current frame that does not match an existing detection frame, it is considered that the detection frame appears for the first time, and the detection frame is added to the existing detection frame set, and the Kalman filter is initialized using the center point position corresponding to the detection frame; for the existing detection frame that does not match the detected detection frame, it is considered that the detection frame has disappeared, and the detection frame is deleted from the existing detection frame set.
[0044] Furthermore, the dynamic clustering algorithm in step 9 comprises:
[0045] (1) It is known that there are m samples, and each sample belongs to n categories C1, C2, …, C n One of ; For a new sample S, use the selected metric to calculate the distance between the sample and all existing samples to obtain a distance set:
[0046] D={d i = dist(S,S i )|i∈[1,m]}
[0047] (2) Calculate the minimum value d among all distances min =min(D), and record the sample point S that obtains the minimum value min , and the category C to which the sample point belongs opt ;
[0048] (3) Select the threshold T, if d min ≤T, then we assume that S∈C opt , that is, S is classified as category C opt If d min >T, the new sample is considered not to belong to any existing category, and a new category C is created. n+1 , let S∈C n+1 , that is, S is classified as category C n+1 ; If there are K sample points in two categories whose distance is less than the set threshold T, then the two categories are considered to be classified into one category, where K>0;
[0049] (4) Repeat the above steps (1) to (3) until no new samples are added.
[0050] Furthermore, in step 9, according to the extracted vehicle driving trajectory, the vehicle trajectory is dynamically clustered using a dynamic clustering algorithm, and the vehicle trajectory category is marked, so as to identify the abnormal behavior event of the vehicle, which specifically includes:
[0051] Step 9-1, according to the vehicle trajectory record, when a new trajectory is obtained, the Douglas-Peucker method is used to simplify the trajectory and reduce the number of trajectory points to N, where N is 30;
[0052] Step 9-2, using a dynamic clustering method to process vehicle trajectories, wherein the distance measurement method between trajectories is selected as a dynamic time deviation distance DTW method;
[0053] Step 9-3, respectively count the proportion of each type of vehicle trajectory to the total number of trajectories, and sort them in descending order. Then, label and confirm the category of each type of vehicle trajectory and vehicle speed record according to the existing labeling database, so as to obtain the actual event type meaning corresponding to each type of trajectory. Events that do not match the existing labeling database are classified as unknown events.
[0054] Furthermore, in step 10, the traffic statistics within the time period are counted at fixed time intervals, the statistical state at different times is dynamically clustered, and the traffic state categories are marked to identify different traffic operation states, thereby judging abnormal events in traffic operation, specifically including:
[0055] Step 10-1, according to the vehicle trajectory information, at a certain time interval, the traffic statistics within the time period are counted, including the average vehicle speed Vmean , average traffic flow F mean , average time occupancy O mean , average headway H mean , average queue length L mean , and obtain the state vector State=[V mean ,F mean ,O mean ,H mean ,L mean ];
[0056] Step 10-2, clustering the state vectors using the dynamic clustering method, and the selected distance measurement standard between samples is Euclidean distance;
[0057] Step 10-3, annotate and confirm the actual event meaning of each category according to the existing annotation database to obtain the actual event type meaning of each category, and the events that are not matched to the existing annotation database are classified as unknown events.
[0058] Compared with the prior art, the present invention has the following significant advantages:
[0059] 1. The present invention provides a vehicle three-dimensional trajectory extraction method based on deep learning and camera internal and external parameters, which can obtain the vehicle's driving trajectory in a real three-dimensional space. Compared with the traditional two-dimensional driving trajectory, the three-dimensional driving trajectory can provide richer position information, effectively reduce the adverse effects on vehicle behavior judgment caused by vehicle occlusion, camera shooting angle, etc., and improve the accuracy of vehicle abnormal event detection.
[0060] 2. The present invention proposes a method for vehicle target detection using a yolov3-5layer model. The model uses 5 yolo layers to process network features at different resolutions, so that smaller targets can be identified. The identification of small targets is very necessary for high-speed monitoring scenarios with large viewing angles and small targets. The anchor of the model is calculated using a training data set and a self-built data set, and the model weight is obtained by training on the training data set and the self-built data set. The introduction of the self-built data constructed by the present invention enables the generalization performance and robustness of the model target detection to better meet engineering needs.
[0061] 3. The present invention provides a novel method for detecting vehicle key points using an attention-based two-stage hourglass model. The method adds a spatial attention mechanism to each residual block to improve the attention to the key point positions of the model. Each stage in the model uses an hourglass-shaped network structure to provide a heat map prediction with the same resolution as the original input, and the outputs of both stages are supervised during training. Each channel of the heat map represents the probability distribution of the corresponding key point. Stacking two hourglass-shaped network structures allows the network in the second stage to use the output of the network in the first stage to learn the relationship between the key points, thereby improving the detection accuracy of the model. The vehicle key points selected by the present invention based on the actual shape of the vehicle have a strong representativeness of the three-dimensional shape of the vehicle and can more accurately describe the shape and size of the vehicle.
[0062] 4. The present invention provides a method for detecting two-dimensional to three-dimensional key points using a camera intrinsic parameter matrix and an extrinsic parameter matrix. The method converts the image coordinates of the two-dimensional key points into world coordinates, and assigns different height values to different targets according to the category of the detected target, thereby calculating the true position of the two-dimensional key points in the three-dimensional world, improving the availability and information richness of the vehicle key points, providing data support for extracting and constructing the three-dimensional driving trajectory of the vehicle, and helping to improve the detection accuracy of the system.
[0063] 5. The present invention provides a vehicle tracking method based on the Hungarian algorithm and Kalman filtering using GIOU as a matching condition. The use of GIOU can overcome the problem that IOU cannot objectively measure the difference between two non-overlapping frames, and can provide a more objective prediction frame overlap judgment result. The Hungarian algorithm can quickly solve the correspondence between the annotated frames of the previous and next frames, thereby determining the position change of the target at different times. The use of the Kalman filtering method can combine the observed value and the model predicted value to estimate and correct the position of the three-dimensional center point of the target, so that the position change of the three-dimensional center point of the target is more stable.
[0064] 6. The present invention provides a dynamic clustering method, which continuously adjusts categories as new samples are added. It is not necessary to pre-set all samples or specify the number of target categories for clustering. The method can be well combined with the actual abnormal event detection clustering problem, thereby providing stable and accurate clustering results.
[0065] 7. The present invention provides a vehicle abnormal event detection method for vehicle trajectory identification. By dynamically clustering the vehicle's position trajectory and speed record, the abnormal vehicle trajectory data can be identified from the two aspects of position and speed. The dynamic clustering method used in the present invention is combined with annotation to finally determine the actual event meaning represented by each category. The method has strong plasticity and can easily expand the identified abnormal events and merge similar vehicle behavior events into categories.
[0066] 8. The present invention provides a method for identifying abnormal events in traffic status using dynamic clustering. According to the three-dimensional trajectory data, the traffic volume of the road is counted by time period to obtain a state vector describing the traffic operation status of each time period. The state vector is clustered to divide the state vector into different categories, and finally the actual event type corresponding to each category is confirmed according to the existing annotation database. This clustering method does not need to pre-specify the number of categories, has strong plasticity, and can achieve rapid expansion of abnormal events and merging of similar events.
[0067] The present invention is further described in detail below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 The present invention is a flowchart of a method for detecting abnormal events on a highway.
[0069] Figure 2 It is a schematic diagram of the attention-based two-stage hourglass network structure of the present invention.
[0070] Figure 3 It is a schematic diagram of the network structure of a single stage in the attention-based two-stage hourglass network of the present invention.
[0071] Figure 4 This is a structural diagram of the residual block with attention mechanism in the attention-based two-stage hourglass network of the present invention.
[0072] Figure 5 It is a schematic diagram of the key point positions of the vehicle of the present invention. DETAILED DESCRIPTION
[0073] The present invention is further described in detail below in conjunction with the accompanying drawings. It should be pointed out that this specific embodiment is only an explanation of the present invention, and it is not a limitation of the present invention. After reading this specification, those skilled in the art can make non-creative modifications to the present embodiment as needed, but as long as it is within the scope of the claims of the present invention, it is protected by the patent law.
[0074] The present invention provides a method for detecting abnormal events on highways. The method reconstructs the trajectory of a vehicle in three-dimensional space based on target detection and key point detection technology, uses a dynamic clustering method to classify vehicle behavior according to trajectory data, and classifies the traffic status of the road according to traffic statistics, thereby realizing the detection of abnormal events on highways. The method acquires images through video surveillance equipment, detects the vehicle position using the YOLO target detection network, proposes a two-stage hourglass key point detection network based on attention to obtain the vehicle key points, and then combines the camera internal and external parameter matrix to obtain the three-dimensional coordinate position of the vehicle key points. The three-dimensional motion trajectory of the vehicle is obtained by tracking the three-dimensional spatial position of the vehicle. In the abnormal event analysis, the present invention proposes a dynamic clustering method, which uses the method to perform cluster analysis on the detected target vehicle motion trajectory according to the three-dimensional trajectory of the vehicle, identify the abnormal trajectory and judge the type of the abnormal trajectory, thereby realizing the judgment of the abnormal behavior event of a single vehicle. At the same time, by dynamically clustering the traffic statistics within a period of time, the accurate judgment of abnormal events in the traffic state is realized. The present invention breaks the conventional method of using two-dimensional trajectories to determine abnormal vehicle events, and the extracted three-dimensional trajectory improves the information richness of the vehicle trajectory. The dynamic clustering method proposed in the present invention can quickly capture abnormal events and has the effect of accurately identifying abnormal events, thus solving the problems of low accuracy and poor robustness of existing abnormal event detection methods based on highways.
[0075] This implementation method is for detecting abnormal events on highways. The specific steps of the method are as follows: Figure 1 After reading the external video stream, the method sequentially performs image preprocessing, target detection, key point detection, two-dimensional coordinate conversion, three-dimensional center point calculation, target tracking processing and other operations on the video image to finally generate the vehicle trajectory, and further detects the abnormal behavior of the vehicle based on the vehicle trajectory and road lane information. The abnormal behavior detected includes vehicle reversing, lane change, slow driving and parking events. The specific steps of the present invention are as follows:
[0076] Step 1, read the real-time video stream, decode the read video, and obtain the image frame; the real-time video stream obtains the original data through the RTSP protocol, and then uses a software or hardware decoder to decode the original data to obtain the image frame.
[0077] Step 2, preprocess the image frame; the preprocessing process includes color space conversion, image scaling, image normalization and other operations; according to the format of the image frame decoded in step 1, the image frame is converted into RGB format. As required, the input size of the target detection network is 416x416, so the image size needs to be scaled to 416x416. The pixel value range in the image frame is 0-255, but the target detection network requires an input of 0-1, so the image is normalized and the RGB value of each pixel is divided by 255, so that the image value range is scaled to 0-1 as the final network input.
[0078] Step 3, using the target detection model to detect the vehicle appearing in the image frame. In this step, it is necessary to load the vehicle target detection model first, carry out forward reasoning on the input image frame data, and parse and post-process the output of the neural network to obtain the final detection result. For each target, the detection result includes three parts, namely, the detection target position, category and the probability of belonging to the category. The target detection model uses the Yolov3-5layer model, which includes 5 yolo layers and can identify smaller targets. The vehicle detection category is small vehicles, medium-sized vehicles and large vehicles. The anchor of the model is obtained by comprehensive calculation using open source data sets and self-built data sets, and the weight file of the model is also obtained by training using open source data sets and self-built data sets. Wherein the self-built data set is independently constructed by the present invention and the marking of the vehicle is completed.
[0079] Step 4: Detect key points of the detected target. The key point detection model uses the attention-based two-stage hourglass model proposed in this invention. The network structure is as follows: Figure 2 The network structure of each stage is as follows Figure 3 As shown in Figure 2. The structure of each residual block with attention mechanism is as follows Figure 4As shown in the figure. In the residual block structure with attention mechanism, the image features are first subjected to a 1x1 convolution to compress the number of channels, and then a 3x3 convolution operation is performed to extract features. After the 3x3 convolution, the image features are pooled in the channel dimension using the pooling operation to obtain a mask with a channel number of 1 and the same size as the feature map, and the mask is multiplied by the result of the 3x3 convolution. Finally, the dot product result uses a 1x1 convolution operation to adjust the number of channels to the size of the original feature, and then adds it to the input feature. In the residual structure that needs to adjust the number of channels, it is necessary to add a 1x1 convolution operation after the input of the residual structure to convert the features to the target number of channels. At the same time, the number of channels of the 1x1 operation after the dot multiplication is also adjusted to the target number of channels, and then summed. The attention-based two-stage hourglass model is trained on the self-built dataset to obtain the final weight file. In this step, the trained attention-based two-stage hourglass key point detection model needs to be pre-loaded. During processing, the target is extracted from the video frame according to the annotation box of the detected vehicle target. For each target, it is scaled to 64x64 size as the input of the hourglass model. The output of each stage in the attention-based two-stage hourglass network has 14 channels. The pixel coordinates of the maximum value point in each channel represent the two-dimensional coordinates of a key point corresponding to the vehicle. The corresponding position of each key point on the vehicle is as follows Figure 5 As shown. The positions of the 14 key points are selected and determined by the present invention according to the shape of the vehicle. For each channel, the distance between the detection results of the channel in the two stages is calculated. If the distance is greater than 5 pixels, it is considered that the key point corresponding to the channel is not detected; if the distance is less than 5 pixels, it is considered that the key point corresponding to the channel is detected.
[0080] Step 5, for the detected key point coordinates, select the 8 main key point positions, including the left front bottom, right front bottom, left rear bottom, right rear bottom, left front upper corner, right front upper corner, left rear upper corner, and right rear upper corner, and use the camera internal and external parameter matrix to convert the two-dimensional key points into coordinate points in the real three-dimensional world. The main key points that are not detected are not processed. During the conversion process, for the four key points at the bottom, the left front bottom, the right front bottom, the left rear bottom, and the right rear bottom, set their heights to 0. For the four key points at the top, the left front upper corner, the right front upper corner, the left rear upper corner, and the right rear upper corner, the height values are taken according to the category obtained by vehicle target detection, that is, different values are taken according to the vehicle category. For small vehicles, the height is 1.4 meters; for medium-sized vehicles, the height is 1.85 meters; for large vehicles, the height is 3.3 meters.
[0081] Step 6, calculate the maximum and minimum values of the detected three-dimensional main key points in the three directions of x, y, and z, and further calculate the average of the maximum and minimum values in the three directions, that is, the center point of the vehicle in the three-dimensional space world.
[0082] Step 7, track the three-dimensional center point of the vehicle in the image frame. During the tracking process, GIOU is used as the similarity measure between the detected target and the existing target. Calculate the GIOU between each detected target and all the existing detected targets in turn, take 1-GIOU as the error value, and record the error value in the error matrix. According to the obtained error matrix, the Hungarian algorithm is used to calculate the best match between the target detected in the frame and the existing target. For each target that matches the existing detection frame, the Kalman filter method is used to continuously predict and track the position and speed of the vehicle; for the detected target that does not match the existing detection frame, the Kalman filter is initialized with the center point position of the site, and the detection frame is added to the existing detection frame set; for the existing detection frame that does not match the current frame detection frame, it is considered that the detection frame has disappeared and the detection frame is deleted from the existing detection frame set.
[0083] Step 8: Generate the vehicle driving trajectory. According to the time series changes of the center point of the vehicle at different times in the image frame, record the three-dimensional center point position of the vehicle at each moment and the time of that moment to obtain the vehicle driving trajectory, where each trajectory point is expressed as p = [x, y, z, t].
[0084] Step 9: Analysis and processing of vehicle abnormal events. According to the vehicle trajectory record, when a new trajectory is obtained, the Douglas-Peucker method is first used to simplify the trajectory and reduce the number of trajectory points to 30. The compression of the data volume can reduce the amount of calculation required for subsequent distance calculations and improve the actual running speed of the algorithm. Then, the dynamic time deviation distance (DTW) of the new trajectory and all existing trajectories is calculated in turn, and the minimum value of all dynamic time deviation distances is counted. If the minimum value is less than the set threshold D thre , the new trajectory is classified into the trajectory category corresponding to the DTW minimum value; if the minimum value is greater than the set threshold D thre , the new trajectory is considered as a new category independent of all existing trajectory categories. As the number of trajectories increases, when the DTW value between more than 5 trajectory samples in two categories is less than the threshold D thre, then these two categories are merged. Finally, the proportion of each type of vehicle trajectory and vehicle speed record to the total number of trajectories is counted and sorted in descending order. Then, the actual events represented by each type of vehicle trajectory and vehicle speed record are labeled and confirmed according to the existing annotation database. Events that are not matched to the existing annotation database are classified as unknown events. For unknown event types, the specific abnormal event type can be further confirmed by updating the annotation database. This method can realize the dynamic expansion of abnormal event types. This method can promptly detect abnormal behavior events of a single vehicle, such as vehicle reversing, vehicle lane changing, etc.
[0085] Step 10: Analysis and processing of abnormal traffic status events. During the processing, at a certain time interval, based on all the trajectories and other information extracted in the period, statistics are collected on traffic statistics such as average vehicle speed, vehicle flow, time occupancy, headway, queue length, etc., to obtain a state vector describing the traffic operation status of the period. For each newly added state vector, the Euclidean distance between the state vector and all existing state vectors is determined, and the minimum distance is obtained by statistics. If the minimum value is less than the set threshold S thre , the state vector is classified into the state category corresponding to the minimum value; if the minimum value is greater than the set threshold S thre , then the state vector is set as a new state category; when the distance between the two state categories is less than the set threshold S thre When the two categories are combined, the actual event meanings of each category in the existing annotation database are annotated to obtain the actual event type meanings of each category. Events that are not matched to the existing annotation database are classified as unknown events. For unknown event types, the specific abnormal event type can be further confirmed by updating the annotation database. This method can timely detect abnormal traffic conditions such as road congestion.
[0086] By adopting the abnormal event detection method for highways provided by the above-mentioned embodiment of the present invention, the driving trajectory of the vehicle in three-dimensional space can be extracted, the accuracy of vehicle trajectory extraction can be improved, and the impact of problems such as video surveillance angle and vehicle occlusion on vehicle trajectory extraction can be reduced, thereby increasing the accuracy of vehicle abnormal behavior event judgment.
[0087] The above describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A method for detecting abnormal events on highways, characterized in that: The method comprises the following steps: Step 1, read the real-time video stream, decode the video, and obtain the image frame; Step 2, preprocessing the image frame, including color space conversion, image scaling, and image normalization; Step 3: Load the vehicle detection model, perform reasoning on the preprocessed image, and parse the reasoning results to obtain the vehicle location and category information; Step 4: Load the vehicle key point detection model, perform key point detection on each detected vehicle target, and post-process the inference results to obtain the key point position of the vehicle and select the main key points of the vehicle; Step 5, according to the detected coordinates of the key points of the vehicle, use the camera internal and external parameter matrix and the vehicle model parameters to calculate the three-dimensional coordinates of the main key points of the vehicle; Step 6, calculating the center point of the vehicle in the three-dimensional space according to the calculated three-dimensional coordinates of the main key points of the vehicle; Step 7, taking the center point of the three-dimensional coordinates of the main key points of the vehicle as the tracking target, using GIOU as the evaluation index, using the Hungarian algorithm to match the detected target, and using the Kalman filter to track the target; Step 8, recording the position and time point of the three-dimensional coordinate center point of the tracking target from appearance to disappearance as the vehicle's driving trajectory; Step 9: According to the extracted vehicle driving trajectories, a dynamic clustering algorithm is used to dynamically cluster the vehicle trajectories, and the vehicle trajectory categories are marked, so as to identify abnormal behavior events of the vehicles; Step 10, traffic statistics within the time period are counted at fixed time intervals, the statistical state at different times is dynamically clustered, and the traffic state categories are marked to identify different traffic operation states, thereby determining abnormal events in traffic operation.
2. The abnormal event detection method for highways according to claim 1, characterized in that: In step 3, the vehicle detection model uses the Yolov3-5layer model, which is based on open source datasets and self-built datasets. The model anchor is calculated using the open source datasets and self-built datasets, and the final weight file is obtained by training on the open source datasets and self-built datasets. The open source data sets include COCO and VOC. The self-built data sets are obtained by collecting video data in different traffic scenarios and manually annotating them. The detection results of the Yolov3-5layer model include vehicle categories and vehicle locations, including small vehicles, medium vehicles and large vehicles.
3. The abnormal event detection method for highways according to claim 1 or 2, characterized in that: The vehicle key point detection model described in step 4 is a two-stage hourglass model based on the attention mechanism. The model introduces the attention mechanism into the hourglass model, and the final weight of the model is trained on the self-built data set; when the self-built data set is established, the left front bottom of the vehicle, the right front bottom, the left front headlight, the right front headlight, the left front window bottom, the right front window bottom, the left front upper corner, the right front upper corner, the left rear upper corner, the right rear upper corner, the left rear light, the right rear light, the left rear bottom, and the right rear bottom of the vehicle are customized and selected and labeled according to the actual shape of the vehicle. 14 sites are used as key points, and the side front bottom, right front bottom, left rear bottom, right rear bottom, left front upper corner, right front upper corner, left rear upper corner, and right rear upper corner are selected as the main key points.
4. The abnormal event detection method for highways according to claim 3 is characterized in that: Step 4 loads the vehicle key point detection model, performs key point detection on each detected vehicle target, and post-processes the inference results to obtain the key point position of the vehicle, specifically including: Step 4-1, for the output of each stage in the two stages, calculate the maximum value of the pixel points of each channel respectively, and record the coordinate position of the maximum value; Step 4-2, for each channel, calculate the distance between the maximum coordinate positions of the two stages corresponding to the channel. If the distance is greater than 5, it is considered that the outputs of the two stages of the channel do not match and the key point corresponding to the channel is not detected; otherwise, it is considered that the key point corresponding to the channel is detected; Step 4-3, traverse each channel and repeat step 4-2 until all 14 channels are processed.
5. The abnormal event detection method for highways according to claim 4 is characterized in that: In step 5, according to the detected coordinates of the key points of the vehicle, the three-dimensional coordinates of the main key points of the vehicle are calculated using the camera internal and external parameter matrix and the vehicle model parameters. The specific process includes: Step 5-1, obtain the camera's intrinsic parameter matrix K, camera rotation matrix R and translation matrix t through camera calibration, where the camera rotation matrix and translation matrix constitute the camera's extrinsic parameter matrix, and K and R are 3×3 real matrices, and t is a 3×1 vector; Step 5-2, for each detected main key point, its two-dimensional pixel coordinates on the image are expressed as p = [u, v, 1], where u represents the horizontal coordinate of the point and v represents the vertical coordinate of the point; for the main key point that is not detected, the following steps 5-3 and 5-4 are not performed; Step 5-3, calculate the coefficients. When the camera intrinsic parameter matrix and extrinsic parameter matrix are known, estimate the equation coefficients. The formula is: [x a ,y a ,z a ] T =R -1 K -1 p [x b ,y b ,z b ] T =R -1 t s=(z b +z) / z a Among them, R -1 represents the inverse matrix of the extrinsic rotation matrix, K -1 represents the inverse matrix of the internal parameter matrix, [x a ,y a ,z a ] T Represents R -1 K -1 The intermediate result vector obtained after p operation, z a Represents the vertical component of the intermediate result vector, x b ,y b ,z b Represents R -1 The intermediate result vector obtained after t operation, z b represents the vertical component of the intermediate result vector, and z represents the value of the preset key point in the vertical direction; the four points of the left front bottom, the right front bottom, the left rear bottom, and the right rear bottom take z=0; the left front upper corner, the right front upper corner, the left rear upper corner, and the right rear upper corner take z=z model , where z model According to the category of the detection target, z is obtained by looking up the table. For small vehicles, model =1.4m; for medium-sized vehicles, z model =1.85m; for large vehicles, z model =3.3m; Step 5-4, calculate the three-dimensional coordinate point x in the real world based on the two-dimensional coordinate point p of the key point, and the calculation formula is: x=[XYZ] T =sR -1 K -1 PR -1 t Where X, Y, and Z represent the components of the three-dimensional coordinate point in the x, y, and z directions of space, respectively.
6. The abnormal event detection method for highways according to claim 5, characterized in that: Step 6 calculates the center point of the vehicle in the three-dimensional space based on the calculated three-dimensional coordinates of the main key points of the vehicle. The specific process includes: Step 6-1, calculate the maximum and minimum values of the three-dimensional spatial coordinates of all detected key points in the x, y, and z directions, and obtain x min ,x max ,y min ,y max ,z min ,z max ; Step 6-2: For each of the three directions x, y, and z, calculate the mean of the maximum and minimum values in that direction and get x mean ,y mean ,y mean , with X c =(x mean ,y mean ,y mean ) as the center point of the vehicle in three-dimensional space.
7. The abnormal event detection method for highways according to claim 6, characterized in that: In step 7, the center point of the three-dimensional coordinates of the main key points of the vehicle is used as the tracking target, GIOU is used as the evaluation index, the Hungarian algorithm is used to match the detected target, and the Kalman filter is used to track the target, which specifically includes: Step 7-1, assuming that the current frame has M t detection frames, and up to the last frame, it has been determined that M t-1 detection frames, and calculate the error matrix E based on the two sets of detection frames, where E ij =1-GIOU(B t,i ,B t-1,j ), B t,i represents the i-th detection box in the current frame, B t-1,j represents the jth detection box in the existing detection box, and the calculation formula of GIOU is: In the formula, A∩B represents the intersection area of detection frames A and B, A∪B represents the area of detection frames A and B combined, and C represents the area of the smallest box that can enclose detection frames A and B; Step 7-2, using the Hungarian algorithm to calculate the best match between the detection frame of the current frame and the existing detection frame according to the error matrix E, and obtain the corresponding relationship between the two sets of detection frames; Step 7-3, for each detection frame in the current frame that matches an existing detection frame, use the Kalman filter to correct the center point position according to the detected corresponding three-dimensional center point position of the vehicle; for the detection frame in the current frame that does not match an existing detection frame, it is considered that the detection frame appears for the first time, and the detection frame is added to the existing detection frame set, and the Kalman filter is initialized using the center point position corresponding to the detection frame; for the existing detection frame that does not match the detected detection frame, it is considered that the detection frame has disappeared, and the detection frame is deleted from the existing detection frame set.
8. The abnormal event detection method for highways according to claim 7, characterized in that: The dynamic clustering algorithm described in step 9 includes the following steps: (1) It is known that there are m samples, and each sample belongs to n categories C1, C2, …, C n One of ; For a new sample S, use the selected metric to calculate the distance between the sample and all existing samples to obtain a distance set: D={d i =dist(S,S i )|i∈[1,m]} (2) Calculate the minimum value d among all distances min =min(D), and record the sample point S that obtains the minimum value min , and the category C to which the sample point belongs opt ; (3) Select the threshold T, if d min ≤T, then we assume that S∈C opt , that is, S is classified as category C opt If d min >T, the new sample is considered not to belong to any existing category, and a new category C is created. n+1 , let S∈C n+1 , that is, S is classified as category C n+1 ; If there are K sample points in two categories whose distance is less than the set threshold T, then the two categories are considered to be classified into one category, where K>0; (4) Repeat the above steps (1) to (3) until no new samples are added.
9. The abnormal event detection method for highways according to claim 8, characterized in that: Step 9, based on the extracted vehicle driving trajectory, dynamically cluster the vehicle trajectory using a dynamic clustering algorithm, mark the vehicle trajectory category, and thus identify the abnormal behavior event of the vehicle, specifically including: Step 9-1, according to the vehicle trajectory record, when a new trajectory is obtained, the Douglas-Peucker method is used to simplify the trajectory and reduce the number of trajectory points to N, where N is 30; Step 9-2, using a dynamic clustering method to process vehicle trajectories, wherein the distance measurement method between trajectories is selected as a dynamic time deviation distance DTW method; Step 9-3, respectively count the proportion of each type of vehicle trajectory to the total number of trajectories, and sort them in descending order. Then, label and confirm the category of each type of vehicle trajectory and vehicle speed record according to the existing labeling database, so as to obtain the actual event type meaning corresponding to each type of trajectory. Events that do not match the existing labeling database are classified as unknown events.
10. The abnormal event detection method for highways according to claim 9, characterized in that: Step 10 includes collecting traffic statistics within a period at fixed time intervals, dynamically clustering the statistics at different times, marking the traffic status categories, identifying different traffic operation states, and determining abnormal events in traffic operation, including: Step 10-1, according to the vehicle trajectory information, at a certain time interval, the traffic statistics within the time period are counted, including the average vehicle speed V mean , average traffic flow F mean , average time occupancy O mean , average headway H mean , average queue length L mean , and obtain the state vector State=[V mean ,F mean ,O mean ,H mean ,L mean ]; Step 10-2, clustering the state vectors using the dynamic clustering method, and the selected distance measurement standard between samples is Euclidean distance; Step 10-3, annotate and confirm the actual event meaning of each category according to the existing annotation database to obtain the actual event type meaning of each category, and the events that are not matched to the existing annotation database are classified as unknown events.
Citation Information
Cited By
Abnormal event identification method and system for traffic monitoring scene
CN117456482A
