Vehicle detecting and tracking method and device and computer readable storage medium
By using the trained object detection model and the DeepSort multi-objective tracking model in the vehicle detection and tracking method, and combining Phantom Convolution and C3GhostV2 to design the convolution attention module, the contradiction between detection and tracking accuracy and real-time in the existing technology is solved, and high-precision and lightweight vehicle detection and tracking is achieved, which improves road traffic safety.
Patent Information
- Application Number
- CN202411620902.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-14
Smart Images

Figure CN119580203A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of vehicle track recognition, and in particular to a vehicle detection and tracking method, device and computer-readable storage medium. Background Art
[0002] With the rapid development of industrial productivity and the continuous improvement of transportation infrastructure, people's demand for motor vehicle travel is also growing. However, the increase in road traffic vehicles has brought major challenges to traffic safety, and the high traffic accident rate has become the focus of safe driving. Real-time and accurate identification of vehicles in road traffic scenes can enable vehicles on the road to avoid safety hazards caused by abnormal vehicles in front, thereby effectively improving the safety of the driving system. In recent years, with the rapid development of artificial intelligence, computer vision technology can be used to analyze and identify vehicle images or videos, thereby realizing automatic detection, identification and tracking of vehicles.
[0003] In the prior art, a real-time target detection algorithm (You Only Look Once, YOLO) is combined with a multi-target tracking algorithm (DeepSort) to perform vehicle detection and tracking. The YOLO algorithm is used to detect the video stream collected from the road, and multiple vehicle bounding boxes and the position information of each vehicle in the current frame image of the video are output. After DeepSort receives the vehicle bounding box in the current frame image, it relies on a deep learning model to extract the features of each vehicle in the image and generates a unique feature vector as the identity of the vehicle. Then, the Kalman filter algorithm is used to predict the position of the vehicle in the next frame image according to the position information of each vehicle in the current frame image. Finally, the Hungarian algorithm is used to perform cascade matching and IoU matching on the predicted position of the vehicle in the next frame image with the bounding boxes and position information of multiple vehicles in the next frame image output by YOLO in real time. If a bounding box matching the vehicle is detected in the next frame image, the position information of the vehicle is updated, and the feature vector of the vehicle in the next frame image is re-extracted, thereby forming a continuous running trajectory of the vehicle. This method can detect and track vehicles on the road in real time, but the accuracy of detection and tracking often depends on the accuracy of target detection. With the continuous evolution of the YOLO series of algorithms, larger and more complex target detection models are constantly being proposed. As the scale of the model increases, the network structure becomes more and more complex, the extraction and recognition results of vehicles in the image become more and more accurate, and the output vehicle bounding box accuracy becomes higher and higher. However, the increase in the scale of the model and the complexity of the structure also lead to a larger number of model parameters and volume, which not only requires more computing resources and memory, but also increases the computational complexity, affecting the real-time performance of vehicle detection and tracking, making it impossible to adjust the traffic density and warn of traffic problems in advance according to the vehicle detection and tracking data, affecting road traffic safety.
[0004] In summary, the existing vehicle detection and tracking methods improve the detection and tracking accuracy while reducing the real-time performance of detection and tracking. They are unable to timely adjust the traffic density and provide early warning of traffic problems based on vehicle detection and tracking data, thus affecting road traffic safety. Summary of the invention
[0005] To this end, the technical problem to be solved by the present invention is to overcome the problem that the vehicle detection and tracking method in the prior art reduces the real-time performance of detection and tracking while improving the detection and tracking accuracy, and is unable to timely adjust the traffic density and provide early warning of traffic problems based on vehicle detection and tracking data, thereby affecting road traffic safety.
[0006] In order to solve the above technical problems, the present invention provides a vehicle detection and tracking method, comprising: Obtain a trained target detection model; the target detection model includes a feature extraction network, a multi-scale feature fusion network and a target detection network, the feature fusion network includes a CBS module, four convolutional attention modules and a spatial pyramid pooling module connected in series along the forward propagation direction, and each of the convolutional attention modules includes a first phantom convolution submodule and a C3GhostV2 submodule connected in series; Input each frame of the image in the video to be detected into the feature extraction network, and obtain the first feature map, the second feature map and the third feature map based on the output of the second convolutional attention module, the third convolutional attention module and the spatial pyramid pooling module; wherein the step of extracting features from the feature map by the C3GhostV2 submodule includes: Inputting the feature map into a first CBS unit and a second CBS unit respectively, and outputting a first intermediate feature and a second intermediate feature; Input the first intermediate feature into the long-distance attention mechanism enhancement unit and output the third intermediate feature; Inputting the second intermediate feature and the third intermediate feature into a feature fusion unit, and outputting a fourth intermediate feature; Input the fourth intermediate feature into the third CBS unit, and use the output of the third CBS unit as the output of the C3GhostV2 submodule; Inputting the first feature map, the second feature map and the third feature map into the multi-scale feature fusion network, and outputting a target feature map; Input the target feature map into the target detection network, and output the vehicle boundary box and position information; The vehicle boundary boxes and position information in all frame images in the video to be detected are input into the trained DeepSort multi-target tracking model, and the running tracks of each vehicle in the video to be detected are output.
[0007] Preferably, the training process of the target detection model includes: Obtain a training set of images to be detected; Inputting an image in the training set of images to be detected into the object detection model, and outputting a predicted vehicle bounding box in the image; Constructing a width-height difference minimization loss function based on the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box, the Euclidean distance between the center point of the predicted vehicle bounding box and the center point of the real vehicle bounding box, and the diagonal length, width, and height of the minimum circumscribed rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; Constructing a target detection loss function based on the width-height difference minimization loss function and the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box; The target detection model is trained using images in the to-be-detected image training set until the value of the target detection loss function is minimized, thereby obtaining a trained target detection model.
[0008] Preferably, the calculation formula for the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box is: , in, Represents the intersection-over-union ratio of the predicted vehicle bounding box and the actual vehicle bounding box; Represents the predicted vehicle bounding box; represents the real vehicle bounding box; The width-height difference minimization loss function is expressed as: , in, Represents the loss function that minimizes the difference between width and height; express loss; Indicates distance loss; represents the edge length loss; represents the square of the Euclidean distance between the center point of the predicted vehicle bounding box and the center point of the true vehicle bounding box; Represents the diagonal length of the minimum bounding rectangle covering the predicted vehicle bounding box and the true vehicle bounding box; Represents the square of the difference between the width of the predicted vehicle bounding box and the width of the actual vehicle bounding box; Represents the width of the minimum bounding rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; Represents the square of the difference between the height of the predicted vehicle bounding box and the height of the actual vehicle bounding box; Represents the height of the minimum bounding rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; The target detection loss function is expressed as: , in, represents the target detection loss function; Represents a hyperparameter used to control the curvature of the curve.
[0009] Preferably, the multi-scale feature fusion network includes a bottom-up feature fusion module, a top-down feature fusion module and a convolution module; The bottom-up feature fusion module includes a second phantom convolution submodule, a first upsampling submodule, a first feature fusion submodule, a first C3 submodule, a third phantom convolution submodule, a second upsampling submodule and a second feature fusion submodule which are sequentially connected in series along the forward propagation direction; The top-down feature fusion module includes a second C3 submodule, a fourth phantom convolution submodule, a third feature fusion submodule, a third C3 submodule, a fifth phantom convolution submodule, a fourth feature fusion submodule and a fourth C3 submodule connected in series in the forward propagation direction; The convolution module includes a sixth phantom convolution submodule, a seventh phantom convolution submodule and an eighth phantom convolution submodule.
[0010] Preferably, inputting the first feature map, the second feature map and the third feature map into the multi-scale feature fusion network, and outputting the target feature map comprises: Inputting the first feature map into the second feature fusion submodule in the bottom-up feature fusion module; inputting the second feature map into the second feature fusion submodule in the bottom-up feature fusion module; inputting the third feature map into the second phantom convolution submodule in the bottom-up feature fusion module; Input the feature map output by the second phantom convolution submodule into the fourth feature fusion submodule in the top-down feature fusion module; input the feature map output by the third phantom convolution submodule into the third feature fusion submodule in the top-down feature fusion module; input the feature map output by the second feature fusion submodule into the second C3 submodule in the top-down feature fusion module; The feature map output by the second C3 submodule is input into the sixth phantom convolution submodule to output a first target feature map; the feature map output by the third C3 submodule is input into the seventh phantom convolution submodule to output a second target feature map; the feature map output by the fourth C3 submodule is input into the eighth phantom convolution submodule to output a third target feature map.
[0011] Preferably, the object detection network comprises a first detection head, a second detection head and a third detection head.
[0012] Preferably, inputting the target feature map into the target detection network, and outputting the vehicle bounding box and position information comprises: Inputting the first target feature map into the first detection head, outputting the coordinates of the first predicted bounding box, the confidence that the first predicted bounding box is a vehicle bounding box, and the probability distribution that the first predicted bounding box belongs to each category bounding box; Inputting the second target feature map into the second detection head, outputting the coordinates of the second predicted bounding box, the confidence that the second predicted bounding box is a vehicle bounding box, and the probability distribution that the second predicted bounding box belongs to each category bounding box; The third target feature map is input into the third detection head, and the coordinates of the third predicted bounding box, the confidence that the third predicted bounding box is a vehicle bounding box, and the probability distribution that the third predicted bounding box belongs to each category bounding box are output.
[0013] Preferably, the feature extraction network in the DeepSort multi-target tracking model is ShuffleNetV2.
[0014] The present invention also provides a vehicle detection and tracking device, comprising: A target detection model acquisition module is used to acquire a trained target detection model; the target detection model includes a feature extraction network, a multi-scale feature fusion network and a target detection network, the feature fusion network includes a CBS module, four convolutional attention modules and a spatial pyramid pooling module connected in series in the forward propagation direction, and each of the convolutional attention modules includes a first phantom convolution submodule and a C3GhostV2 submodule connected in series; The feature extraction module is used to input each frame of the video to be detected into the feature extraction network, and obtain the first feature map, the second feature map and the third feature map based on the output of the second convolutional attention module, the third convolutional attention module and the spatial pyramid pooling module; wherein the step of extracting features from the feature map by the C3GhostV2 submodule includes: Inputting the feature map into a first CBS unit and a second CBS unit respectively, and outputting a first intermediate feature and a second intermediate feature; Input the first intermediate feature into the long-distance attention mechanism enhancement unit and output the third intermediate feature; Inputting the second intermediate feature and the third intermediate feature into a feature fusion unit, and outputting a fourth intermediate feature; Input the fourth intermediate feature into the third CBS unit, and use the output of the third CBS unit as the output of the C3GhostV2 submodule; A feature fusion module, used for inputting the first feature map, the second feature map and the third feature map into the multi-scale feature fusion network, and outputting a target feature map; A target detection module, used to input the target feature map into the target detection network and output a vehicle boundary box and position information; The target tracking module is used to input the vehicle boundary boxes and position information in all frame images in the video to be detected into the trained DeepSort multi-target tracking model, and output the running trajectory of each vehicle in the video to be detected.
[0015] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned vehicle detection and tracking method are implemented.
[0016] The vehicle detection and tracking method provided by this application has the following beneficial effects: 1. Use phantom convolution and C3GhostV2 to design the convolution attention module in the feature extraction network, so as to construct a high-precision and lightweight target detection model. Among them, phantom convolution can generate feature maps through a small amount of nonlinear convolution operations, and then perform a linear operation on the feature map to generate more feature maps. By splicing all feature maps to obtain all feature information and eliminate the redundancy between feature maps, the number of parameters and the amount of calculation of the feature extraction network can be reduced, and the efficiency of feature extraction can be improved. At the same time, two parallel CBS units in the C3GhostV2 submodule are used to extract features from the input feature map at different scales to enhance the local feature capture capability. The output of one of the CBS units is input into the long-distance attention mechanism enhancement unit, so as to effectively fuse the global information and make up for the pure convolution structure in It captures the deficiencies in long-distance feature dependence, then fuses the extracted local features and global features through the feature fusion unit to improve the feature representation capability, and finally uses the CBS unit to optimize the fused features to generate more feature maps without significantly increasing the amount of calculation and parameters. This not only improves the efficiency of feature extraction, but also ensures the quality of feature extraction. It combines low computational complexity with powerful feature expression capabilities to form an efficient and high-precision convolutional attention mechanism, and uses a multi-scale feature fusion network and a detection network to perform target detection based on the feature maps extracted by the feature extraction network. This not only ensures the detection accuracy of the target detection model, but also realizes the lightweight of the model. In this way, it can be combined with the DeepSort multi-target tracking model to detect and track road vehicles in real time and with high precision, providing a data basis for road traffic safety.
[0017] 2. By connecting four convolutional attention modules in series and extracting feature information from different scales and angles, the feature extraction network can capture features from fine-grained to coarse-grained, thereby improving the performance of the target detection model. Finally, the spatial pyramid pooling module is used to aggregate the extracted features in the spatial dimension, compress the spatial information into a smaller representation, and reduce the spatial resolution of the feature map. While maintaining the effectiveness of feature extraction, the number of parameters is reduced, further realizing the lightweight of the target detection model and reducing the redundancy of the feature map generated during the target detection process, thereby improving the real-time performance of target detection and vehicle tracking. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein: Figure 1 Flowchart of the vehicle detection and tracking method provided for this application; Figure 2 A schematic diagram of the structure of the phantom convolution submodule provided for this application; Figure 3 Schematic diagram of the C3GhostV2 submodule structure provided for this application; Figure 4 Schematic diagram of the target detection model structure provided for this application; Figure 5 A schematic diagram of the intersection of the predicted vehicle bounding box and the real vehicle bounding box provided in this application; Figure 6 A schematic diagram of the ShuffleNetV2 structure provided for this application; Figure 7 Schematic diagram of the vehicle detection and tracking process provided for this application; Figure 8 A schematic diagram showing the comparison of the tracking effects of the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided in this application on vehicles on a viaduct in a cloudy environment; Fig. 9 A schematic diagram comparing the tracking effects of the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided in this application under vehicle occlusion; Fig.10 The inspection results of highway vehicles on a sunny day using the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided in this application; Fig.11Tracking results of the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided in this application for vehicles on a highway under a sunny sky from frame 1626 to frame 1721; Fig.12 The results of the tunnel vehicle tracking test using the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided by this application; Fig.13 The tracking results of the vehicle traveling in the tunnel from frame 1626 to frame 1721 using the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided in this application; Fig.14 This is a schematic diagram of the structure of the vehicle detection and tracking device provided in this application. DETAILED DESCRIPTION
[0019] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0020] See also Figure 1 , Figure 1 The flowchart of the vehicle detection and tracking method provided by the present application is shown, and the method specifically includes: S10: Obtain a trained target detection model; the target detection model includes a feature extraction network, a multi-scale feature fusion network and a target detection network, the feature fusion network includes a CBS module, four convolutional attention modules and a spatial pyramid pooling module connected in series along the forward propagation direction, and each convolutional attention module includes a first phantom convolution submodule and a C3GhostV2 submodule connected in series; S20: Input each frame of the video to be detected into the feature extraction network, and obtain the first feature map, the second feature map and the third feature map based on the output of the second convolutional attention module, the third convolutional attention module and the spatial pyramid pooling module; wherein the step of extracting features from the feature map by the C3GhostV2 submodule includes: Input the feature map into the first CBS unit and the second CBS unit respectively, and output the first intermediate feature and the second intermediate feature; Input the first intermediate feature into the long-distance attention mechanism enhancement unit and output the third intermediate feature; Input the second intermediate feature and the third intermediate feature into a feature fusion unit, and output a fourth intermediate feature; Input the fourth intermediate feature into the third CBS unit, and use the output of the third CBS unit as the output of the C3GhostV2 submodule; S30: inputting the first feature map, the second feature map and the third feature map into a multi-scale feature fusion network, and outputting a target feature map; S40: Input the target feature map into the target detection network, and output the vehicle boundary box and position information; S50: Input the vehicle boundary boxes and position information in all frame images in the video to be detected into the trained DeepSort multi-target tracking model, and output the running tracks of each vehicle in the video to be detected.
[0021] In the prior art, the feature extraction network in the target detection model mostly uses multiple traditional Conv convolution blocks to convolve the input image, thereby generating a large number of feature maps. These feature maps often contain a large amount of redundant information, resulting in high computational complexity of the target detection model, low detection efficiency and increased storage requirements. Therefore, this application adopts a convolution operation based on grouped convolution and channel rearrangement to deal with the redundancy between feature maps.
[0022] Specifically, Figure 2 As shown is a structural schematic diagram of the ghost convolution submodule (GhostConv) provided by the present application, an initial feature map is generated through a small number of nonlinear convolution operations, and then more new feature maps are generated through a linear operation. These new feature maps are called ghosts of the initial feature maps. Finally, the initial feature map and the new feature map are spliced to obtain all the feature information of the image and eliminate the redundancy between the feature maps. The present application uses GhostConv instead of traditional Conv to effectively reduce the feature redundancy generated when the target detection model extracts features from the image, saves computing resources, reduces the amount of model parameters and calculations, realizes model lightweight and improves the efficiency of target detection, thereby improving the real-time performance of vehicle detection and tracking.
[0023] Furthermore, in addition to using the phantom convolution submodule, the present application also designs a C3GhostV2 submodule. Specifically, GhostNetV2, as a lightweight network module, can achieve a good balance in long-distance modeling, computational efficiency, global receptive field, feature representation, accuracy, and reasoning speed. Therefore, the present application embeds GhostNetV2 into the C3 module to obtain the C3GhostV2 submodule. The structure of the C3GhostV2 submodule is as follows: Figure 3 shown.
[0024] Among them, the CBS unit consists of convolution, batch normalization and SiLu activation layers, which are used to enhance the nonlinear ability of the model while extracting image features.
[0025] This application connects the phantom convolution submodule and the C3GhostV2 submodule in series as a convolutional attention module. The phantom convolution submodule improves the expressiveness of the convolution layer, and reduces the amount of calculation and parameters by decomposing the original convolution operation, transmits information in different convolution kernels, captures fine-grained features, and improves the efficiency of feature extraction. Then, the C3GhostV2 submodule is used to generate more feature maps without significantly increasing the amount of calculation and parameters. This not only improves the efficiency of feature extraction, but also ensures the quality of feature extraction, combining low computational complexity with powerful feature expression capabilities to form an efficient and high-precision convolutional attention mechanism. In addition, by connecting four convolutional attention modules in series and extracting feature information from different scales and angles, the feature extraction network can capture features from fine-grained to coarse-grained features, thereby improving the performance of the target detection model. Finally, the spatial pyramid pooling module is used to aggregate the extracted features in the spatial dimension, compress the spatial information into a smaller representation, and reduce the spatial resolution of the feature map. The feature extraction network designed in this application reduces the amount of parameters while maintaining the effectiveness of feature extraction, thereby achieving lightweight target detection models, reducing the redundancy of feature maps generated during target detection, and ensuring target detection accuracy, thereby improving the timeliness and accuracy of vehicle detection and tracking, and can detect and track road vehicles in real time and with high precision, providing a data basis for road traffic safety.
[0026] Specifically, in some embodiments of the present application, the multi-scale feature fusion network includes a bottom-up feature fusion module, a top-down feature fusion module, and a convolution module; The bottom-up feature fusion module includes a second phantom convolution submodule, a first upsampling submodule, a first feature fusion submodule, a first C3 submodule, a third phantom convolution submodule, a second upsampling submodule, and a second feature fusion submodule, which are sequentially connected in series along the forward propagation direction; The top-down feature fusion module includes a second C3 submodule, a fourth phantom convolution submodule, a third feature fusion submodule, a third C3 submodule, a fifth phantom convolution submodule, a fourth feature fusion submodule and a fourth C3 submodule connected in series in the forward propagation direction; The convolution module includes a sixth phantom convolution submodule, a seventh phantom convolution submodule and an eighth phantom convolution submodule.
[0027] The multi-scale feature fusion network adopts the PANet structure, which integrates the feature maps of different levels in the feature extraction network, and improves the detection performance of the target detection model for targets of different scales. This application also uses the phantom convolution sub-module to replace the traditional convolution block in the multi-scale feature fusion network, reducing the number of parameters and calculations in the multi-scale feature fusion network, further realizing the lightweight of the target detection model, and improving the detection efficiency of the target detection model and the real-time performance of vehicle detection and tracking.
[0028] Based on the specific structure of the multi-scale feature fusion network described above, step S30 specifically includes: Inputting the first feature map into the second feature fusion submodule in the bottom-up feature fusion module; inputting the second feature map into the second feature fusion submodule in the bottom-up feature fusion module; inputting the third feature map into the second phantom convolution submodule in the bottom-up feature fusion module; Input the feature map output by the second phantom convolution submodule into the fourth feature fusion submodule in the top-down feature fusion module; input the feature map output by the third phantom convolution submodule into the third feature fusion submodule in the top-down feature fusion module; input the feature map output by the second feature fusion submodule into the second C3 submodule in the top-down feature fusion module; The feature map output by the second C3 submodule is input into the sixth phantom convolution submodule to output the first target feature map; the feature map output by the third C3 submodule is input into the seventh phantom convolution submodule to output the second target feature map; the feature map output by the fourth C3 submodule is input into the eighth phantom convolution submodule to output the third target feature map.
[0029] Furthermore, the target detection network includes a first detection head, a second detection head and a third detection head, such as Figure 4 The figure shows a schematic diagram of the target detection model structure provided in this application.
[0030] Step S40 inputs the target feature map into the target detection network, and outputs the vehicle boundary box and position information, specifically including: Inputting the first target feature map into the first detection head, outputting the coordinates of the first predicted bounding box, the confidence that the first predicted bounding box is a vehicle bounding box, and the probability distribution that the first predicted bounding box belongs to each category bounding box; Inputting the second target feature map into the second detection head, outputting the coordinates of the second predicted bounding box, the confidence that the second predicted bounding box is a vehicle bounding box, and the probability distribution that the second predicted bounding box belongs to each category bounding box; The third target feature map is input into the third detection head, and the coordinates of the third predicted bounding box, the confidence that the third predicted bounding box is a vehicle bounding box, and the probability distribution that the third predicted bounding box belongs to each category bounding box are output.
[0031] In the object detection model training process, the intersection over union (IOU) is usually used as an indicator to measure the degree of overlap between the predicted object bounding box and the true object bounding box, such as Figure 5 As shown in the figure, the higher the IOU, the more accurate the detection result of the target detection model is. The calculation formula is: , in, Represents the intersection-over-union ratio of the predicted vehicle bounding box and the actual vehicle bounding box; Represents the predicted vehicle bounding box; represents the real vehicle bounding box; The loss function of the target detection model in the prior art is constructed based on the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box, the Euclidean distance between the center point of the predicted vehicle bounding box and the center point of the real vehicle bounding box, and the diagonal length of the minimum circumscribed rectangle covering the predicted vehicle bounding box and the real vehicle bounding box: , , in, is the loss function of the target detection model in the prior art; represents the weight parameter; Used to measure the similarity of aspect ratio; Represents the width of the predicted vehicle bounding box; Represents the height of the predicted vehicle bounding box; Indicates the width of the real vehicle bounding box; Represents the height of the ground-truth vehicle bounding box.
[0032] Although the loss function constructed in the prior art takes into account factors such as the center point distance and the aspect ratio of the bounding box, it lacks adaptability to the loss and gradient, and does not improve the accuracy of small target detection. Based on this, the embodiment of the present application provides a method for training a target detection model. Specifically, the training process of the target detection model includes: Obtain a training set of images to be detected; Input the images in the training set of images to be detected into the object detection model and output the predicted vehicle bounding box in the image; Constructing a width-height difference minimization loss function based on the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box, the Euclidean distance between the center point of the predicted vehicle bounding box and the center point of the real vehicle bounding box, and the diagonal length, width, and height of the minimum circumscribed rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; Specifically, the width-height difference minimization loss function is expressed as: , in, Represents the loss function that minimizes the difference between width and height; express loss; Indicates distance loss; represents the edge length loss; represents the square of the Euclidean distance between the center point of the predicted vehicle bounding box and the center point of the true vehicle bounding box; Represents the diagonal length of the minimum bounding rectangle covering the predicted vehicle bounding box and the true vehicle bounding box; Represents the square of the difference between the width of the predicted vehicle bounding box and the width of the actual vehicle bounding box; Represents the width of the minimum bounding rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; Represents the square of the difference between the height of the predicted vehicle bounding box and the height of the actual vehicle bounding box; Represents the height of the minimum bounding rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; Construct the target detection loss function based on minimizing the width-height difference loss function and the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box; Specifically, the target detection loss function is expressed as: , in, represents the target detection loss function; Represents a hyperparameter used to control the curvature of the curve.
[0033] The target detection model is trained using images in the image training set until the value of the target detection loss function is minimized, thereby obtaining a trained target detection model.
[0034] This application uses the width-height difference minimization loss function to minimize the difference in height and width between the predicted bounding box and the true bounding box to accelerate the convergence speed of the model and obtain more accurate target detection results. The target detection loss function is then obtained by combining the intersection-over-union ratio of the predicted bounding box and the true bounding box, so that the bounding box regression focuses more on high-quality bounding boxes, enhances the model's recognition of target vehicles with smaller distant imaging targets, and further improves the recognition accuracy of the target detection model.
[0035] Specifically, after receiving the target detection results, the DeepSort multi-target tracking model first initializes the target trajectory and predicts the target trajectory through Kalman filtering. The prediction expression is as follows: , , according to The state estimate and covariance matrix at the moment, prediction The state estimation value and covariance matrix at the moment, Kalman filter predicts the vehicle at the next moment according to the current moment. The state of the moment, is the (covariance) state matrix, is the external control matrix, is the state transfer matrix, is the external interference matrix; right The confirmed state trajectory at the moment is cascade matched with the current vehicle target frame. At this time, the matching results are divided into three cases: successful matching, trajectory mismatch, and detection mismatch. If the match is successful, the target frame predicted by the Kalman filter is updated, and then the target trajectory at the current moment is predicted. The update expression is as follows: , , , The prior estimate is corrected and adjusted according to the observation value at the current moment to obtain the posterior estimate. Represents the observation matrix, which maps the state vector to the observation space; for The (covariance) optimal estimate matrix at time , is the (covariance) measurement matrix; If the match fails, the unmatched trajectory is IOU matched with the unmatched detection. If the match is successful, it is updated and a new round of tracking process is carried out.
[0036] If the detected target fails to match again, it may be due to the appearance of a new target or the target being blocked for a long time. At this time, the system will establish a new track but temporarily mark it as undetermined. After three inspections and confirmations, if the target is confirmed to be real, it will be changed to confirmed status and tracked and updated.
[0037] If the track fails to match again, it may be because the target cannot be accurately detected. At this time, it is processed according to the track status. The undetermined status is directly deleted. If the confirmed status does not change within the set life time, it is considered that the target has moved out of the lens and the track is deleted. Otherwise, three inspections are carried out and the tracking update is performed again after confirmation.
[0038]
[0039] ,
[0040] It is used to measure the distance between the detected target and the trajectory, where represents the detected target feature vector, The feature vector representing the trajectory, is the inverse matrix of the covariance matrix; Used to associate detected targets with trajectories, where represents the set of trajectory feature vectors, Represents a known trajectory The eigenvector A quantity.
[0041] The feature extraction network in the DeepSort multi-target tracking model extracts relevant feature information from the input target image to describe the target appearance and its structural features, thereby realizing the recognition and tracking of the target. In the prior art, the feature extraction network in the DeepSort multi-target tracking model mainly consists of two convolutional layers, one maximum pooling layer, six residual networks and one fully connected layer. The specific network structure is shown in Table 1. Table 1
[0042] In order to further improve the real-time performance of vehicle detection and tracking, the present application also lightweights the DeepSort multi-target tracking model. Specifically, in some embodiments of the present application, the feature extraction network in the DeepSort multi-target tracking model is ShuffleNetV2.
[0043] like Figure 6 The diagram shows the structure of ShuffleNetV2 provided by this application. ShuffleNetV2 achieves lightweight through channel shuffle (CS) and deep separable convolution operations. The channel shuffle operation is that ShuffleNetV2 groups the input feature channels and interleaves and reorganizes them after group convolution, realizing information exchange and fusion between different channels. The deep separable convolution decomposes the convolution operation into two parts: deep convolution and point-by-point convolution, effectively reducing the number of parameters and calculations of the model, making the network more lightweight while maintaining effective feature extraction capabilities. Therefore, using ShuffleNetV2 to replace the feature extraction network in the DeepSort multi-target tracking model can ensure that the tracking accuracy fluctuates within an acceptable range while ensuring the lightweight of the model, without reducing the expressiveness of the model.
[0044] Specifically, in some embodiments, when the DeepSort multi-target tracking model is used for vehicle tracking, the size of the rectangular frame of the input image needs to be converted to adapt to the size of the vehicle image. In a specific example of the present application, the size of the rectangular frame of a 128×64 image with a height of 128 and a width of 64 is adjusted to 64×128. Table 2 shows the specific parameters of using ShuffleNetV2 as the feature extraction network after adjusting the size of the rectangular frame: Table 2
[0045] like Figure 7The figure is a schematic diagram of the vehicle detection and tracking process provided by the present application, which takes the video stream as input data and performs preprocessing; loads and initializes the trained target detection model, then passes the preprocessed video into the target detection model, detects the target object, and then extracts the detection result; inputs the detected target object into the DeepSort multi-target tracking model; initializes the DeepSort multi-target tracking model and inputs the feature vector and detection box, passes the detection result of the current frame into the DeepSort multi-target tracking model, updates the tracking status and generates a new tracking ID; repeats the above steps for each frame image in the video stream, continues target detection and tracking until all input data are processed; obtains the running trajectory of each vehicle, and completes vehicle detection and tracking.
[0046] This application uses the BDD100K dataset to train the benchmark YOLOv5 model and the target detection model provided by this application, covering different weather conditions, including sunny, cloudy and rainy days, as well as different times of day and night. This dataset is one of the largest and most diverse autonomous driving datasets to date, with a total of 10,000 images in the dataset, covering vehicle images of different models in various driving scenarios and different weather environments. The images are then divided into training and validation sets in a ratio of 8:2, and the images are pre-processed by adding noise, flipping, and adjusting brightness. Since the detection focus of this application is to identify the vehicle in front rather than its category, the dataset labels are unified as 'car'.
[0047] Veri-776 is a large vehicle re-identification dataset containing more than 40,000 images of 776 vehicles. Each vehicle contains images taken by 2-18 cameras at different angles. The dataset is divided into training set and test set in a ratio of 7:3. The original feature extraction network model of the Deepsort multi-target tracking model and the lightweight feature extraction network model with ShuffleNetv2 are tracked and trained for 120 rounds.
[0048] The target detection model provided in this application is compared with the YOLOv5s model and the mainstream lightweight backbone network models (ShuffleNetV2, MobileNetV3 and EfficientNetV2). The experimental results are shown in Table 3: Table 3
[0049] From the data in Table 3, it can be seen that the GFLOPS of ShuffleNetv2 is only 1.8, and the number of parameters is 842358, but its mAP@0.5 drops to 94.60%. EfficientNetV2 and MobileNetV3 have achieved a good balance in GFLOPS and parameter volume, reaching 5.6 GFLOPS and 2.5 GFLOPS respectively, but their mAP@0.5 also dropped to 96.60% and 95.20% respectively. The above lightweight models all have different degrees of loss in detection accuracy. Although YOLOv8s has a slight improvement in target detection accuracy based on the model provided in this application, its GFLOPS and parameter volume are close to three times that of our optimized model. Based on the latest end-to-end real-time target detection model YOLOv10 published by Tsinghua University, the mAP value is 0.20% higher than the original model, but it is lower than the optimized model, and the GFLOPS and parameter volume are close to twice that of the optimized model.
[0050] Experiments show that by optimizing the model structure and algorithm, the computational complexity and number of parameters can be significantly reduced while maintaining or even improving the detection accuracy to a certain extent. The target detection model provided by this application has a GFLOPS of 10.0, which is 37% lower than the YOLOv5s model. The number of parameters is 4601086, which is 34.50% lower, and the mAP@0.5 reaches 97.10%, which is higher than the YOLOv5s model. This shows that the target detection model provided by this application successfully reduces the computational complexity and number of parameters while maintaining high accuracy, realizes model lightweight, and is suitable for vehicle detection tasks in practical applications.
[0051] The embodiment of the present application also explores the impact of different lightweight modules on model performance through ablation experiments, and selects GhostConv, C3GhostV2 modules in the feature extraction network, GhostConv modules in the Conv convolution layer in the multi-scale feature fusion network, and the target detection loss function. As independent variables, we analyze the impact of each component on the overall performance of the model. The experimental results are shown in Table 4: Table 4
[0052] From the data in Table 4, it can be seen that after replacing the Conv and C3 modules in the feature extraction network with GhostConv and C3GhostV2 respectively, the mAP@0.5 of the model is increased from 96.80% to 96.90%, GFLOPS is reduced from 15.9 to 10.6, and the number of parameters is reduced from 7022326 to 5042046, indicating that the lightweight convolution module used in this application can effectively reduce the computational complexity and parameter amount without significantly affecting the accuracy. When GhostConv replaces the Conv module in the multi-scale feature fusion network, the accuracy is slightly improved to 97%, GFLOPS is further reduced to 10.0, and the number of parameters is reduced to 4601086, indicating that the application of lightweight convolution modules in multi-scale feature extraction networks can not only continue to reduce the computational complexity and parameter amount, but also slightly improve the model accuracy. Finally, after adding the target detection loss function provided in this application, the mAP@0.5 of the model is further improved to 97.10%, and the GFLOPS and parameter amount remain unchanged, which fully demonstrates the advantage of the lightweight convolution module in further reducing the amount of calculation and the amount of parameters on the basis of improving the original accuracy.
[0053] The weight is one of the important indicators to measure the lightweight degree of the model. It directly affects the application effect of the model in embedded devices or in resource-constrained environments. In order to evaluate the lightweight effect of the target detection model and the DeepSort multi-target tracking model, this experiment will analyze and compare the model weights of the two algorithms. The experimental results are shown in Table 5: Table 5
[0054] In the prior art, the model weight of the YOLOv5s+DeepSORT combination is 24.7MB. After the target detection model provided by this application is used as the detector of the tracking model, the weight is reduced to 20.28MB, which is about 17.9% less than that of the original model. After ShuffleNetV2 is further used as the Deepsort feature extraction network, the combined model weight is reduced to 13.62MB, which is about 44.9% less than that of the original model. The results show that by lightweighting the target detection model and the DeepSort multi-target tracking model, the model weight is significantly reduced.
[0055] The effectiveness of the vehicle detection and tracking method provided in the above embodiment is verified by a specific example below: The vehicle tracking videos shot by the on-board camera of Tesla Model Y are used as the validation set to evaluate the effect of vehicle tracking. The dataset includes three scenes: cloudy elevated road, sunny highway, and tunnel. The video length is 59 seconds.
[0056] like Figure 8The figure shows the comparison of the tracking effect of the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided by this application on vehicles on the viaduct in a cloudy environment. Figure 8 (a) and Figure 8 (b) shows the tracking result of the YOLOv5-Deepsort model from frame 628 to frame 632, which shows that the bus in front cannot be identified. Figure 8 (c) and Figure 8 (d) is the tracking result of the target detection model + DeepSort multi-target tracking model provided by this application in the corresponding frame, which can accurately identify the bus that the original algorithm failed to track, marked as ID 16.
[0057] Fig. 9 The figure shows the ID changes after the blocked vehicle is re-identified from frame 861 to frame 924. The upper and lower groups of pictures are also the test results of the YOLOv5-Deepsort model and the target detection model + DeepSort multi-target tracking model provided by this application. Fig. 9 In (c), the vehicle with ID 2 is accurately identified, and Fig. 9 It is not accurately identified in (a); in frames 861 to 924, Fig. 9 In (a), vehicle with ID 21 is briefly blocked by vehicle with ID 19. Fig. 9 (b) in the figure shows that after the occluded vehicle is re-identified in frame 924, the ID of the vehicle previously with ID 21 is switched to 24, while the corresponding frame below shows that the ID of the corresponding vehicle with ID 17 remains 17 after being re-identified after being occluded, and no switch occurs.
[0058] Fig.10 The following are the results of two methods for highway vehicle inspection on a sunny day, from frame 1599 to frame 1606. Fig.10 (a) and Fig.10 In (b), the front vehicle with ID 16 is partially blocked and not recognized by the YOLOv5-Deepsort model. Fig.10 (c) and Fig.10 As shown in (d), the target detection model + DeepSort multi-target tracking model provided by this application can still accurately identify it, and its ID is 4.
[0059] like Fig.11 The following are the tracking results of two methods for highway vehicles on a sunny day from frame 1626 to frame 1721. Fig.11In (a), the vehicle with ID 5 was not recognized by the YOLOv5-Deepsort model between frames 1626 and 1721 due to occlusion. Fig.11 After (b) is detected, the ID switches to 24. Fig.11 The corresponding vehicle with ID 4 in (c) to frame 1644 can be accurately tracked by the target detection model + DeepSort multi-target tracking model provided by this application, between frames 1644 and 1705 ( Fig.11 (d) in the figure is not accurately tracked due to occlusion, and at frame 1705 ( Fig.11 In (e)), the blocked vehicle is recognized again, and the ID is 4 without switching.
[0060] Fig.12 The following are the results of two methods for tracking vehicles in tunnels, from frame 1125 to frame 1128. Fig.12 (a) and Fig.12 In (b), the vehicle in front of the vehicle with ID 16 is blocked and cannot be accurately identified by the YOLOv5-Deepsort model. Fig.12 (c) and Fig.12 (d) in the figure shows that the corresponding vehicle can be identified by the target detection model + DeepSort multi-target tracking model provided by this application, and its ID is 3.
[0061] Fig.13 The following are the tracking results of the two methods for the tunnel vehicle from frame 1626 to frame 1721. Fig.13 (a) and Fig.13 In (b), there is a black car in front. Due to the long distance, the YOLOv5-Deepsort model cannot track the vehicle with a smaller image. Fig.13 (c) and Fig.13 (d) in the figure shows that the corresponding vehicle can be accurately tracked by the target detection model + DeepSort multi-target tracking model provided by this application, and the vehicle ID is 35.
[0062] In summary, the improved model provided by the present application performs well in different environments such as cloudy days, highways and tunnels, and can stably and accurately identify and track vehicles, indicating that the improved model has strong robustness in different environments, while the YOLOv5-Deepsort model in the prior art is more likely to miss the detection of vehicles. In addition, the improved model can more accurately identify the obscured vehicle compared to the YOLOv5-Deepsort model, and is better than the YOLOv5-Deepsort model in maintaining the consistency of vehicle ID, avoiding the ID switching problem caused by occlusion, thereby improving the continuity and accuracy of tracking. In addition, the improved model can also accurately identify and track vehicles at a distance, while the YOLOv5-Deepsort model often fails to successfully identify in similar situations. Experiments show that the improved model is not only lightweight in size to adapt to mobile devices, but also can more accurately and stably track the vehicle in front than the YOLOv5-Deepsort model, and has achieved a good balance in detection accuracy, processing efficiency and resource consumption, showing great practical value.
[0063] Through the example visualization analysis of the multi-target tracking algorithm, it can be seen that the improved target detection model + DeepSort multi-target tracking model provided in this application is significantly better than the performance of the YOLOv5-Deepsort model in accurately tracking vehicles.
[0064] The present application also provides a vehicle detection and tracking device, such as Fig.14 As shown, the device specifically includes: The target detection model acquisition module 10 is used to obtain a trained target detection model; the target detection model includes a feature extraction network, a multi-scale feature fusion network and a target detection network, the feature fusion network includes a CBS module, four convolutional attention modules and a spatial pyramid pooling module connected in series along the forward propagation direction, and each convolutional attention module includes a first phantom convolution submodule and a C3GhostV2 submodule connected in series; The feature extraction module 20 is used to input each frame of the image in the video to be detected into the feature extraction network, and obtain the first feature map, the second feature map and the third feature map based on the output of the second convolutional attention module, the third convolutional attention module and the spatial pyramid pooling module; wherein the step of extracting features from the feature map by the C3GhostV2 submodule includes: Input the feature map into the first CBS unit and the second CBS unit respectively, and output the first intermediate feature and the second intermediate feature; Input the first intermediate feature into the long-distance attention mechanism enhancement unit and output the third intermediate feature; Inputting the second intermediate feature and the third intermediate feature into a feature fusion unit, and outputting a fourth intermediate feature; Input the fourth intermediate feature into the third CBS unit, and use the output of the third CBS unit as the output of the C3GhostV2 submodule; A feature fusion module 30, used to input the first feature map, the second feature map and the third feature map into a multi-scale feature fusion network, and output a target feature map; The target detection module 40 is used to input the target feature map into the target detection network and output the vehicle boundary box and position information; The target tracking module 50 is used to input the vehicle boundary boxes and position information in all frame images in the video to be detected into the trained DeepSort multi-target tracking model, and output the running track of each vehicle in the video to be detected.
[0065] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned vehicle detection and tracking method are implemented.
[0066] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A vehicle detection and tracking method, characterized in that: include: Obtain a trained target detection model; the target detection model includes a feature extraction network, a multi-scale feature fusion network and a target detection network, the feature fusion network includes a CBS module, four convolutional attention modules and a spatial pyramid pooling module connected in series along the forward propagation direction, and each of the convolutional attention modules includes a first phantom convolution submodule and a C3GhostV2 submodule connected in series; Input each frame of the image in the video to be detected into the feature extraction network, and obtain the first feature map, the second feature map and the third feature map based on the output of the second convolutional attention module, the third convolutional attention module and the spatial pyramid pooling module; wherein the step of extracting features from the feature map by the C3GhostV2 submodule includes: Inputting the feature map into a first CBS unit and a second CBS unit respectively, and outputting a first intermediate feature and a second intermediate feature; Input the first intermediate feature into the long-distance attention mechanism enhancement unit and output the third intermediate feature; Inputting the second intermediate feature and the third intermediate feature into a feature fusion unit, and outputting a fourth intermediate feature; Input the fourth intermediate feature into the third CBS unit, and use the output of the third CBS unit as the output of the C3GhostV2 submodule; Inputting the first feature map, the second feature map and the third feature map into the multi-scale feature fusion network, and outputting a target feature map; Input the target feature map into the target detection network, and output the vehicle boundary box and position information; The vehicle boundary boxes and position information in all frame images in the video to be detected are input into the trained DeepSort multi-target tracking model, and the running tracks of each vehicle in the video to be detected are output.
2. The vehicle detection and tracking method according to claim 1, characterized in that: The training process of the target detection model includes: Obtain a training set of images to be detected; Inputting an image in the training set of images to be detected into the object detection model, and outputting a predicted vehicle bounding box in the image; Constructing a width-height difference minimization loss function based on the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box, the Euclidean distance between the center point of the predicted vehicle bounding box and the center point of the real vehicle bounding box, and the diagonal length, width, and height of the minimum circumscribed rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; Constructing a target detection loss function based on the width-height difference minimization loss function and the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box; The target detection model is trained using images in the to-be-detected image training set until the value of the target detection loss function is minimized, thereby obtaining a trained target detection model.
3. The vehicle tracking detection method according to claim 2, characterized in that: The calculation formula of the intersection-over-union ratio of the predicted vehicle bounding box and the real vehicle bounding box is: , in, Represents the intersection-over-union ratio of the predicted vehicle bounding box and the actual vehicle bounding box; Represents the predicted vehicle bounding box; represents the real vehicle bounding box; The width-height difference minimization loss function is expressed as: , in, Represents the loss function that minimizes the difference between width and height; express loss; Indicates distance loss; represents the edge length loss; represents the square of the Euclidean distance between the center point of the predicted vehicle bounding box and the center point of the true vehicle bounding box; Represents the diagonal length of the minimum bounding rectangle covering the predicted vehicle bounding box and the true vehicle bounding box; Represents the square of the difference between the width of the predicted vehicle bounding box and the width of the actual vehicle bounding box; Represents the width of the minimum bounding rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; Represents the square of the difference between the height of the predicted vehicle bounding box and the height of the actual vehicle bounding box; Represents the height of the minimum bounding rectangle covering the predicted vehicle bounding box and the real vehicle bounding box; The target detection loss function is expressed as: , in, represents the target detection loss function; Represents a hyperparameter used to control the curvature of the curve.
4. The vehicle detection and tracking method according to claim 1, characterized in that: The multi-scale feature fusion network includes a bottom-up feature fusion module, a top-down feature fusion module and a convolution module; The bottom-up feature fusion module includes a second phantom convolution submodule, a first upsampling submodule, a first feature fusion submodule, a first C3 submodule, a third phantom convolution submodule, a second upsampling submodule and a second feature fusion submodule which are sequentially connected in series along the forward propagation direction; The top-down feature fusion module includes a second C3 submodule, a fourth phantom convolution submodule, a third feature fusion submodule, a third C3 submodule, a fifth phantom convolution submodule, a fourth feature fusion submodule and a fourth C3 submodule connected in series in the forward propagation direction; The convolution module includes a sixth phantom convolution submodule, a seventh phantom convolution submodule and an eighth phantom convolution submodule.
5. The vehicle detection and tracking method according to claim 4, characterized in that: Inputting the first feature map, the second feature map, and the third feature map into the multi-scale feature fusion network, and outputting a target feature map includes: Inputting the first feature map into the second feature fusion submodule in the bottom-up feature fusion module; inputting the second feature map into the second feature fusion submodule in the bottom-up feature fusion module; inputting the third feature map into the second phantom convolution submodule in the bottom-up feature fusion module; Input the feature map output by the second phantom convolution submodule into the fourth feature fusion submodule in the top-down feature fusion module; input the feature map output by the third phantom convolution submodule into the third feature fusion submodule in the top-down feature fusion module; input the feature map output by the second feature fusion submodule into the second C3 submodule in the top-down feature fusion module; The feature map output by the second C3 submodule is input into the sixth phantom convolution submodule to output a first target feature map; the feature map output by the third C3 submodule is input into the seventh phantom convolution submodule to output a second target feature map; the feature map output by the fourth C3 submodule is input into the eighth phantom convolution submodule to output a third target feature map.
6. The vehicle detection and tracking method according to claim 5, characterized in that: The object detection network includes a first detection head, a second detection head and a third detection head.
7. The vehicle detection and tracking method according to claim 6, characterized in that: Inputting the target feature map into the target detection network, outputting the vehicle bounding box and position information includes: Inputting the first target feature map into the first detection head, outputting the coordinates of the first predicted bounding box, the confidence that the first predicted bounding box is a vehicle bounding box, and the probability distribution that the first predicted bounding box belongs to each category bounding box; Inputting the second target feature map into the second detection head, outputting the coordinates of the second predicted bounding box, the confidence that the second predicted bounding box is a vehicle bounding box, and the probability distribution that the second predicted bounding box belongs to each category bounding box; The third target feature map is input into the third detection head, and the coordinates of the third predicted bounding box, the confidence that the third predicted bounding box is a vehicle bounding box, and the probability distribution that the third predicted bounding box belongs to each category bounding box are output.
8. The vehicle detection and tracking method according to claim 1, characterized in that: The feature extraction network in the DeepSort multi-target tracking model is ShuffleNetV2.
9. A vehicle detection and tracking device, characterized in that: include: A target detection model acquisition module is used to acquire a trained target detection model; the target detection model includes a feature extraction network, a multi-scale feature fusion network and a target detection network, the feature fusion network includes a CBS module, four convolutional attention modules and a spatial pyramid pooling module connected in series in the forward propagation direction, and each of the convolutional attention modules includes a first phantom convolution submodule and a C3GhostV2 submodule connected in series; The feature extraction module is used to input each frame of the video to be detected into the feature extraction network, and obtain the first feature map, the second feature map and the third feature map based on the output of the second convolutional attention module, the third convolutional attention module and the spatial pyramid pooling module; wherein the step of extracting features from the feature map by the C3GhostV2 submodule includes: Inputting the feature map into a first CBS unit and a second CBS unit respectively, and outputting a first intermediate feature and a second intermediate feature; Input the first intermediate feature into the long-distance attention mechanism enhancement unit and output the third intermediate feature; Inputting the second intermediate feature and the third intermediate feature into a feature fusion unit, and outputting a fourth intermediate feature; Input the fourth intermediate feature into the third CBS unit, and use the output of the third CBS unit as the output of the C3GhostV2 submodule; A feature fusion module, used for inputting the first feature map, the second feature map and the third feature map into the multi-scale feature fusion network, and outputting a target feature map; A target detection module, used to input the target feature map into the target detection network and output a vehicle boundary box and position information; The target tracking module is used to input the vehicle boundary boxes and position information in all frame images in the video to be detected into the trained DeepSort multi-target tracking model, and output the running trajectory of each vehicle in the video to be detected.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the vehicle detection and tracking method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Unmanned vehicle carried camera target detection method based on YOLOv5
CN114548363A
High-speed vehicle tracking speed measurement method under weak light condition
CN116935335A
Target tracking method and device and storage medium
CN117152205A
Road target detection method based on YOLOv5s
CN118155172A
Cited By
Target tracking method based on spatial conversion network and convolutional network
CN120219442A
Object tracking method based on spatial transformer network and convolutional network
CN120219442B
Bus passenger getting-on and getting-off identification and tracking counting method, equipment and medium
CN120932304A