A method for generating traffic flow data incorporating GIS information

By constructing a four-layer progressive mathematical model and a two-layer detection and verification system, and combining computer vision and GIS information, the problem of binding traffic flow data with geographic coordinates was solved, realizing high-precision traffic flow data generation and visualization, and supporting urban traffic management.

CN122416741APending Publication Date: 2026-07-17SOUTHWEST MUNICIPAL ENGINEERING DESIGN & RESEARCH INSTITUTE OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTHWEST MUNICIPAL ENGINEERING DESIGN & RESEARCH INSTITUTE OF CHINA
Filing Date
2026-06-17
Publication Date
2026-07-17

Smart Images

  • Figure CN122416741A_ABST
    Figure CN122416741A_ABST
Patent Text Reader

Abstract

This invention discloses a method for generating traffic flow data containing GIS information, relating to the field of traffic data technology. The method includes: S1, acquiring traffic flow data from collected traffic videos using a computer vision system; S2, defining detection lines in the video frame, measuring the actual distance between two detection lines, recording the times when vehicles pass different detection lines and calculating the time difference, and obtaining the average vehicle speed by dividing the actual distance by the time difference; S3, obtaining traffic density data based on the acquired traffic flow data and average vehicle speed, thus obtaining basic traffic flow data; S4, constructing a four-layer progressive mathematical model, extracting GIS information, and forming traffic flow data containing GIS information; S5, visualizing the traffic flow data containing GIS information generated in step S4 on a CIM platform. This application can fully incorporate accurate geospatial information and significantly improve data accuracy, thus contributing to improved efficiency and effectiveness in urban traffic management and planning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of traffic data technology, and more specifically to a method for generating traffic flow data that includes GIS information. Background Technology

[0002] With the increasing demand for intelligent and refined urban traffic management, accurate traffic flow data with spatial attributes has become a core support for traffic control and municipal transportation project planning and design. Existing traffic flow data collection and generation technologies have significant shortcomings, failing to meet practical application needs. Specifically, current mainstream traffic flow data acquisition methods rely on single video recognition technology, which can only extract basic traffic parameters such as traffic volume, speed, and vehicle type, generally lacking accurate GIS geographic information and unable to accurately bind traffic data with road networks, geographic coordinates, and road segment locations. Furthermore, the data's spatial correlation is weak, making it difficult to support comprehensive analysis and planning decisions at the road network level. Traffic flow data provided by commercial data companies, limited by data collection coverage, user software usage rates, sampling density, and algorithm models, generally has low accuracy, with deviations in data from local road segments and intersections, failing to meet the stringent requirements of high-precision data for municipal transportation planning and refined traffic management. Summary of the Invention

[0003] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method for generating traffic flow data that includes GIS information.

[0004] The objective of this invention is achieved through the following technical solution: This application discloses a method for generating traffic flow data containing GIS information, including the following steps: S1. Traffic flow data is obtained from the collected traffic videos using a computer vision system. The traffic flow data includes vehicle type and number of vehicles. S2. Draw detection lines in the video frame, reserve the coordinates of the detection lines, measure the actual distance between the two detection lines, record the time when the vehicle passes through different detection lines and calculate the time difference, and obtain the average speed of the vehicle by dividing the actual distance by the time difference. S3. Based on the acquired traffic flow data and average vehicle speed, traffic density data is calculated to obtain basic traffic flow data. S4. Construct a four-layer progressive mathematical model, extract GIS information, and form traffic flow data containing GIS information; S5. Visualize the traffic flow data containing GIS information generated in step S4 on the CIM platform to realize the diagnosis of urban road operation status and to provide a basis for designing traffic control and congestion mitigation plans. The construction of the four-layer progressive mathematical model described in step S4 specifically includes the following sub-steps: S401, Let the global set of roads to be visualized be... , m represents the total number of roads, where roads It consists of n spatial coordinate points, that is Spatial coordinates Using the WGS-84 geographic coordinate system, , Represents spatial coordinates latitude value, Represents spatial coordinates The longitude value is used to generate the road geometry by using a straight line method between adjacent coordinate points. To reconstruct the road's direction and spatial location; S402, the first Average driving speed of the road segment Traffic flow per unit time With geospatial coordinate point set By establishing strong associations and constructing an attribute-spatial binding model, an integrated road data unit can be formed. ; S403. Continuous traffic indicator values ​​are converted into visual discrete color values ​​to intuitively distinguish road condition levels. A segmented boundary mapping rule is adopted, specifically including: Let the complete range of a single indicator be... Divide it into There are three non-overlapping, fully covered, and front-closed-back-open subintervals that satisfy: , ; Denotes the j-th subinterval. Indicates except All other subintervals except those mentioned above; construct the mapping function. To achieve targeted matching of indicator values ​​to color values. ,in express The corresponding color value; at the same time, a boundary fallback rule is set, if the actual value of a single indicator appears... Then set To ensure that extreme values ​​can be mapped correctly, among which Indicates the last subinterval The corresponding bottom color value; S404. Mathematical Model Construction for Map Center Point: Assume the global set of all road coordinate points is... Where N represents the total number of global road coordinate points, and the coordinates of the center point are calculated using the arithmetic mean method. ,in This represents the average latitude of the global road coordinate points. The average longitude of global road coordinate points is calculated using the following methods: , Use the smallest axis-aligned bounding rectangle. , ,in, , , , The map zoom level is automatically matched based on this boundary. This represents the minimum latitude value among all road coordinate points globally. This represents the maximum latitude value among all road coordinate points globally. This represents the minimum longitude value among all road coordinate points globally. This represents the maximum longitude value among all road coordinate points globally.

[0005] Further, step S1 specifically includes: initializing the computer vision system, configuring the traffic video input path, YOLOv8 pre-trained model path, region mask path, and multi-format output files, and presetting a confidence threshold for the vehicle category to be detected to achieve an optimal balance between detection accuracy and false negative rate; after the computer vision system initialization is completed, the SORT target tracker is imported, and an anomaly handling mechanism is designed; the anomaly handling mechanism includes: real-time monitoring of the tracking operation status of the computer vision system in response to SORT target tracker initialization failure, Kalman filter parameter out-of-bounds, frequent vehicle ID jumps, target trajectory loss, and redundant accumulation of the tracking queue; when ID disorder or target tracking loss occurs, the local tracking association is automatically reset and invalid trajectory cache is cleared, and the tracking of targets that have driven out of the region mask range is actively terminated to avoid continuous accumulation of tracking errors and ensure the effectiveness of vehicle trajectory matching with GIS region.

[0006] Furthermore, step S2 specifically includes the following sub-steps: S21. Select either a preset mode or a manual interactive mode to delineate two detection lines on the collected traffic video. The preset mode includes automatically generating detection lines by calling the reserved detection line coordinates. The manual interactive mode includes selecting the start and end points of the two detection lines by clicking on the first frame of the traffic video with the mouse, and providing real-time feedback on the coordinates and line preview during the selection process. S22. Input the actual distance between the two detection lines, obtain the actual distance between the two detection lines through on-site measurement tools, and determine the validity of the actual distance through outlier verification. S23. Record the line crossing time and calculate the time difference. Load the YOLOv8 deep learning model to process the video frames. Filter irrelevant areas and detect vehicles using region masking technology. Combine the SORT tracker and bounding box center coordinate matching mechanism to assign a unique target ID to the detected vehicles to achieve stable tracking. Call the vehicle line crossing recorder class. For horizontal lines, calculate the mean of the line coordinates to determine the line position. Combine the position changes of the vehicle in previous and subsequent frames to determine whether the vehicle has crossed the line. For non-horizontal lines, determine the vehicle's line crossing status by calculating the sign change of the cross product of the point and the line segment. S24. Based on the actual distance of the detection line and the vehicle's travel time, calculate the average speed of the vehicle between the two detection lines, verify the reasonableness of the speed result, and save the relevant vehicle category information after the verification is passed.

[0007] Furthermore, step S22 involves validating the actual distance through outlier detection, specifically including: S221. Based on urban road traffic conditions, pre-set the lower and upper limits of the reasonable distance between two detection lines to form a legal distance range; S222. Compare the manually input measured actual distance with the legal distance range. If the measured actual distance is not within the legal distance range, it is determined to be an abnormal distance value. A text alarm is issued, the current abnormal value is rejected, and the operator is guided to remeasure and enter the compliant distance data on site. S223. If the measured actual distance is within the legal distance range, it is determined to be a valid distance parameter, and it is allowed to be entered and proceed to step S23. At the same time, the distance entry and abnormal verification logs are recorded throughout the process and archived synchronously with GIS geographic information to avoid deviations in vehicle speed calculation caused by incorrect distance parameters.

[0008] Furthermore, in step S23, the Manhattan distance between the target ID center and the detected vehicle center is calculated, and the nearest detection result is matched to dynamically update the category information of the detected vehicle.

[0009] Furthermore, step S4 also includes the following sub-steps: S411, through formula Determine the path file The validity of the loading of graded ranges and color value parameters. This function checks if a file exists; if the path to the file is correct. If valid, then traverse the path files. The number of roads in the worksheets satisfies the condition that the number of worksheets is equal to the number of worksheets. , This represents a statistical counting function. This refers to a worksheet in an Excel file, from which road indicator values, including speed, are extracted. Traffic flow , , ,in, This represents the numerical extraction function. This represents the data frame corresponding to the k-th road. This indicates the function for locating a data frame by its label index. This indicates the vehicle speed field name in the data frame. This indicates the traffic flow field name in the data frame. Null values ​​and abnormal characters are removed to complete the initial data cleaning. S412, For the input coordinate text string Perform character cleaning to remove redundant symbols, resulting in a string cleaned by latitude and longitude. , This indicates the removal of redundant symbols, using commas to split the string. Split latitude and longitude by commas, that is , This represents the dimensions obtained from the split. The longitude obtained from the decomposition is represented by the formula. and Perform numeric type conversion. This indicates the conversion of a numeric type to a string, followed by a formula. Conduct compliance checks, removing non-compliant latitude and longitude data; and identifying the points corresponding to compliant latitude and longitude data. Combine them to obtain ; S413, Integrating Road Data Units With worksheet name To perform a one-to-one correspondence, that is Then, the global data is integrated to obtain the global dataset. , This enables integrated modeling of traffic indicators and spatial information. S414, via formula For global dataset Perform pattern determination and range calling, where M These represent the control variables for the entire visualization process, used to determine which type of traffic business indicator needs to be processed and rendered at any given time. speed Indicates the speed mode identifier, if M = speed Then enter the speed visualization mode; flow Indicates the traffic pattern identifier, if M = flow Then enter the traffic visualization mode; through the formula Extract indicator values; using formulas Perform interval traversal matching; if the actual value of the current road's traffic indicator... Then the final matched rendering color value of the kth road Equal to the fallback color value used when it exceeds the normal range ,Right now Generate color-coded rendering data; 415. Through the formula Perform a global coordinate summary. This represents the global coordinate set; then the center point coordinates are calculated and a bounding rectangle with the smallest axis alignment is constructed; based on the range of the bounding rectangle, the optimal scaling level is automatically matched, and map layer mapping is performed. Where F represents the map auto-scaling hierarchy mapping function, and Z represents the hierarchy parameter; S416, Perform map initialization, i.e. ,in, This represents the map after initialization. This indicates the creation of a map instance and its location at center point P0 and level Z; Load the base image and position it; according to color values and width Perform road polyline drawing to obtain the drawn road. ,Right now , Indicates by color value Draw the k-th road with a width of 5, and render each road one by one. Mark the starting point and the end point Add markers and bind pop-ups; bind color values ​​to corresponding road condition labels to generate legends. ,Right now Simultaneously display the hierarchical color matching rules; switch modes and re-render, clear the original layers, and execute... The process enables view updates without restarting, where... This represents a color value mapping.

[0010] The beneficial effects of this invention are: 1) This application uses the YOLOv8 model to complete vehicle target detection and preliminary vehicle model recognition, and relies on the SORT tracker to achieve continuous trajectory tracking of multiple targets. It innovatively adds a full-dimensional anomaly handling mechanism, and performs special algorithm optimization to address the defects of traditional tracking algorithms such as vehicle ID jumps, trajectory loss, and tracking queue redundancy, so as to realize the automatic repair of various tracking anomalies. At the same time, it innovatively introduces the Manhattan distance algorithm to construct feature comparison logic, performs dynamic correction on vehicle model recognition results, and then combines the Manhattan distance algorithm to compare feature vectors to dynamically correct vehicle model recognition results. Through multi-algorithm fusion optimization, the vehicle target tracking effect and vehicle model classification accuracy in complex scenarios are comprehensively improved.

[0011] 2) This application establishes a dual-layer detection and multi-level data verification system, supports automatic / manual dual-mode deployment of detection lines, sets threshold verification and abnormal alarms for detection line spacing and vehicle speed, and links the entire process to GIS log archives to eliminate calculation deviations from the data source. At the same time, it distinguishes between straight and non-straight detection lines and adopts differentiated judgment logic to improve the accuracy of vehicle crossing the line recognition.

[0012] 3) This application pioneers a four-layer progressive mathematical fusion model, which realizes deep binding of traffic flow indicators with WGS-84 standard geographic coordinates, and completes four major functions: road geometry restoration, integrated construction of traffic-spatial data units, hierarchical color value mapping of traffic indicators, and automatic adaptation of map view, thus completely solving the industry problem of traffic data being disconnected from road network space.

[0013] 4) This application integrates GIS data with CIM visualization applications to achieve dynamic rendering of road conditions, switching between modes without restarting, and visualization of all elements, enabling intuitive diagnosis of road operation status; the data has high accuracy and strong geospatial correlation, providing high-quality data support for urban traffic congestion mitigation, road network planning, and refined traffic management. Attached Figure Description

[0014] Figure 1 This is a schematic diagram illustrating the steps of a traffic flow data generation method incorporating GIS information according to an embodiment of the present invention. Detailed Implementation

[0015] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0016] This application discloses a method for generating traffic flow data containing GIS information, the steps of which are illustrated in the diagram below. Figure 1 As shown, it includes the following steps: S1. Traffic flow data is obtained from the collected traffic videos using a computer vision system. The traffic flow data includes vehicle type and number of vehicles. S2. Draw detection lines in the video frame, reserve the coordinates of the detection lines, measure the actual distance between the two detection lines, record the time when the vehicle passes through different detection lines and calculate the time difference, and obtain the average speed of the vehicle by dividing the actual distance by the time difference. S3. Based on the acquired traffic flow data and average vehicle speed, traffic density data is calculated to obtain basic traffic flow data. S4. Construct a four-layer progressive mathematical model, extract GIS information, and form traffic flow data containing GIS information; S5. Visualize the traffic flow data containing GIS information generated in step S4 on the CIM platform to realize the diagnosis of urban road operation status and to provide a basis for designing traffic control and mitigation plans.

[0017] For example, the core parameters are preset and configured to lay the foundation for the orderly implementation of the subsequent speed measurement process; the computer vision system is initialized, configuring the traffic video input path, YOLOv8 pre-trained model path, region mask path, and multiple output file formats (processed video, result TXT, result XLSX), while presetting the confidence threshold for the vehicle category to be detected to achieve the optimal balance between detection accuracy and false negative rate; through the flexible configuration and extended design of the above parameters, the system can adapt to the speed measurement needs in different scenarios, effectively improving the system's versatility and practicality; after the computer vision system initialization is completed, the SORT target tracker is imported, and an anomaly handling mechanism is designed. The anomaly handling mechanism includes: for SORT target tracker initialization failure, Kalman filter parameter out-of-bounds, frequent vehicle ID jumps, target trajectory loss, and redundant accumulation of the tracking queue, the computer vision system monitors the tracking operation status in real time; when ID disorder or target tracking loss occurs, the local tracking association is automatically reset and invalid trajectory cache is cleared, and the tracking of targets that have driven out of the region mask range is actively terminated to avoid the continuous accumulation of tracking errors and ensure that the vehicle trajectory is consistent with the GIS. Effectiveness of region matching; SORT tracker can effectively solve the technical defects of traditional single target detection technology, such as vehicle ID jump and tracking loss when multiple vehicles are detected in parallel. It can achieve stable tracking of vehicles throughout the process and provide a reliable target association basis for vehicle line crossing detection and speed calculation.

[0018] For example, TXT files contain detailed speed measurement data and statistical information, with standardized formatting and data alignment, facilitating manual review and archiving. XLSX files store data in a structured table format, allowing direct use for subsequent data statistics, analysis, and editing, adapting to office scenarios. Processed video files completely preserve the entire detection process, including details such as vehicle detection, lane departure warnings, and speed display, facilitating subsequent traceability, review, and verification. This enhances the system's practicality and traceability, meeting the application needs of results in different scenarios.

[0019] For example, step S2 specifically includes the following sub-steps: S21. Select either a preset mode or a manual interactive mode to delineate two detection lines on the collected traffic video. The preset mode includes automatically generating detection lines by calling the reserved detection line coordinates. The manual interactive mode includes selecting the start and end points of the two detection lines by clicking on the first frame of the traffic video with the mouse. During the selection process, the coordinates and line preview effects are provided in real time. This effectively solves the technical pain point that traditional speed measurement systems cannot adapt to diverse application scenarios such as different videos and different road sections, and significantly improves the system's scenario adaptability. S22. Input the actual distance between the two detection lines, obtain the actual distance between the two detection lines through on-site measurement tools, and determine the validity of the actual distance through outlier verification. S23. Record the line crossing time and calculate the time difference. Load the YOLOv8 deep learning model to process the video frames. Use region masking technology to filter out irrelevant areas (such as roadside vegetation, buildings, etc.) and detect vehicles. Combine the SORT tracker and the bounding box center coordinate matching mechanism to assign a unique target ID to the detected vehicles to achieve stable tracking. Call the vehicle line crossing recorder class. For horizontal lines, calculate the mean of the line coordinates to determine the line position. Combine the position changes of the vehicle in the previous and next frames to determine whether the vehicle has crossed the line. For non-horizontal lines, determine the vehicle's line crossing status by calculating the sign change of the cross product of the point and the line segment. This dual algorithm significantly improves the robustness and accuracy of line crossing detection, effectively avoids false or missed detections, and ensures that the line crossing time of each vehicle can be accurately captured. S24. Based on the actual distance of the detection line and the vehicle's travel time, calculate the average speed of the vehicle between the two detection lines, verify the reasonableness of the speed result, and save the relevant vehicle category information after the verification is passed.

[0020] For example, the specific process of anomaly verification of actual distance in S22 is as follows: First, based on urban road traffic conditions, a lower limit threshold and an upper limit threshold for the reasonable distance between two detection lines are preset to form a legal distance range; the manually input measured actual distance is compared with the preset legal distance range. If the measured actual distance is less than the lower limit threshold or greater than the upper limit threshold, it is determined to be an anomaly; after the system determines the anomaly, it immediately issues a text alarm prompt, refuses to accept the current abnormal value, and guides the operator to re-measure and enter the compliant distance data on-site; if the measured actual distance falls within the preset legal distance range, it is determined to be a valid distance parameter, allowed to be entered, and enters the subsequent vehicle speed calculation process; at the same time, the distance entry and anomaly verification log are recorded throughout the process and archived synchronously with GIS geographic information to avoid deviations in vehicle speed calculation caused by incorrect distance parameters, to judge the validity of user-input data, to ensure the accuracy of speed measurement calculation and the stability of system operation, and to achieve flexible adaptation of distance parameters under different actual scenarios.

[0021] For example, a comprehensive exception handling system is constructed, with corresponding prompting mechanisms and fallback strategies designed for common exception scenarios such as video inability to open, interrupted detection line selection, invalid distance input, and SORT tracker import failure. For the video inability to open scenario, a clear error message is output and the relevant detection process is terminated. For the interrupted detection line selection scenario, the selected detection line information is retained and the user is prompted to perform the operation again. For the invalid distance input and SORT tracker import failure scenarios, default values ​​are enabled or alternative solutions are provided to ensure that the system does not crash and can exit normally under abnormal conditions. This ensures the stability and reliability of system operation, reduces system maintenance costs, and improves system usability.

[0022] For example, in step S23, the Manhattan distance between the target ID center and the detected vehicle center is calculated, and the nearest detection result is matched to dynamically update the category information of the detected vehicle. This effectively avoids category recognition errors caused by detection frame errors and ensures the accuracy of vehicle category recognition.

[0023] For example, the construction of the four-layer progressive mathematical model described in step S4 specifically includes the following sub-steps: S401, Let the global set of roads to be visualized be... , m represents the total number of roads, where roads It consists of n spatial coordinate points, that is Spatial coordinates Using the WGS-84 geographic coordinate system, , Represents spatial coordinates latitude value, Represents spatial coordinates The longitude value is used to generate the road geometry by using a straight line method between adjacent coordinate points. To reconstruct the road's direction and spatial location; S402, the first Average driving speed of the road segment Traffic flow per unit time With geospatial coordinate point set By establishing strong associations and constructing an attribute-spatial binding model, an integrated road data unit can be formed. Used to achieve a strong correlation between traffic business indicators and road spatial information; Road spatial information is represented by a set of ordered geospatial coordinates (i.e., The road geometric skeleton data, composed of multiple coordinate points arranged according to the road direction, completely restores the actual alignment and spatial location of a single road, providing a standardized spatial carrier for the precise integration of traffic business indicators and GIS / CIM platforms; Traffic business indicators represent core quantitative parameters directly related to road operating conditions. In this embodiment, they mainly include two items: (1) No. Average driving speed of the road segment : refers to the average speed of all vehicles passing through the k-th road within the statistical period, usually expressed in km / h, reflecting the road's traffic efficiency and congestion level; (2) No. Traffic flow per unit time on each road This refers to the total number of vehicles passing through the k-th road within a unit of time (such as hours or minutes), usually expressed in pcu / h, reflecting the road's traffic load and demand. S403. Continuous traffic indicator values ​​are converted into visual discrete color values ​​to intuitively distinguish road condition levels. A segmented boundary mapping rule is adopted, specifically including: Let the complete range of a single indicator be... Divide it into There are three non-overlapping, fully covered, and front-closed-back-open subintervals that satisfy: , ; Denotes the j-th subinterval. Indicates except All other subintervals except those mentioned above; construct the mapping function. To achieve targeted matching of indicator values ​​to color values. ,in express The corresponding color value (color code) needs to be a predefined color identifier used to visually represent the level to which the indicator value belongs; at the same time, a boundary fallback rule should be set (the boundary fallback rule refers to the exception handling mechanism set in the indicator visualization mapping setting; specifically, when the actual value of a traffic indicator exceeds the upper limit of the preset value range, it is forcibly mapped to the color value corresponding to the last sub-interval in the preset value range to ensure that extreme values ​​can also be visualized normally and to avoid rendering anomalies caused by data overflow). If the actual value of a single indicator... ,but To ensure that extreme values ​​can be mapped correctly, among which Indicates the last subinterval The corresponding fallback color value is used to handle extreme values ​​that exceed the upper limit of the normal value range, ensuring that the excess indicator data can still be mapped to a uniform color identifier and avoid visualization failure. S404. Mathematical Model Construction for Map Center Point: Assume the global set of all road coordinate points is... Where N represents the total number of global road coordinate points, and the coordinates of the center point are calculated using the arithmetic mean method. ,in This represents the average latitude of the global road coordinate points. The average longitude of global road coordinate points is calculated using the following methods: , Use the smallest axis-aligned bounding rectangle. , ,in, , , , The map zoom level is automatically matched based on this boundary. This represents the minimum latitude value among all road coordinate points globally. This represents the maximum latitude value among all road coordinate points globally. This represents the minimum longitude value among all road coordinate points globally. This represents the maximum longitude value among all road coordinate points globally.

[0024] For example, step S4 further includes the following sub-steps: S411, through formula Determine the path file The validity of the loading of graded ranges and color value parameters. This function checks if a file exists (to verify if an Excel file path is valid and readable); if the file path is valid... If valid, then traverse the path files. The number of roads in the worksheets satisfies the condition that the number of worksheets is equal to the number of worksheets. , This represents a statistical counting function (used to count the total number of roads or the total number of items in an Excel worksheet). This refers to worksheets in an Excel file, with each worksheet corresponding to one line of road data. The goal is to extract road indicator values, including speed, from these worksheets. Traffic flow , , ,in, This represents a numeric extraction function (which converts cell text content into computable numeric data). This represents the data frame corresponding to the k-th road (which stores structured data such as speed and traffic flow for that road). This indicates a function for locating data frames by label index (used to accurately extract indicator values ​​for specified rows and columns). This indicates the vehicle speed field name in the data frame (stores the average driving speed of the road segment). This indicates the traffic flow field name in the data frame (stores the number of vehicles passing through per unit time). Null values ​​and abnormal characters are removed to complete the initial data cleaning. S412, For the input coordinate text string Perform character cleaning to remove redundant symbols, resulting in a string cleaned by latitude and longitude. , This indicates the removal of redundant symbols (parentheses, quotation marks, etc.), and the use of commas to split the string. Split latitude and longitude by commas, that is , This represents the dimensions obtained from the split. The longitude obtained from the decomposition is represented by the formula. and Perform numeric type conversion. This indicates the conversion of a numeric type to a string, followed by a formula. Conduct compliance checks, removing non-compliant latitude and longitude data; and identifying the points corresponding to compliant latitude and longitude data. Combine them to obtain ; S413, Integrating Road Data Units With worksheet name To perform a one-to-one correspondence, that is Integrate global data to obtain a global dataset. , This enables integrated modeling of traffic indicators and spatial information, providing standardized data support for subsequent GIS visualization and spatial analysis. S414, via formula For global dataset Perform pattern determination and range calling, where M These represent the control variables for the entire visualization process, used to determine which type of traffic business indicator needs to be processed and rendered at any given time. speed Indicates the speed mode identifier, if M = speed Then enter the speed visualization mode; flow Indicates the traffic pattern identifier, if M = flow Then enter the traffic visualization mode; through the formula Extract indicator values; using formulas Perform interval traversal matching; if the actual value of the current road's traffic indicator... Then the final matched rendering color value of the kth road Equal to the fallback color value used when it exceeds the normal range ,Right now Generate color-coded rendering data; 415. Through the formula Perform a global coordinate summary. This represents the global coordinate set; then the center point coordinates are calculated and a bounding rectangle with the smallest axis alignment is constructed; based on the range of the bounding rectangle, the optimal scaling level is automatically matched, and map layer mapping is performed. Where F represents the map auto-scaling level mapping function (calculates the optimal map display level based on the bounding rectangle), and Z represents the level parameter; S416, Perform map initialization, i.e. ,in, This represents the map after initialization. This indicates the creation of a map instance and its location at center point P0 and level Z; Load the base image and position it; according to color values and width Perform road polyline drawing to obtain the drawn road. ,Right now , Indicates by color value Draw the k-th road with a width of 5, and render each road one by one. Mark the starting point and the end point Add markers and bind pop-ups; bind color values ​​to corresponding road condition labels to generate legends. ,Right now Simultaneously display the hierarchical color matching rules; switch modes and re-render, clear the original layers, and execute... The process enables view updates without restarting, where... This represents a color value mapping.

[0025] For example, step S5 also includes setting up a real-time visualization module to achieve real-time visualization of the detection process and results. The detection line, vehicle bounding box, vehicle ID, vehicle category, and real-time speed information are synchronously drawn on the video frame. The detection line uses a dynamic indicator design that is normally red and flashes green when a vehicle crosses the line, providing intuitive feedback on the vehicle's crossing status and facilitating real-time monitoring by the user. Simultaneously, core statistical data (current time, detection line distance, number of vehicles completed detection, number of vehicles of each type, and overall average speed) are displayed in real time, intuitively presenting the detection process and real-time results, improving the user experience, and enabling users to monitor the system's operating status in real time and promptly identify and handle abnormal situations.

[0026] For example, the optimized video frame processing logic, by specifying the processing progress for each frame output, allows users to monitor the system's operational status in real time and promptly detect processing anomalies. After system operation concludes, video capture and writing resources are automatically released, and all visualization windows are closed, effectively preventing memory leaks and improving long-term system stability. This optimized design ensures the system can adapt to the demands of long-term, high-volume video speed testing, addressing the technical pain points of traditional systems prone to lag and crashes during extended operation, further enhancing system reliability and practicality, and adapting to large-scale speed testing scenarios in real-world applications.

[0027] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.

Claims

1. A method for generating traffic flow data including GIS information, characterized in that, Includes the following steps: S1. Traffic flow data is obtained from the collected traffic videos using a computer vision system. The traffic flow data includes vehicle type and number of vehicles. S2. Draw detection lines in the video frame, reserve the coordinates of the detection lines, measure the actual distance between the two detection lines, record the time when the vehicle passes through different detection lines and calculate the time difference, and obtain the average speed of the vehicle by dividing the actual distance by the time difference. S3. Based on the acquired traffic flow data and average vehicle speed, traffic density data is calculated to obtain basic traffic flow data. S4. Construct a four-layer progressive mathematical model, extract GIS information, and form traffic flow data containing GIS information; S5. Visualize the traffic flow data containing GIS information generated in step S4 on the CIM platform to realize the diagnosis of urban road operation status and to provide a basis for designing traffic control and congestion mitigation and smooth traffic flow. The construction of the four-layer progressive mathematical model described in step S4 specifically includes the following sub-steps: S401, Let the global set of roads to be visualized be... , m represents the total number of roads, where roads It consists of n spatial coordinate points, that is Spatial coordinates Using the WGS-84 geographic coordinate system, , Represents spatial coordinates latitude value, Represents spatial coordinates The longitude value is used to generate the road geometry by using a straight line method between adjacent coordinate points. To reconstruct the road's direction and spatial location; S402, the first Average driving speed of the road segment Traffic flow per unit time With geospatial coordinate point set By establishing strong associations and constructing an attribute-spatial binding model, an integrated road data unit can be formed. ; S403. Continuous traffic indicator values ​​are converted into visual discrete color values ​​to intuitively distinguish road condition levels. A segmented boundary mapping rule is adopted, specifically including: Let the complete range of a single indicator be... Divide it into There are three non-overlapping, fully covered, and front-closed-back-open subintervals that satisfy: , ; Denotes the j-th subinterval. Indicates except All other subintervals except those mentioned above; construct the mapping function. To achieve targeted matching of indicator values ​​to color values. ,in express The corresponding color value; at the same time, a boundary fallback rule is set, in case the actual value of a single indicator appears. Then set To ensure that extreme values ​​can be mapped correctly, among which Indicates the last subinterval The corresponding bottom color value; S404. Mathematical Model Construction for Map Center Point: Assume the global set of all road coordinate points is... Where N represents the total number of global road coordinate points, and the coordinates of the center point are calculated using the arithmetic mean method. ,in This represents the average latitude of the global road coordinate points. The average longitude of global road coordinate points is calculated using the following methods: , Use the smallest axis-aligned bounding rectangle. , ,in, , , , The map zoom level is automatically matched based on this boundary. This represents the minimum latitude value among all road coordinate points globally. This represents the maximum latitude value among all road coordinate points globally. This represents the minimum longitude value among all road coordinate points globally. This represents the maximum longitude value among all road coordinate points globally.

2. The method for generating traffic flow data including GIS information according to claim 1, characterized in that, Step S1 specifically includes: initializing the computer vision system, configuring the traffic video input path, YOLOv8 pre-trained model path, region mask path, and multi-format output files, and presetting a confidence threshold for the vehicle category to be detected to achieve an optimal balance between detection accuracy and false negative rate; after the computer vision system initialization is completed, the SORT target tracker is imported, and an anomaly handling mechanism is designed; the anomaly handling mechanism includes: real-time monitoring of the tracking operation status of the computer vision system in response to SORT target tracker initialization failure, Kalman filter parameter out-of-bounds, frequent vehicle ID jumps, target trajectory loss, and redundant accumulation of the tracking queue; when ID disorder or target tracking loss occurs, the local tracking association is automatically reset and invalid trajectory cache is cleared, and the tracking of targets that have driven out of the region mask range is actively terminated to avoid continuous accumulation of tracking errors and ensure the effectiveness of vehicle trajectory matching with GIS region.

3. The method for generating traffic flow data including GIS information according to claim 1, characterized in that, Step S2 specifically includes the following sub-steps: S21. Select either a preset mode or a manual interactive mode to delineate two detection lines on the collected traffic video. The preset mode includes automatically generating detection lines by calling the reserved detection line coordinates. The manual interactive mode includes selecting the start and end points of the two detection lines by clicking on the first frame of the traffic video with the mouse, and providing real-time feedback on the coordinates and line preview during the selection process. S22. Input the actual distance between the two detection lines, obtain the actual distance between the two detection lines through on-site measurement tools, and determine the validity of the actual distance through outlier verification. S23. Record the line crossing time and calculate the time difference. Load the YOLOv8 deep learning model to process the video frames. Filter irrelevant areas and detect vehicles using region masking technology. Combine the SORT tracker and bounding box center coordinate matching mechanism to assign a unique target ID to the detected vehicles to achieve stable tracking. Call the vehicle line crossing recorder class. For horizontal lines, calculate the mean of the line coordinates to determine the line position. Combine the position changes of the vehicle in previous and subsequent frames to determine whether the vehicle has crossed the line. For non-horizontal lines, determine the vehicle's line crossing status by calculating the sign change of the cross product of the point and the line segment. S24. Based on the actual distance of the detection line and the vehicle's travel time, calculate the average speed of the vehicle between the two detection lines, verify the reasonableness of the speed result, and save the relevant vehicle category information after the verification is passed.

4. The method for generating traffic flow data including GIS information according to claim 3, characterized in that, Step S22 involves validating the actual distance through outlier detection, specifically including: S221. Based on urban road traffic conditions, pre-set the lower and upper limits of the reasonable distance between two detection lines to form a legal distance range; S222. Compare the manually input measured actual distance with the legal distance range. If the measured actual distance is not within the legal distance range, it is determined to be an abnormal distance value. A text alarm is issued, the current abnormal value is rejected, and the operator is guided to remeasure and enter the compliant distance data on site. S223. If the measured actual distance is within the legal distance range, it is determined to be a valid distance parameter, and it is allowed to be entered and proceed to step S23. At the same time, the distance entry and abnormal verification logs are recorded throughout the process and archived synchronously with GIS geographic information to avoid deviations in vehicle speed calculation caused by incorrect distance parameters.

5. The method for generating traffic flow data including GIS information according to claim 3, characterized in that: In step S23, the Manhattan distance between the target ID center and the detected vehicle center is calculated, and the nearest detection result is matched to dynamically update the category information of the detected vehicle.

6. The method for generating traffic flow data including GIS information according to claim 5, characterized in that, Step S4 also includes the following sub-steps: S411, via formula Determine the path file The validity of the loading of graded ranges and color value parameters. This function checks if a file exists; if the path to the file is correct. If valid, then traverse the path files. The number of roads in the worksheets satisfies the condition that the number of worksheets is equal to the number of worksheets. , This represents a statistical counting function. This refers to a worksheet in an Excel file, from which road indicator values, including speed, are extracted. Traffic flow , , ,in, This represents the numerical extraction function. This represents the data frame corresponding to the k-th road. This indicates the function for locating a data frame by its label index. This indicates the vehicle speed field name in the data frame. This indicates the traffic flow field name in the data frame. Null values ​​and abnormal characters are removed to complete the initial data cleaning. S412, For the input coordinate text string Perform character cleaning to remove redundant symbols, resulting in a string cleaned by latitude and longitude. , This indicates the removal of redundant symbols, using commas to split the string. Split latitude and longitude by commas, that is , This represents the dimensions obtained from the split. The longitude obtained from the decomposition is represented by the formula. and Perform numeric type conversion. This indicates the conversion of a numeric type to a string, followed by a formula. Conduct compliance checks, removing non-compliant latitude and longitude data; and identifying the points corresponding to compliant latitude and longitude data. Combine them to obtain ; S413, Integrating Road Data Units With worksheet name To perform a one-to-one correspondence, that is Then, the global data is integrated to obtain the global dataset. , This enables integrated modeling of traffic indicators and spatial information. S414, via formula For global dataset Perform pattern determination and range calling, where M These represent the control variables for the entire visualization process, used to determine which type of traffic business indicator needs to be processed and rendered at any given time. speed Indicates the speed mode identifier, if M = speed Then enter the speed visualization mode; flow Indicates the traffic pattern identifier, if M = flow Then enter the traffic visualization mode; through the formula Extract indicator values; using formulas Perform interval traversal matching; if the actual value of the current road's traffic indicator... Then the final matched rendering color value of the kth road Equal to the fallback color value used when it exceeds the normal range ,Right now Generate color-coded rendering data; 415. Through the formula Perform a global coordinate summary. This represents the global coordinate set; then the center point coordinates are calculated and a bounding rectangle with the smallest axis alignment is constructed; based on the range of the bounding rectangle, the optimal scaling level is automatically matched, and map layer mapping is performed. Where F represents the map auto-scaling hierarchy mapping function, and Z represents the hierarchy parameter; S416, Perform map initialization, i.e. ,in, This represents the map after initialization. This indicates the creation of a map instance and its location at center point P0 and level Z; Load the base image and position it; according to color values and width Perform road polyline drawing to obtain the drawn road. ,Right now , Indicates by color value Draw the k-th road with a width of 5, and render each road one by one. Mark the starting point and the end point Add markers and bind pop-ups; bind color values ​​to corresponding road condition labels to generate legends. ,Right now Simultaneously display the hierarchical color matching rules; switch modes and re-render, clear the original layers, and execute... The process enables view updates without restarting, where... This represents a color value mapping.