Lane-level flow detection and prediction method, electronic equipment and storage medium
By combining YOLOv5 and DeepSort models with a spatiotemporal attention mechanism for lane-level traffic flow detection and prediction, the problems of large detection errors and high computational resource consumption in existing technologies are solved, achieving efficient and accurate traffic flow monitoring and emergency prediction, and reducing operation and maintenance costs.
Patent Information
- Application Number
- CN202511307942.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-09-15
AI Technical Summary
Existing traffic flow monitoring methods suffer from large detection errors, high computational resource consumption, and are not suitable for real-time scenarios in complex environments, making them unsuitable for large-scale deployment.
Lane video analysis is performed using YOLOv5 object detection neural network and DeepSort feature extraction model. Lane-level traffic flow detection and prediction are combined with spatiotemporal attention mechanism to automatically generate vehicle polygon configuration areas and adjust and maintain them using multi-view data from roadside monitoring cameras.
It improves the efficiency and accuracy of lane-level traffic flow detection and prediction, reduces operation and maintenance costs, and can adapt to complex environments and predict the traffic impact of emergencies.
Smart Images

Figure CN120808290A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of intelligent traffic management, and particularly relates to a lane-level traffic detection and prediction method, an electronic device and a storage medium. BACKGROUND
[0002] With the continuous acceleration of urbanization, traffic flow monitoring has become a key demand in the field of urban planning and intelligent transportation. Existing traffic flow monitoring methods are mostly based on sensors, cameras or radars, etc. However, these methods have certain limitations in terms of cost, maintenance and accuracy. For example, the method based on ultrasonic, millimeter wave radar and other sensing devices has problems such as complex engineering, high cost and small amount of information obtained. The method through roadside monitoring cameras can obtain rich traffic information, including vehicle type, vehicle position, vehicle flow, vehicle density and vehicle speed, etc. However, the existing video traffic flow detection method is limited by factors such as device layout, environmental changes and data noise, and needs to rely on professional personnel to manually configure detection virtual lines or polygonal areas. In addition, due to the problems of occlusion and movement of monitoring cameras, it is necessary to regularly maintain the roadside monitoring cameras. The existing method has a large detection error in complex environments and cannot be deployed on a large scale.
[0003] The invention patent with application number 201410826965.6 and invention name "video traffic flow detection method and device" discloses a video traffic flow detection method based on background difference. The method obtains road traffic video information of a preset detection area; extracts images frame by frame from the obtained road traffic video information to obtain gray images and gray background images under no-vehicle conditions; obtains a background difference image; judges whether there is a vehicle contour in the background difference image. If yes, the vehicle contour is counted. Otherwise, the background difference image is segmented. For the partial information of the background difference image segmented into each lane, it is judged whether there is a vehicle contour that meets the preset rule. If yes, the vehicle contours that meet the preset rule in different lanes are counted respectively. However, when judging whether there is a vehicle contour that meets the preset rule, the method may be affected by the preset rule setting. If the preset rule is not comprehensive or accurate enough, it may lead to missed detection or false detection. In the case of complex road traffic and dense traffic flow, the background difference method may have a high false detection rate. Because when the traffic flow is large and the vehicles are dense, the background difference image may contain a large amount of non-vehicle changes. In addition, the steps of extracting images frame by frame, performing background difference, segmentation and counting, etc. consume a large amount of computing resources, which may lead to slow running speed of the method and make it not suitable for real-time scenarios.
[0004] Therefore, there is an urgent need for a full-automatic high-precision traffic flow detection method that can adapt to multi-view and complex environment of monitoring cameras. SUMMARY
[0005] The problem to be solved by the present application is to improve the efficiency and accuracy of lane-level traffic detection and prediction, and a lane-level traffic detection and prediction method, an electronic device and a storage medium are proposed.
[0006] To achieve the above-mentioned purpose, the present application realizes the following technical scheme:
[0007] A lane-level traffic detection and prediction method, comprising the following steps:
[0008] S1. Using a roadside monitoring camera to collect lane video;
[0009] S2. Input the collected lane video into a detection and tracking module, and the detection and tracking module performs frame-by-frame analysis on the lane video based on a YOLOv5 target detection neural network and a DeepSort feature extraction model to obtain detection and tracking results of the traffic vehicles, including tracking id, type, position and confidence data;
[0010] S3. Based on the detection and tracking results of the traffic vehicles obtained in step S2, it is judged whether to automatically generate a vehicle polygon configuration area, and if yes, step S5 is performed, and if no, step S4 is performed;
[0011] S4. A region automatic generation method of vehicle trajectory is constructed to generate a vehicle polygon configuration area for the detection and tracking results of the traffic vehicles obtained in step S2, and to calculate lane traffic related data of the vehicle trajectory in the vehicle polygon configuration area;
[0012] S5. Based on the lane traffic related data of the vehicle trajectory in the vehicle polygon configuration area obtained in step S4, a time and space dependent relationship is jointly modeled by combining a spatio-temporal attention mechanism to describe the relationship between time and traffic flow in a single lane for lane-level traffic prediction.
[0013] Further, the YOLOv5 target detection neural network and the DeepSort feature extraction model in step S2 are adjusted using a multi-view dataset of a roadside monitoring camera.
[0014] Further, the judgment basis of step S3 is as follows:
[0015] S3.1. If it is the first time to process offline video or online video of a point, a tracking trajectory set with a time length of 5 minutes is intercepted, if the number of trajectories is too small, the interception is continued, then the region automatic generation of step S4 is performed, otherwise the lane-level traffic prediction of step S5 is entered;
[0016] S3.2. For a roadside traffic camera that is blocked or a monitoring camera that moves, the region automatic generation of step S4 is performed again, otherwise the lane-level traffic prediction of step S5 is entered.
[0017] Further, the specific implementation method of step S4 includes the following steps:
[0018] S4.1. Read the vehicle trajectory data based on the detection and tracking results of the traffic vehicles obtained in step S2, perform outlier detection on the vehicle trajectory, perform unsupervised abnormal trajectory point detection using a local outlier factor algorithm, filter the outliers, and obtain filtered vehicle trajectory data;
[0019] S4.2. Process and screen the filtered vehicle trajectory data, first obtain the midpoint coordinates of each trajectory, then scale the midpoint coordinates according to a scaling factor to obtain a scaled circumscribed rectangle range, and then classify the vehicle trajectory data in the circumscribed rectangle range according to the trajectory direction slope to obtain processed vehicle trajectory data;
[0020] S4.3. Fit and cluster the processed vehicle trajectory data obtained in step S4.2, calculate the slope by fitting the trajectory points through ridge regression, and then perform trajectory direction clustering using a kernel density estimation algorithm to obtain vehicle trajectory data with confirmed direction;
[0021] S4.4. Perform cluster analysis on the vehicle trajectory data with confirmed direction obtained in step S4.3 to determine the lane to which the trajectory belongs; use DBSCAN clustering to judge the formed trajectory cluster, mark the lane corresponding to the cluster, and respectively count the number of trajectories of each label to calculate the lane flow.
[0022] Further, the specific implementation method of step S5 includes the following steps:
[0023] S5.1. For the lane flow related data of the vehicle trajectory in the vehicle polygon configuration area obtained in step S4, construct a dynamic space-time graph edge weight calculation method, and the expression is:
[0024]
[0025] wherein, is the edge weight of lane i to lane j at time t, is the number of vehicles that change lanes from lane i to lane j in the time window, is the average speed of lane i at time t, are the first and second hyperparameters, respectively; is a random factor, is the average speed of lane j at time t;
[0026] S5.2. Constructing the spatio-temporal attention mechanism to jointly model the time and spatial dependence, and describe the relationship between time and traffic flow in a single lane;
[0027] S5.2.1. Define the spatial attention mechanism to capture the correlation between lanes, and the expression is:
[0028]
[0029] wherein, is the lane is the correlation strength between lane at time is the feature vector of lane at time , including flow, speed, and signal light status; is the query matrix of the kth attention head, is the key matrix of the kth attention head, is the normalized exponential function, is the model dimension;
[0030] The spatial attention mechanism captures the flow correlation between lanes through the attention mechanism;
[0031] S5.2.2. Based on the time attention mechanism, construct the time attention coefficient to capture the importance of historical time, and the expression is:
[0032]
[0033] wherein, is the time attention coefficient between lane at time and historical time is the model parameter matrix; the time attention coefficient represents the similarity between the current time and the historical time features;
[0034] S5.2.3. Construct the lane spatio-temporal attention fusion mechanism to form a joint modeling of spatio-temporal features, and the modeling definition is as follows:
[0035]
[0036] wherein, is the model hidden layer parameter, is the adjacent lane set of lane is the value matrix of the kth attention head; is the number of attention heads;
[0037] The spatio-temporal attention fusion mechanism fuses the time features and the space features to form a spatio-temporal attention network;
[0038] S5.3. Combining the dynamic spatio-temporal graph edge weight obtained in step S5.1 with the lane spatio-temporal attention fusion mechanism, training and prediction of the lane-level traffic are performed.
[0039] An electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the steps of the lane-level traffic detection and prediction method when executing the computer program.
[0040] A computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the lane-level traffic detection and prediction method.
[0041] The beneficial effects of the present application are:
[0042] The lane-level traffic detection and prediction method directly uses urban monitoring video data without the need to install any equipment on site, thereby saving a large amount of cost.
[0043] The lane-level traffic detection and prediction method proposes a method for automatically generating a region, which is directly applied to cameras with different perspectives and different positions, and is periodically automatically generated and maintained, thereby reducing operation and maintenance costs and being conducive to large-scale deployment and application.
[0044] The lane-level traffic detection and prediction method is based on a lane-level spatio-temporal attention mechanism, can consider the influence of lane changing of vehicles, and can discover traffic problems that may be caused by sudden events such as bad weather and traffic accidents in advance. BRIEF DESCRIPTION OF DRAWINGS
[0045] Figure 1 The lane-level traffic detection and prediction method is based on a lane-level spatio-temporal attention mechanism, can consider the influence of lane changing of vehicles, and can discover traffic problems that may be caused by sudden events such as bad weather and traffic accidents in advance.
[0046] Figure 2 The spatio-temporal attention mechanism jointly models a time and space dependency relationship structure diagram. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in combination with the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application, that is, the described specific embodiments are only a part of the embodiments of the present application, but not all the specific embodiments. The components of the specific embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations, and the present application can also have other embodiments.
[0048] Therefore, the following detailed description of the specific embodiments of the application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected specific embodiments of the application. Based on the specific embodiments of the application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the application.
[0049] In order to further understand the invention content, characteristics and effects of the present application, the following specific embodiments are exemplified, and the accompanying drawings are Figure 1 and the accompanying drawings Figure 2 The detailed description is as follows:
[0050] Example 1
[0051] A lane-level traffic detection and prediction method, comprising the following steps:
[0052] S1. Collect lane video using roadside monitoring camera;
[0053] S2. Input the collected lane video into the detection and tracking module, and the detection and tracking module performs frame-by-frame analysis on the lane video based on the YOLOv5 target detection neural network and the DeepSort feature extraction model to obtain the detection and tracking results of the traffic vehicles, including tracking id, type, position and confidence data;
[0054] Further, the YOLOv5 target detection neural network and the DeepSort feature extraction model in step S2 are adjusted using the multi-view data set of the roadside monitoring camera.
[0055] S3. Based on the detection and tracking results of the traffic vehicles obtained in step S2, determine whether to automatically generate a vehicle polygon configuration area, if yes, proceed to step S5, if no, proceed to step S4;
[0056] Further, the judgment basis of step S3 is as follows:
[0057] S3.1. If it is the first time to process the offline video or online video of the point, the tracking trajectory set of 5 minutes is intercepted, if the number of trajectories is too small, continue to intercept; then proceed to step S4 of automatic region generation, otherwise proceed to step S5 of lane-level traffic prediction;
[0058] S3.2. For the roadside traffic camera or the monitoring camera that moves, the automatic region generation of step S4 is performed again, otherwise the lane-level traffic prediction of step S5 is entered.
[0059] S4. Constructing a regional automatic generation method of vehicle trajectory, generating a vehicle polygon configuration region according to the detection and tracking result of the traffic vehicle obtained in step S2, and calculating lane flow related data of the vehicle trajectory in the vehicle polygon configuration region;
[0060] Further, the specific implementation method of step S4 includes the following steps:
[0061] S4.1. Reading vehicle trajectory data based on the detection and tracking result of the traffic vehicle obtained in step S2, performing outlier detection on the vehicle trajectory, performing unsupervised abnormal trajectory point detection using a local outlier factor algorithm, filtering outliers, and obtaining filtered vehicle trajectory data;
[0062] Local outlier factor Representative point Neighborhood The average of the ratio of the local reachable density of other points in the neighborhood of point to the local reachable density of point
[0063]
[0064] wherein, is the kth local reachable density of point , which represents the average reachable distance from all points in the kth neighborhood of point to point , and is the range of the neighborhood, is the kth local reachable density of point , is the kth neighborhood of point ; is the kth neighborhood of point ;
[0065] is defined as:
[0066]
[0067] wherein, is the kth reachable distance from point to point , which is expressed as the larger one of the kth distance of point and the distance from point to point :
[0068] S4.2. Process and screen the filtered vehicle trajectory data, first obtain the midpoint coordinates of each trajectory, then scale the midpoint coordinates according to the scaling coefficient to obtain the scaled circumscribed rectangle range, and then classify the vehicle trajectory data in the circumscribed rectangle range according to the trajectory direction slope to obtain the processed vehicle trajectory data;
[0069] Further, the default scaling coefficient is 0.8; and the processed vehicle trajectory data is forward and reverse vehicle trajectory data.
[0070] S4.3. Fit and cluster the processed vehicle trajectory data obtained in step S4.2, calculate the slope by fitting the trajectory points through ridge regression, and then perform trajectory direction clustering using the kernel density estimation algorithm to obtain the vehicle trajectory data with confirmed direction.
[0071] The kernel density estimation algorithm is to place a kernel function near each vehicle trajectory point, then perform weighted average estimation of the probability density by the value of the kernel function, extract the main direction of the vehicle trajectory, determine whether the vehicle trajectory is forward or reverse according to the included angle between the vehicle trajectory direction vector obtained by clustering and the current vehicle trajectory vector, and divide according to the position of the vehicle trajectory point in the main direction of the trajectory.
[0072] The method for estimating the vehicle trajectory by ridge regression is:
[0073]
[0074] wherein, is the ridge regression loss function; is the trajectory point position; is the trajectory estimated position; is the regularization weight; is the regularization variable; i is the lane number; n is the total length of the trajectory sequence.
[0075] The calculation formula of the probability density estimator of the kernel density estimation algorithm is:
[0076]
[0077] wherein, is the probability density distribution of the trajectory variable; is the i-th trajectory sample, h is the bandwidth parameter, K is the kernel function, and x is the trajectory variable.
[0078] Further, by adjusting the bandwidth parameter and the type of kernel function, the smoothness and shape of the estimated probability density curve can be affected.
[0079] S4.4. Cluster analysis is performed on the vehicle trajectory data of the confirmed direction obtained in step S4.3 to determine the lane to which the trajectory belongs; DBSCAN clustering is used to determine the trajectory cluster formed, mark the lane corresponding to the cluster, and respectively count the number of trajectories of each label to calculate the lane flow.
[0080] Further, after obtaining the adaptive analysis result of the traffic vehicle trajectory, the traffic flow data is saved. For real-time traffic flow data, statistics are performed once every 30 s, and written into the database; offline flow data is written into the corresponding offline video or text.
[0081] Further, the vehicle lane change frequency extracted from the video image of the monitoring camera is combined with the lane level traffic flow extracted in the previous part, and the multi-modal scene understanding ability of AI model numerical understanding and image understanding is combined to realize high-precision lane level flow prediction.
[0082] S5. Based on the lane flow related data of the vehicle trajectory in the vehicle polygon configuration area obtained in step S4, the time and space dependent relationship is jointly modeled by combining the spatio-temporal attention mechanism to describe the relationship between time and traffic flow in a single lane for lane level flow prediction.
[0083] Further, the specific implementation method of step S5 includes the following steps:
[0084] S5.1. The lane flow related data of the vehicle trajectory in the vehicle polygon configuration area obtained in step S4 is used to construct a dynamic spatio-temporal graph edge weight calculation method, and the expression is:
[0085]
[0086] wherein, is the edge weight of lane i to lane j at time t, is the number of vehicles that change lanes from lane i to lane j in the time window is the average speed of lane i at time t, is the average speed of lane j at time t, are the first and second hyperparameters, respectively; is a random factor, is the average speed of lane j at time t; The edge weight of the dynamic graph reflects the vehicle interaction intensity between lanes, and is combined with the vehicle lane change frequency and the lane speed difference; the initial setting is
[0087] The first term in the formula represents the lane change frequency feature: it captures the dynamic correlation between vehicles in the lanes, such as the enhanced interaction between the left-turn lane and the through lane during the green light period. The second term represents the speed difference feature: if the speed difference between adjacent lanes is large (such as congested lanes and unobstructed lanes), the vehicle is more likely to change lanes, and the weight increases accordingly.
[0088] S5.2. Build a spatiotemporal attention mechanism to jointly model temporal and spatial dependencies, describing the relationship between time and traffic flow in a single lane.
[0089] S5.2.1. Define the spatial attention mechanism to capture the correlation between lanes, expressed as:
[0090]
[0091] in, For lanes With lane At the moment The strength of association, For lanes At the moment The feature vector of , including flow, speed, and traffic light status; is the query matrix of the k-th attention head, is the key matrix of the kth attention head, is the normalized exponential function, is the model dimension;
[0092] The spatial attention mechanism captures the traffic correlation between lanes through the attention mechanism;
[0093] S5.2.2. Based on the temporal attention mechanism, construct a temporal attention coefficient to capture the importance of historical moments. The expression is:
[0094]
[0095] in, For lanes At the moment and historical moments The time attention coefficient, is the model parameter matrix; the temporal attention coefficient represents the similarity between the characteristics of the current moment and the historical moments;
[0096] S5.2.3. Construct a lane spatiotemporal attention fusion mechanism to form a joint spatiotemporal feature model. The model definition is as follows:
[0097]
[0098] in, is the model hidden layer parameter, for the lane set of adjacent lanes; for the i-th attention head value matrix of the i-th attention head; for the number of attention heads
[0099] The spatio-temporal attention fusion mechanism fuses the time features and the space features to form a spatio-temporal attention network.
[0100] S5.3. In combination with the dynamic spatio-temporal graph edge weight obtained in step S5.1 and the lane spatio-temporal attention fusion mechanism, training and prediction of lane-level traffic are performed.
[0101] Further, in combination with the dynamic spatio-temporal graph edge weight and the lane spatio-temporal attention mechanism, the model is trained; the model structure diagram is shown in Figure 2 ; after the training is completed, the weight is issued to each edge node for prediction, and the abnormal traffic conditions that may occur in the future are reported in real time.
[0102] The embodiment realizes direct use of urban monitoring video data without the need for on-site installation of any equipment, thereby saving a large amount of cost; a region automatic generation method is proposed, which is directly applied to cameras with different perspectives and different positions, is periodically automatically generated and maintained, reduces operation and maintenance cost, is conducive to large-scale deployment and application. The prediction method is based on a lane-level spatio-temporal attention mechanism, which can consider the influence of lane changing of vehicles and can discover traffic problems that may be caused by sudden events such as bad weather and traffic accidents in advance.
[0103] Embodiment 2:
[0104] An electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the lane-level traffic detection and prediction method of embodiment 1 when executing the computer program.
[0105] The computer device of the present application can be a device including a processor and a memory, such as a single-chip microcomputer including a central processing unit. Moreover, the processor is used to execute the computer program stored in the memory to implement the steps of the lane-level traffic detection and prediction method.
[0106] The processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0107] The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required by at least one function (such as a sound playing function, an image playing function, etc.), etc.; and the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state memory devices.
[0108] Embodiment 3:
[0109] A computer readable storage medium, having stored thereon a computer program, the computer program being executed by a processor to implement the lane-level traffic detection and prediction method of embodiment 1.
[0110] The computer readable storage medium of the present application can be any form of storage medium readable by the processor of the computer device, including but not limited to non-volatile memory, volatile memory, ferroelectric memory, etc., and the computer readable storage medium has stored thereon a computer program, when the processor of the computer device reads and executes the computer program stored in the memory, the steps of the modeling method of modifying the modeling data driven by the relationship based on the CREO software can be realized.
[0111] The computer program includes computer program code, which can be in the form of source code, object code, executable code, or some intermediate form. The computer-readable medium can include any entity or apparatus, tangible or
[0112] It should be noted that the relational terms herein, such as first and second, and the like, are used solely to distinguish one from another entity or action without necessarily requiring or implying any actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. The terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0113] Although the present application has been described with reference to specific implementations, it will be apparent to those skilled in the art that various modifications in form and details can be made therein without departing from the scope of the application. Specifically, the features of the various implementations disclosed herein can be combined with each other in any manner without structural conflict, and the combinations of these features are not exhaustively described in the present specification only for the purpose of saving space and resources. Therefore, the present application is not limited to the specific implementations disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. A lane-level traffic flow detection and prediction method, characterized in that: The steps include: S1. Use roadside surveillance cameras to collect lane video; S2. The captured lane video is fed into the detection and tracking module. This module analyzes the lane video frame by frame using the YOLOv5 object detection neural network and the DeepSort feature extraction model to generate vehicle detection and tracking results, including tracking ID, type, location, and confidence data. S3 based on the detection and tracking results of traffic vehicles obtained in step S2, it is determined whether the vehicle polygon configuration area is automatically generated, if it is determined to be yes, the process proceeds to step S5, otherwise it proceeds to step S4; S4 constructs a method for automatically generating vehicle trajectory regions, generating a vehicle polygonal configuration region for the detection and tracking results of traffic vehicles obtained in step S2, and calculating lane flow-related data of vehicle trajectories within the vehicle polygonal configuration region; S5. Based on the lane flow data of vehicle trajectories within the vehicle polygon configuration area obtained in step S4, the spatiotemporal attention mechanism is used to jointly model temporal and spatial dependencies, describing the relationship between time and traffic flow in a single lane and predicting lane-level traffic flow.
2. The lane-level traffic flow detection and prediction method according to claim 1, characterized in that: In step S2, the YOLOv5 target detection neural network and DeepSort feature extraction model are adjusted using the dataset from multiple viewpoints of the roadside surveillance camera.
3. The lane-level flow detection and prediction method according to claim 2, characterized in that: The judgment basis of step S3 is as follows: S3.
1. If this is the first time processing a point in offline or online video, extract a 5-minute set of tracking trajectories. If the number of trajectories is too small, continue extracting. Then proceed to step S4 for automatic region generation. Otherwise, proceed to step S5 for lane-level flow prediction. S3.
2. If the roadside traffic camera is blocked or moved, the automatic region generation in step S4 is repeated. Otherwise, the process proceeds to lane-level traffic flow prediction in step S5.
4. The lane-level flow detection and prediction method according to claim 3, characterized in that: The specific implementation method of step S4 includes the following steps: S4.
1. Read the vehicle trajectory data based on the detection and tracking results of the traffic vehicle obtained in step S2, perform outlier detection on the vehicle trajectory, perform unsupervised abnormal trajectory point detection using the local outlier factor algorithm, filter outliers, and obtain filtered vehicle trajectory data; S4.
2. Process and filter the filtered vehicle trajectory data. First, obtain the midpoint coordinates of each trajectory. Then, scale the midpoint coordinates by a scaling factor to obtain the scaled bounding rectangle. Then, classify the vehicle trajectory data within the bounding rectangle based on the trajectory direction slope to obtain the processed vehicle trajectory data. S4.
3. Fit and cluster the processed vehicle trajectory data obtained in step S4.
2. Use ridge regression to fit the trajectory points and calculate the slope. Then, use a kernel density estimation algorithm to cluster the trajectory directions to obtain vehicle trajectory data with confirmed directions. S4.
4. Perform cluster analysis on the vehicle trajectory data obtained in the confirmed direction in step S4.3 to determine the lane to which the trajectory belongs; Use DBSCAN clustering to determine the formed trajectory clusters, mark the lanes corresponding to the clusters, and count the number of trajectories for each label to estimate the lane flow.
5. The lane-level flow detection and prediction method according to claim 4, characterized in that: The specific implementation method of step S5 includes the following steps: S5.
1. Based on the lane flow data of vehicle trajectories within the vehicle polygon configuration area obtained in step S4, construct a dynamic spatiotemporal graph edge weight calculation method, expressed as: ; in, For the moment Lane To the driveway The edge weights of Time window The number of vehicles changing lanes from inner lane i to lane j, For lanes At the moment The average speed of are the first hyperparameter and the second hyperparameter respectively; is a random factor, For lane j at time average speed of vehicles; S5.
2. Build a spatiotemporal attention mechanism to jointly model temporal and spatial dependencies, describing the relationship between time and traffic flow in a single lane. S5.2.
1. Define the spatial attention mechanism to capture the correlation between lanes, expressed as: ; in, For lanes With lane At the moment The strength of association, For lanes At the moment The feature vector of , including flow, speed, and traffic light status; is the query matrix of the k-th attention head, is the key matrix of the kth attention head, is the normalized exponential function, is the model dimension; The spatial attention mechanism captures the traffic correlation between lanes through the attention mechanism; S5.2.
2. Based on the temporal attention mechanism, construct a temporal attention coefficient to capture the importance of historical moments. The expression is: ; in, For lanes At the moment and historical moments The time attention coefficient, is the model parameter matrix; the temporal attention coefficient represents the similarity between the characteristics of the current moment and the historical moments; S5.2.
3. Construct a lane spatiotemporal attention fusion mechanism to form a joint spatiotemporal feature model. The model definition is as follows: ; in, is the model hidden layer parameter, For lanes The set of adjacent lanes; For the The value matrix of the attention head; is the number of attention heads; The spatiotemporal attention fusion mechanism fuses temporal features and spatial features to form a spatiotemporal attention network; S5.
3. Combine the dynamic spatiotemporal graph edge weights obtained in step S5.1 with the lane spatiotemporal attention fusion mechanism to train and predict lane-level traffic flow.
6. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of a lane-level flow detection and prediction method as described in any one of claims 1 to 5 when executing the computer program.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the lane-level traffic flow detection and prediction method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Video traffic detection method and device
CN104504913B
Ground road lane-level traffic flow prediction method based on space-time attention mechanism
CN112926768A
Road traffic state prediction method and system based on multi-target tracking
CN117975734A
Adaptive network intrusion detection and response system based on deep learning
CN119341840A
Vehicle space-time trajectory similarity calculation method and device based on semantic information
CN120123787A