Road congestion early warning method and system based on vehicle image recognition and trajectory prediction
By deploying vehicle recognition devices at city entrances and exits and on major roads, and combining sliding window, DBSCAN, and DTW algorithms, a six-dimensional feature risk assessment function is constructed. This solves the problem that existing technologies cannot reflect real-time traffic dynamics and accurately predict the routes of out-of-town vehicles entering the city, thus achieving precise road congestion warnings and management.
Patent Information
- Application Number
- CN202510943405.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-10-28
AI Technical Summary
Existing methods for predicting road congestion cannot reflect real-time changes in traffic dynamics, especially during peak hours when they cannot accurately predict the routes of vehicles from other areas entering the city, making it difficult to achieve accurate road congestion warnings.
By deploying vehicle recognition devices at city entrances and exits and on major roads, using the HyperLPR3 model and OpenCV technology to extract license plate information, and combining the sliding window algorithm to calculate the net increase and trend indicators of vehicles entering the city, the DBSCAN algorithm is used to cluster the trajectories of vehicles from other places and the DTW algorithm is used to match the trajectories of local vehicles, and a six-dimensional feature risk assessment function is constructed to determine the congestion risk.
It enables accurate early warning of urban road congestion risks, reduces citizens' travel costs, improves the level of urban traffic management, and can quickly respond to changes in traffic flow and take into account the impact of multi-dimensional factors such as weather, road characteristics and the influx of vehicles from other places.
Smart Images

Figure CN120853380A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for early warning of urban road congestion, and more particularly to a method and system for early warning of road congestion based on vehicle image recognition and trajectory prediction. Background Technology
[0002] With the acceleration of urbanization and the continuous growth of motor vehicle ownership, urban traffic congestion has become an increasingly serious problem. Traffic congestion not only reduces travel efficiency and increases residents' travel time and costs, but also exacerbates environmental pollution and energy consumption. Therefore, accurately predicting road congestion and taking traffic management measures in advance is of great significance for improving urban traffic conditions. Currently, common methods for predicting road congestion mainly include those based on historical data statistical analysis, floating car data, and traffic sensor data. Methods based on historical data statistical analysis predict future traffic conditions by analyzing traffic flow data under similar time periods and weather conditions in the past. However, this method cannot reflect the dynamic changes in current traffic conditions in real time and has poor adaptability to unexpected situations. Methods based on floating car data use the driving data of floating vehicles such as taxis and buses to infer road congestion; however, their data coverage is limited, and their prediction accuracy is low in areas with fewer vehicles. Methods based on traffic sensor data rely on various sensors deployed on roads, such as geomagnetic sensors and radar sensors. Although they can acquire traffic flow and speed data in real time, the deployment and maintenance costs of these sensors are high, and there are data collection blind spots. Furthermore, most existing road congestion prediction technologies do not adequately consider the impact of the origin and routes of vehicles entering the city on urban road congestion. During peak hours, cities often face a large influx of vehicles from other areas, whose routes are unpredictable. Without accurate prediction of their trajectories and concentrated traffic sections, precise early warning of road congestion becomes difficult. Therefore, there is an urgent need for a road congestion prediction method that can comprehensively consider factors related to vehicles entering the city, improving prediction accuracy and real-time performance. Summary of the Invention
[0003] This application proposes a road congestion early warning method and system based on vehicle image recognition and trajectory prediction, aiming to more accurately realize early warning of urban road congestion risks, reduce the cost of citizens' travel, and improve the city's management level.
[0004] The technical solution adopted in the invention is: In a first aspect, the present invention proposes a road congestion early warning method based on vehicle image recognition and trajectory prediction, which includes the following steps: Step S1: Data extraction step. Vehicle recognition equipment is deployed at city entrance and exit checkpoints and main roads to collect vehicle data. The video stream is read using the HyperLPR3 model combined with OpenCV to extract license plate information and store it in the database. Step S2, the inbound trend analysis step, uses the sliding window algorithm to calculate the difference between the number of vehicles entering the city and the number of vehicles leaving the city within the time window, the net increase in inbound traffic and the trend index, and determines the upward trend of inbound traffic based on the rising trend index of continuous time windows. Step S3, Vehicle trajectory prediction step: For vehicle trajectory data with a home location outside the local area, clustering is performed using the DBSCAN algorithm and cluster centers are extracted. For vehicle trajectories with a home location in the local area, the Dynamic Time Warping (DTW) algorithm is used to match historical trajectories to predict the driving path. Step S4, Congestion Risk Assessment Step: Construct a six-dimensional feature risk assessment function that includes inbound trend factors, predicted traffic flow factors, historical congestion factors, local vehicle trajectory prediction factors, out-of-town vehicle trajectory factors, road segment characteristic factors, and weather condition factors. Generate a comprehensive risk score by weighted summation, and classify congestion risk levels based on thresholds.
[0005] Furthermore, in step S2, the calculation formulas for the net increase in inbound traffic and trend indicators are as follows: Net increase in inbound traffic: ΔC(T) = C in (T)−C out (T) Trend indicator: Trend(T) = ΔC(T) − ΔC(T − ΔT) where T is the time window, ΔT is the sliding step size, and C is the sliding step size. in (T) represents the number of vehicles entering the city within time window T, and C represents the number of vehicles entering the city within time window T. out (T) represents the number of vehicles leaving the city within the time window T.
[0006] Furthermore, the criteria for determining the upward trend of inbound traffic are as follows: the net increase in inbound traffic ∆C(T) in the current time window is >0; the trend indicator Trend(T) is >0; and the trend indicators for two consecutive time windows satisfy the following: Trend(T) > Trend(T−ΔT) and Trend(T−ΔT) > Trend(T−2ΔT).
[0007] Furthermore, in the vehicle trajectory prediction step, trajectory clustering based on the DBSCAN algorithm includes: Data preprocessing: The 3D trajectory data Ts is reduced to a 2D matrix F through a Reshape operation. Ts The formula is: F Ts =Reshape(Ts,−1,2); Cluster analysis: By using the neighborhood radius threshold eps and the minimum number of core points mins, trajectory points with achievable density are grouped into the same cluster, and the cluster label vector L is output. Cluster centroid calculation: The centroid of each cluster is calculated using the mean estimation method, and the formula is as follows: ,in, Let be the number of sample points within the i-th cluster. This represents the coordinate vector of the j-th trajectory point in the cluster.
[0008] Furthermore, the parameter tuning of the DBSCAN algorithm adopts a grid search combined with the silhouette coefficient evaluation method. The silhouette coefficient ranges from [-1, 1], and the closer the value is to 1, the better the clustering effect.
[0009] Furthermore, in the DTW-based path matching step, the current trajectory C is calculated. t With historical trajectory H t The distance formula is: D(C) t H t =DTW(C t H t ,d)=D(m,n); Where D(m, n) is the DTW distance between the two trajectories, which is obtained through a recursive formula, as follows: Recurrence formula: Where m and n represent the partial driving trajectory C that has been collected for the current vehicle. t And the vehicle driving trajectory H stored in the historical database t Length of matrix elements Let d represent the Euclidean distance between the i-th point of the current trajectory and the j-th point of the historical trajectory; The algorithm formula for d is as follows: d = , and These are the x and y coordinates of P2, respectively. and These are the x and y coordinates of P1, respectively; by As an initial condition, this formula means that the cumulative distance at the current position is equal to the current point distance plus the minimum cumulative distance of the first three possible paths, and finally D(m, n) is the DTW distance between the two trajectories.
[0010] Furthermore, in the congestion risk assessment step, the comprehensive risk scoring formula is as follows: ; Wherein, T is the inbound trend factor. 1. The inbound trend factor T satisfies the following: when ∆C (T) > 0 and the trend indicator rises for two consecutive time windows, T = 1; otherwise, T = 0. F is the predicted traffic factor, which is the hourly traffic flow of the target road segment predicted using a machine learning algorithm. H is the historical congestion factor, and the value of H ranges from 0 to 1; R is the local vehicle trajectory prediction factor. The DTW path matching technology is used to predict the paths of local vehicles entering the city, and the path overlap ratio rs for each road segment is calculated. , Let N be the number of predicted paths passing through road segment s, and N be the total number of predicted paths. Combining this with the road segment importance weights ωs, we obtain R. ; V represents the trajectory factor for vehicles from other regions, which calculates the frequency of occurrence of these vehicles on each road segment in the predicted trajectory. ,calculate: ×ωs; S is the road segment characteristic factor, which assigns weights to road segments based on factors such as road segment length, number of lanes, and whether it is a transportation hub. The value of S ranges from 0 to 1. W is the weather condition factor, which is assigned a value based on real-time weather: sunny day W=0, light rain W=0.2, moderate rain W=0.4, heavy rain and above W=0.6, snowy day or heavy fog W=0.8.
[0011] Furthermore, for key traffic arteries such as main roads and expressways, The value is assigned to 0.8 - 1.0; secondary arterial roads connecting important commercial areas and residential areas, The assigned value is 0.5 - 0.7; for other branch roads or non-core road sections, The value assigned is 0.1-0.4.
[0012] Furthermore, the congestion risk level is divided into four levels based on thresholds: Score < 30 indicates smooth traffic, 30 ≤ Score < 60 indicates localized slow traffic, 60 ≤ Score < 85 indicates regional congestion, and Score ≥ 85 indicates severe congestion.
[0013] Secondly, the present invention further proposes a system for performing the aforementioned road congestion early warning method, comprising: Data acquisition module: Vehicle recognition equipment configured at city entrance and exit checkpoints and main roads is used to collect vehicle data. The vehicle recognition equipment includes a video stream reading unit based on OpenCV and a HyperLPR3 license plate recognition unit. Data processing module: used to clean, deduplicatize and store the collected vehicle data, including a database unit; Inbound Trend Analysis Module: Integrates a sliding window algorithm to calculate the net increase in inbound traffic and trend indicators, and to determine that the inbound trend is rising; The trajectory prediction module includes a DBSCAN clustering unit and a DTW path matching unit. The DBSCAN clustering unit is used for dimensionality reduction and clustering of trajectories of vehicles from other regions and extracting cluster centers. The DTW path matching unit is used for matching local vehicle trajectories with historical trajectories. Risk assessment module: Constructs a six-dimensional feature risk assessment function, including calculation units for inbound trend factors, predicted traffic factors, historical congestion factors, local vehicle trajectory prediction factors, out-of-town vehicle trajectory factors, road segment characteristic factors, and weather condition factors, which are used to generate a comprehensive risk score and classify congestion levels. Communication module: Used to interface with the meteorological department's data interface to obtain real-time weather information and transmit data processed by each module.
[0014] This invention comprehensively covers key factors influencing road congestion by integrating multiple dimensions such as local and out-of-town vehicle trajectories, inbound trends, road characteristics, and weather. Compared to traditional assessment methods that rely on only one or a few factors, it can more accurately capture the sources of congestion risk. For example, it simultaneously considers the combined impact of concentrated influx of out-of-town vehicles during holidays and severe weather on traffic, avoiding omissions or misjudgments. Moreover, it uses real-time data and dynamic algorithms for inbound trend factors and predicted traffic flow factors, enabling rapid response to changes in traffic flow; the weather condition factor is integrated with meteorological data in real time, promptly reflecting the impact of weather on traffic. Furthermore, the weighting parameters can be adjusted according to changes in traffic characteristics at different seasons and times, ensuring the model maintains high prediction accuracy and adapts to the complex and ever-changing characteristics of urban traffic. Attached Figure Description
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1 This is a structural block diagram of the road congestion prediction system in this invention; Figure 2 This is a diagram illustrating the execution steps of the road congestion prediction system in this invention. Figure 3 This is a flowchart illustrating the operation of the road congestion prediction method in this invention. Detailed Implementation
[0017] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0018] This invention proposes a road congestion early warning method based on vehicle image recognition and trajectory prediction. This technical solution aims to collect vehicle information entering and exiting the city from checkpoints and vehicle data from major arterial roads, comprehensively analyze inbound vehicle trends and route predictions, and achieve early warning of road congestion risks for specific road sections. This invention covers key aspects such as data extraction, trend calculation, vehicle route prediction, and congestion risk assessment.
[0019] Specifically, the road congestion early warning method and system mainly includes the following steps, combined with appendix. Figures 1 to 3 As shown: This invention proposes a system for implementing the road congestion early warning method based on vehicle image recognition and trajectory prediction, such as... Figure 1 As shown, it includes: Data acquisition module: Vehicle recognition equipment configured at city entrance and exit checkpoints and main roads is used to collect vehicle data. The vehicle recognition equipment includes a video stream reading unit based on OpenCV and a HyperLPR3 license plate recognition unit. Data processing module: used to clean, deduplicatize and store the collected vehicle data, including a database unit; Inbound Trend Analysis Module: Integrates a sliding window algorithm to calculate the net increase in inbound traffic and trend indicators, and to determine that the inbound trend is rising; The trajectory prediction module includes a DBSCAN clustering unit and a DTW path matching unit. The DBSCAN clustering unit is used for dimensionality reduction and clustering of trajectories of vehicles from other regions and extracting cluster centers. The DTW path matching unit is used for matching local vehicle trajectories with historical trajectories. Risk assessment module: Constructs a six-dimensional feature risk assessment function, including calculation units for inbound trend factors, predicted traffic factors, historical congestion factors, local vehicle trajectory prediction factors, out-of-town vehicle trajectory factors, road segment characteristic factors, and weather condition factors, which are used to generate a comprehensive risk score and classify congestion levels. Communication module: Used to interface with the meteorological department's data interface to obtain real-time weather information and transmit data processed by each module.
[0020] Furthermore, based on the traffic information maps of urban entrances and exits and the vehicle operation data obtained by the vehicle capture event data analysis and management module within a certain period, the total number of vehicles entering the city, the total number of vehicles passing through each city's entrances and exits, and the urban vehicle growth rate within a certain period can be calculated through various indicators by the vehicle capture event data analysis and management module. In this way, the traffic flow and congestion index of some entrance and exit traffic arteries within a certain period, the traffic flow prediction index of urban traffic arteries in the future period can be calculated, and urban traffic pressure warnings can be issued through visualization and event push.
[0021] (ii) Road congestion prediction system Step S1: Deploy vehicle recognition equipment at city entrance and exit checkpoints to collect vehicle data for entering and exiting the city.
[0022] Combined with appendix Figure 2 , 3 As shown, the road congestion early warning method proposed in this invention mainly includes: In step S1, regarding data extraction, the main approach involves deploying license plate recognition equipment at key checkpoints such as urban highways, national roads, and county roads. This involves reading video streams using OpenCV and performing license plate recognition using HyperLPR3. HyperLPR3 is primarily used to extract license plate information from images or video streams, quickly and accurately identifying key attributes such as license plate number and color. Based on deep learning technology, HyperLPR3 constructs a model architecture including components such as convolutional neural networks (CNNs). The CNN learns and trains on a large amount of license plate image data to extract feature information from the license plates, thereby achieving segmentation and recognition of license plate characters. For example, the model learns features such as the shape and stroke structure of license plate characters to accurately distinguish different characters. During training, using a labeled license plate image dataset, the model parameters are continuously adjusted through backpropagation to optimize the model's ability to recognize license plates, thereby improving the accuracy and speed of recognition.
[0023] The license plate recognition result is represented by the following formula: Results = HyperLPR3(Frame), where Frame represents a single frame of image data in the video stream. The license plate recognition model performs feature extraction, character segmentation, and recognition operations, ultimately outputting a set of recognition results. This set includes key attributes such as the license plate character sequence, recognition confidence score, and license plate color encoding. These attributes accurately characterize the vehicle's identity information, providing a crucial data foundation for subsequent vehicle location determination and traffic flow analysis. Through this license plate recognition model and formula calculation, license plate information can be extracted quickly and accurately from large amounts of video stream data.
[0024] Regarding vehicle location determination: First, frame data from the video stream is continuously captured via the OpenCV interface. This data is then processed by the HyperLPR3 model to generate structured license plate recognition results. Next, based on predefined license plate location discrimination rules, the identified license plate numbers are classified by regional attributes. Vehicle feature information, timestamps, and monitoring point geographic coordinates are simultaneously stored in the database. Simultaneously, monitoring equipment deployed at intersections of major urban roads collects vehicle data, providing multi-dimensional data support for subsequent traffic flow analysis and road network situation assessment. After initial cleaning and verification, the collected data is transmitted to the data processing center. Here, deduplication and outlier handling are performed to ensure data accuracy and validity, providing a reliable data foundation for subsequent key steps such as urban entry trend calculation and vehicle route prediction.
[0025] Step S2: Analysis of vehicle entry and exit trends in the city; In step S2, a sliding window algorithm is used to count the number of vehicles entering and leaving the city within a set time window, and then calculate the net increase in inbound traffic and trend indicators to determine the inbound trend. The specific algorithm formula is as follows: Let the time window be T, the sliding step of the time window be ∆T, and the number of vehicles entering the city within the time window T be C. in (T), the number of vehicles leaving the city is C out (T).
[0026] Net increase in inbound traffic: ∆C(T)=C in (T)-C out (T); Trend indicator: Trend(T) = ∆C(T) - ∆C(T - ∆T); The criteria for determining an upward trend are as follows: Within each time window T, the number of vehicles entering the city, C, is counted. in (T) and the number of vehicles leaving the city C out The difference between the two is the net increase in inbound traffic ∆C(T). The trend indicator Trend(T) represents the difference between the net increase in inbound traffic in the current time window and the net increase in inbound traffic in the previous time window (T-∆T), and is used to measure the changing trend of the net increase in inbound traffic. When the net increase in inbound traffic in the current time window is greater than 0, the trend indicator is greater than 0, and the trend indicator has been rising for two consecutive time windows (i.e., Trend(T) > Trend(T-∆T), and Trend(T-∆T) > Trend(T-2∆T), then the trend of inbound traffic is determined to be upward.
[0027] Step S3: Deploy vehicle recognition equipment at major traffic intersections in the city, collect vehicle data information at each intersection, and create vehicle route trajectory profiles and predictions. In step S3, the processing is mainly based on the vehicle trajectory data of vehicles whose origin is outside the local area. The DBSCAN algorithm is used to cluster and extract the cluster centers, which provides a basis for subsequent path matching.
[0028] In DBSCAN-based trajectory clustering: Vehicle trajectory data is processed, clustered using the DBSCAN algorithm, and cluster centers are extracted to provide a foundation for subsequent path matching. In intelligent transportation systems, vehicle trajectory data exhibits high-dimensional, dynamic, and complex characteristics, making it difficult for traditional clustering methods to effectively capture the spatial distribution features of trajectory data. The density-based spatial clustering application of the DBSCAN algorithm, with its characteristics of not requiring a pre-defined number of clusters and strong robustness to noisy data, has become an ideal choice for trajectory analysis. The specific implementation process is as follows.
[0029] Step S3.1: Data preprocessing and dimensionality reduction.
[0030] Assume the set of vehicle trajectories is Ts, and its data dimensions include {n} s n p ,2},n s n represents the number of samples, where each sample represents a complete vehicle trajectory; p The first dimension represents the number of data collection points at different time points, and the second dimension represents the number of time series points recorded in each trajectory, used to characterize the vehicle's state at different times. The final dimension value 2 represents the two-dimensional coordinates, corresponding to the vehicle's x-axis and y-axis position information on the planar map, respectively. Each sample represents a vehicle trajectory, containing multiple time series two-dimensional coordinate points. To adapt to the input requirements of the DBSCAN algorithm, the 3D trajectory data needs to be dimensionality reduced through a matrix reshape operation, the transformation formula of which is as follows: F Ts =Reshape(Ts, -1, 2), where Ts represents the original 3D vehicle trajectory data tensor, F Ts This represents the two-dimensional matrix data after the dimensionality reduction operation. The parameter -1 is a special marker for automatically inferring dimensions. Based on the total amount of original data and the specified two-column dimension, it automatically calculates the appropriate number of rows, ensuring no information is lost during dimensionality reduction. This allows all coordinate points in each trajectory to be arranged sequentially in the rows of the new matrix, with each row corresponding to a vehicle position coordinate. Every two columns constitute a complete two-dimensional coordinate information, ultimately meeting the input format requirements of the DBSCAN algorithm and laying the foundation for subsequent density-based trajectory clustering analysis.
[0031] Step S3.2, DBSCAN cluster analysis; The DBSCAN algorithm, as a density-based clustering method, defines clustering rules through two key parameters: eps and min. s .
[0032] eps, or neighborhood radius threshold, is a parameter used to define the neighborhood range of a sample point, that is, a hyperspherical region with a radius of eps centered on a sample point in space. eps determines the "distance tolerance" between data points; a value that is too small will lead to overly dispersed clustering, while a value that is too large may merge clusters that should be separated.
[0033] min s This refers to the minimum number of samples required to identify a core point. This threshold is used to determine the minimum number of samples that need to be included in the neighborhood of eps. s The setting of the value directly affects the strictness of clustering. A larger value will make the determination of core points more stringent, tending to generate fewer and larger clusters, while a smaller value may generate more fragmented clusters. In step S3.2, the main process involves traversing all sample points. If a sample point contains at least min within the neighborhood of eps, then... s If a point is found, it is determined to be a core point; points that are directly or indirectly density-reachable from the core point are grouped into the same cluster, and isolated points that are not density-reachable are marked as noise points.
[0034] Finally, the clustering results are output as a label vector: L=DBSCAN(F Ts ,eps,min s In the actual parameter tuning process, a grid search combined with the silhouette coefficient evaluation method can be used. The grid search systematically traverses all possible parameter combinations within a preset parameter value range; the silhouette coefficient serves as an evaluation index, comprehensively measuring the clustering cohesion and separation, with a value range of [−1, 1], where a value closer to 1 indicates a better clustering effect. This method can automatically find the optimal eps and min values. s Parameter combinations can improve the accuracy and reliability of clustering results.
[0035] Step S3.3: Cluster center calculation. The cluster center reflects the spatial clustering characteristics of vehicle trajectories.
[0036] The centroid of each cluster is calculated using the mean estimation method: ,in, Let be the number of sample points within the i-th cluster. This represents the coordinate vector of the j-th trajectory point in the cluster. By calculating the cluster centers, massive vehicle trajectories can be abstracted into representative path patterns, providing key input features for subsequent path matching and congestion prediction models. In summary, this process transforms the original vehicle trajectory data Ts into a two-dimensional point set F suitable for processing by the DBSCAN algorithm in the context of urban traffic big data. Ts By setting reasonable eps and min sThe algorithm automatically identifies vehicle trajectory clusters with similar travel paths and assigns a cluster label L to each point. Finally, the cluster centers are calculated based on the mean estimation method. This method not only effectively extracts the core features of trajectory data but also helps identify road hotspots by analyzing the density distribution differences between clusters, providing data support for dynamic traffic flow prediction. Taking a city area with 1000 (collected within the last two days) trajectory data points of out-of-town vehicles as an example, if the DBSCAN algorithm clusters these data into 5 clusters, and the centroids of these 5 clusters are calculated using the mean estimation method, then cluster A shows a large number of trajectory points clustered near its centroid. Furthermore, the number of out-of-town vehicles entering the area has increased from 200 to 300 per day in the past three days. Because of the dense cluster centers near this road segment and the continuously increasing trend of out-of-town vehicles entering, the system will determine this road segment as a potentially congested high-frequency road segment.
[0037] Step S4: Path matching based on Dynamic Time Warping (DTW); This step is mainly used to find the best historical trajectory that matches the current vehicle's partial trajectory by defining a two-point distance calculation function and combining it with the DTW algorithm for vehicles whose origin is local, thereby determining the predicted path.
[0038] Traditional distance calculation methods using the DTW algorithm struggle to accurately measure the similarity between two trajectories due to differences in vehicle speed and time series. Therefore, this invention introduces a dynamic time warping algorithm.
[0039] The formula used is: D(Ct, Ht) = DTW(Ct, Ht, d) = D(m, n); Where D(m, n) is the DTW distance between the two trajectories, which is obtained through a recursive formula, as follows: Recurrence formula: Where m and n represent C t (Indicates the partial driving trajectory that has been collected for the current vehicle) and H t (The length of the matrix element representing the vehicle's driving trajectory stored in the historical database) Let represent the Euclidean distance d between the i-th point in the current trajectory and the j-th point in the historical trajectory. The formula for d is as follows: d = , and These are the x and y coordinates of P2, respectively. and Let x and y be the x and y coordinates of P1, respectively. The Euclidean distance formula is used for accurate calculation, which can effectively measure the straight-line distance between two points.
[0040] As an initial condition, the formula means that the cumulative distance of the current position is equal to the current point distance plus the minimum cumulative distance of the first three possible paths (left, top, top left). Finally, D(m, n) is the DTW distance between the two trajectories. The DTW algorithm employs a dynamic programming strategy to construct an m×n distance matrix (m, n) and finds the optimal time series alignment scheme by backtracking paths. In its implementation, the algorithm allows for local stretching and compression of the time axis, aligning the time series on a non-linear time scale and effectively solving the trajectory misalignment problem caused by inconsistent speeds. The final output D value reflects the overall distance between the two trajectories; a smaller value indicates higher trajectory similarity, providing a reliable matching basis for subsequent traffic state prediction based on historical similar trajectories. This algorithm can accurately identify the current trajectory and historical similar trajectories, thereby predicting the future congestion probability of road segments.
[0041] Finally, a historical trajectory database is stored in the vehicle information for vehicles registered in this city. This database contains a large number of vehicle trajectories under different time periods and traffic conditions. To find the historical trajectory that most closely matches the current vehicle's driving pattern, the trajectory with the smallest distance from the current trajectory is selected as the predicted trajectory. First, a function is defined to calculate the distance between two points, using the Euclidean norm to calculate the distance between the two points. In summary, this method first defines a function to calculate the distance between two points, uses the Euclidean norm to calculate the distance d between the two points, and then calculates the partial trajectory C of the current vehicle. t With each historical trajectory H in the historical trajectory list t The distance D between the current trajectory and the historical trajectory is calculated using the DTW algorithm and a defined distance function d. The historical trajectory with the smallest distance to the current trajectory is selected from the historical trajectory list as the best matching trajectory. Finally, the portion of the best matching trajectory after the current trajectory is used as the predicted path to predict the vehicle's subsequent driving route.
[0042] Step S5: Determining the risk of road congestion; In step S5, a risk assessment function containing six-dimensional features is constructed, and a comprehensive risk score is generated by weighted summation.
[0043] The score is calculated using the following formula: In the road congestion risk assessment technology, this solution integrates multiple dimensions such as local vehicle trajectory prediction, out-of-town vehicle trajectory prediction, inbound trend prediction, road segment characteristics, and weather conditions to construct an accurate congestion risk scoring system, providing a scientific basis for traffic management decisions.
[0044] The inbound trend factor T is calculated using a sliding window algorithm to count the number of vehicles entering the city within a time window. When ∆C(T) > 0, Trend(T) > 0, and the trend indicators rise for two consecutive time windows, T = 1; otherwise, T = 0. When the inbound trend rises, it means that more vehicles are entering the city, increasing the possibility of road congestion.
[0045] Traffic flow prediction factor F: Based on historical traffic data, holiday calendars, and schedules of major events, this factor uses machine learning algorithms (such as LSTM neural networks) to predict the hourly traffic flow (unit: vehicles / hour) of a target road segment. Higher traffic flow means greater road capacity pressure and a higher risk of congestion. For example, if the predicted peak-hour traffic flow for a road segment far exceeds its designed capacity, this factor will be increased accordingly.
[0046] Historical congestion factor H: This factor represents the frequency of congestion on the target road segment over the past 7 days. The formula is H = (Number of congestion occurrences in the past 7 days) / (Total number of monitoring periods in the past 7 days), with a value range of [0,1]. Road segments with high historical congestion frequencies are more likely to experience congestion again under similar conditions. This factor reflects the historical congestion patterns of the road segment.
[0047] Local vehicle trajectory prediction factor R: Predicts the routes of local vehicles entering the city using DTW path matching technology. Calculates the path overlap ratio r for each road segment. s ,in ( R is the number of predicted paths passing through road segment s (where N is the total number of predicted paths), combined with the road segment importance weight ωs, to obtain R. If the predicted routes of most vehicles entering the city are concentrated in certain road segments, the R value of these road segments will increase, indicating a higher risk of congestion due to the concentration of vehicle routes.
[0048] Out-of-town vehicle trajectory factor V: Statistical analysis of the frequency of occurrence of out-of-town vehicles in each road segment within the predicted trajectory. ,calculate: ×ωs, the travel routes of out-of-town vehicles are usually uncertain. During peak tourist seasons or large events, out-of-town vehicles may flood into certain road sections, potentially causing temporary congestion. This factor is used to quantify the risks posed by out-of-town vehicles.
[0049] It should be noted that for key traffic arteries such as main roads and expressways, The value is assigned to 0.8 - 1.0; secondary arterial roads connecting important commercial areas and residential areas, The assigned value is 0.5 - 0.7; for other branch roads or non-core road sections, The value assigned is 0.1 - 0.4.
[0050] Road segment characteristic factor S: This factor assigns weights to road segments based on factors such as segment length, number of lanes, and whether they are located at transportation hubs. For example, road segments that are long, have few lanes, or are located at transportation hubs tend to have low traffic efficiency and are prone to congestion. These factors are quantified as S, with a value range of [0,1]. A larger value indicates that the road segment is more likely to cause congestion.
[0051] Weather condition factor W: This factor connects with meteorological data to obtain real-time weather information. Different weather conditions have different impacts on traffic: Sunny days W = 0; Light rain, slippery roads, reduced vehicle speed W = 0.2; Moderate rain W = 0.4; Heavy rain and above, severe weather, increased probability of traffic accidents, significant decrease in traffic flow, extremely low traffic efficiency W = 0.6; Snow, fog, and other special weather conditions W = 0.8.
[0052] Weights of each factor This is determined by combining expert experience with historical data using the analytic hierarchy process (AHP), for example: And will be dynamically adjusted according to actual traffic conditions.
[0053] Finally, based on the calculated comprehensive risk score, a threshold method was used to classify congestion risk into four levels. The thresholds were set based on historical traffic congestion data of the city, determined by analyzing the actual congestion situation corresponding to different risk scores, combined with factors such as road capacity and traffic management resources. For example, data analysis in a certain city revealed that when... When the speed is below 30, the road section is generally in a smooth state; when it is between 30 and 60, there may be occasional local slow traffic; when it is between 60 and 85, regional congestion is likely to occur; when it exceeds 85, severe large-scale congestion may occur. The threshold is determined based on this.
[0054] This invention comprehensively covers key factors influencing road congestion by integrating multiple dimensions such as local and out-of-town vehicle trajectories, inbound trends, road characteristics, and weather. Compared to traditional assessment methods that rely on only one or a few factors, it can more accurately capture the sources of congestion risk. For example, it simultaneously considers the combined impact of concentrated influx of out-of-town vehicles during holidays and severe weather on traffic, avoiding omissions or misjudgments. Furthermore, it employs real-time data and dynamic algorithms for inbound trend factors and predicted traffic flow factors, enabling rapid response to changes in traffic flow; the weather condition factor is integrated with meteorological data in real time, promptly reflecting the impact of weather on traffic. Simultaneously, the weighting parameters can be adjusted according to changes in traffic characteristics at different seasons and times, ensuring the model maintains high prediction accuracy and adapts to the complex and ever-changing characteristics of urban traffic. This road congestion risk assessment scheme integrates multiple factors and possesses strong scientific rigor and practicality.
[0055] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A road congestion early warning method based on vehicle image recognition and trajectory prediction, characterized in that, Includes the following steps: Step S1: Data extraction step. Vehicle recognition equipment is deployed at city entrance and exit checkpoints and main roads to collect vehicle data. The video stream is read using the HyperLPR3 model combined with OpenCV to extract license plate information and store it in the database. Step S2, the inbound trend analysis step, uses the sliding window algorithm to calculate the net increase and trend index of the number of vehicles entering and leaving the city within the time window. The upward trend of the inbound trend is determined based on the continuous time window trend index. Step S3, Vehicle trajectory prediction step: For vehicle trajectory data with a home location outside the local area, clustering is performed using the DBSCAN algorithm and cluster centers are extracted. For vehicle trajectories with a home location in the local area, the Dynamic Time Warping (DTW) algorithm is used to match historical trajectories to predict the driving path. Step S4, Congestion Risk Assessment Step: Construct a six-dimensional feature risk assessment function that includes inbound trend factors, predicted traffic flow factors, historical congestion factors, local vehicle trajectory prediction factors, out-of-town vehicle trajectory factors, road segment characteristic factors, and weather condition factors. Generate a comprehensive risk score by weighted summation, and classify congestion risk levels based on thresholds.
2. The road congestion early warning method according to claim 1, characterized in that, In step S2, the formulas for calculating the net increase in urban inflow and trend indicators are as follows: Net increase in inbound traffic: ΔC(T) = C in (T)−C out (T) Trend indicator: Trend(T) = ΔC(T) − ΔC(T − ΔT) where T is the time window, ΔT is the sliding step size, and C... in (T) represents the number of vehicles entering the city within time window T, and C represents the number of vehicles entering the city within time window T. out (T) represents the number of vehicles leaving the city within the time window T.
3. The road congestion early warning method according to claim 2, characterized in that, The criteria for determining the upward trend of inbound traffic are: net increase in inbound traffic ∆C (T) > 0 in the current time window; trend indicator Trend (T) > 0; and the trend indicators for two consecutive time windows satisfy: Trend (T) > Trend (T−ΔT) and Trend (T−ΔT) > Trend (T−2ΔT).
4. The road congestion early warning method according to claim 1, characterized in that, In the vehicle trajectory prediction step, trajectory clustering based on the DBSCAN algorithm includes: Data preprocessing: The 3D trajectory data Ts is reduced to a 2D matrix F through a Reshape operation. Ts The formula is: F Ts =Reshape(Ts,−1,2); Cluster analysis: By using the neighborhood radius threshold eps and the minimum number of core points mins, trajectory points with achievable density are grouped into the same cluster, and the cluster label vector L is output. Cluster centroid calculation: The centroid of each cluster is calculated using the mean estimation method, and the formula is as follows: ,in, Let be the number of sample points within the i-th cluster. This represents the coordinate vector of the j-th trajectory point in the cluster.
5. The road congestion early warning method according to claim 4, characterized in that, The parameter tuning of the DBSCAN algorithm adopts a grid search combined with the silhouette coefficient evaluation method. The silhouette coefficient ranges from -1 to 1, and the closer the value is to 1, the better the clustering effect.
6. The road congestion early warning method according to claim 1, characterized in that, In the DTW-based path matching step, the formula for calculating the distance between the current trajectory Ct and the historical trajectory Ht is as follows: D(Ct,Ht)=DTW(Ct,Ht,d)=D(m,n); Where D(m, n) is the DTW distance between the two trajectories, which is obtained through a recursive formula, as follows: Recurrence formula: Where m and n represent the partial driving trajectory C that has been collected for the current vehicle. t And the vehicle driving trajectory H stored in the historical database t Length of matrix elements Let d represent the Euclidean distance between the i-th point of the current trajectory and the j-th point of the historical trajectory; The algorithm formula for d is as follows: d = , and These are the x and y coordinates of P2, respectively. and These are the x and y coordinates of P1, respectively; by As an initial condition, this formula means that the cumulative distance at the current position is equal to the current point distance plus the minimum cumulative distance of the first three possible paths, and finally D(m, n) is the DTW distance between the two trajectories.
7. The road congestion early warning method according to claim 1, characterized in that, In the congestion risk assessment step, the comprehensive risk scoring formula is as follows: ; Wherein, T is the inbound trend factor.
1. The inbound trend factor T satisfies the following: when ∆C (T) > 0 and the trend indicator rises for two consecutive time windows, T = 1; otherwise, T = 0. F is the predicted traffic factor, which is the hourly traffic flow of the target road segment predicted using a machine learning algorithm. H is the historical congestion factor, and the value of H ranges from 0 to 1; R is the local vehicle trajectory prediction factor. The DTW path matching technology is used to predict the paths of local vehicles entering the city, and the path overlap ratio rs for each road segment is calculated. , Let N be the number of predicted paths passing through road segment s, and N be the total number of predicted paths. Combining this with the road segment importance weights ωs, we obtain R. ; V represents the trajectory factor for vehicles from other regions, which calculates the frequency of occurrence of these vehicles on each road segment in the predicted trajectory. ,calculate: ×ωs; S is the road segment characteristic factor, which assigns weights to road segments based on factors such as road segment length, number of lanes, and whether it is a transportation hub. The value of S ranges from 0 to 1. W is the weather condition factor, which is assigned a value based on real-time weather: sunny day W=0, light rain W=0.2, moderate rain W=0.4, heavy rain and above W=0.6, snowy day or heavy fog W=0.
8.
8. The road congestion early warning method according to claim 7, characterized in that, For key traffic arteries such as main roads and expressways The value is assigned to 0.8 - 1.0; secondary arterial roads connecting important commercial areas and residential areas, The assigned value is 0.5-0.7; for other branch roads or non-core road sections, The value assigned is 0.1 - 0.
4.
9. The road congestion early warning method according to any one of claims 1-8, characterized in that, The congestion risk level is divided into four levels based on thresholds: Score < 30 indicates smooth traffic, 30 ≤ Score < 60 indicates localized slow traffic, 60 ≤ Score < 85 indicates regional congestion, and Score ≥ 85 indicates severe congestion.
10. A system for performing the road congestion early warning method according to any one of claims 1 to 8, characterized in that, include: Data acquisition module: Vehicle recognition equipment configured at city entrance and exit checkpoints and main roads is used to collect vehicle data. The vehicle recognition equipment includes a video stream reading unit based on OpenCV and a HyperLPR3 license plate recognition unit. Data processing module: used to clean, deduplicatize and store the collected vehicle data, including a database unit; Inbound Trend Analysis Module: Integrates a sliding window algorithm to calculate the net increase in inbound traffic and trend indicators, and to determine that the inbound trend is rising; The trajectory prediction module includes a DBSCAN clustering unit and a DTW path matching unit. The DBSCAN clustering unit is used for dimensionality reduction and clustering of trajectories of vehicles from other regions and extracting cluster centers. The DTW path matching unit is used for matching local vehicle trajectories with historical trajectories. Risk assessment module: Constructs a six-dimensional feature risk assessment function, including calculation units for inbound trend factors, predicted traffic factors, historical congestion factors, local vehicle trajectory prediction factors, out-of-town vehicle trajectory factors, road segment characteristic factors, and weather condition factors, which are used to generate a comprehensive risk score and classify congestion levels. Communication module: Used to interface with the meteorological department's data interface to obtain real-time weather information and transmit data processed by each module.