Road traffic flow identification and statistics method and system
By collecting videos at traffic intersections and establishing localized data sets, combining the equipment hardware information configuration model framework, the problem of instability in traffic identification models in the existing technology is solved, and the recognition accuracy and system efficiency are improved.
Patent Information
- Application Number
- CN202510208262.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-05-27
AI Technical Summary
In the prior art, traffic identification models trained using public data sets often have missed detection and model instability in actual applications, resulting in poor identification accuracy and affecting the sorting statistics of traffic flow.
By collecting videos of traffic intersections in actual applications, establishing localized data sets, and configuring the initial model framework based on the equipment hardware information, model training and monitoring are carried out to ensure that the model is in line with the application scenarios, and improving the stability and recognition accuracy of the model.
It improves the accuracy of vehicle identification, enhances the stability of the model and the performance utilization of equipment hardware, reduces the amount of picture data to be identified, and improves the system's efficiency in vehicle identification.
Smart Images

Figure CN120048118A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of road traffic, and in particular, to a method and system for identifying and counting road traffic flow. Background Art
[0002] With the continuous development of the economic society, more and more families have purchased motor vehicles as commuting means of transportation. While bringing a comfortable experience to the drivers and passengers, it also brings practical problems such as congestion and frequent accidents to the urban road network, which has become a common problem in the road networks of various cities across the country. Therefore, the statistics, analysis, modeling, and prediction of urban road network traffic flow have become increasingly important.
[0003] In the prior art, through machine learning technology, an identification model is trained using a public dataset so that the trained model can accurately identify the vehicle information at intersections collected by video devices such as traffic probes, thereby accurately providing the traffic volume at traffic intersections for subsequent analysis. However, since the data collection in the public dataset mainly comes from abroad and there are significant differences in video image features from those in China, the trained model often has problems such as missed detections and model instability in actual applications, resulting in poor identification accuracy, which in turn affects the sorting and statistics of traffic flow and there is room for improvement. Summary of the Invention
[0004] In order to improve the accuracy of vehicle identification, this application provides a method and system for identifying and counting road traffic flow.
[0005] In a first aspect, this application provides a method for identifying and counting road traffic flow, adopting the following technical solution:
[0006] A method for identifying and counting road traffic flow includes:
[0007] Performing video acquisition on traffic intersections in actual application to obtain video sample data, and processing the video sample data to obtain a picture set;
[0008] Marking the motor vehicles in each picture in the picture set to obtain vehicle marking data, and dividing the vehicle marking data according to the built-in vehicle types to obtain labeled data;
[0009] Statistically marking the labeled data and the corresponding pictures to obtain a localized dataset;
[0010] Obtaining device hardware information, and configuring parameters for the built-in initial model framework according to the device hardware information to obtain an initial training model;
[0011] Training the initial training model based on the localized dataset, and monitoring the initial training model during the training process to determine the training results of the initial training model and obtain a mature detection model;
[0012] Obtain the road video data for which traffic flow needs to be counted, input the road video data into a mature detection model for vehicle recognition to obtain recognition data, perform statistical analysis on the recognition data, and obtain and output the traffic flow data.
[0013] Preferably, based on the built-in picture quantity index, randomly extract frames from the video sample data to obtain video frame data;
[0014] Obtain the image resolution of the common video acquisition devices at the traffic intersection to obtain an image resolution set;
[0015] Perform mathematical statistics judgment on the image resolutions in the image resolution set to determine the basic resolution interval;
[0016] Match the resolution of the video frame data with the resolutions in the basic resolution interval, and add the video frame data with the resolution equal to the resolution in the basic resolution interval to the picture data group corresponding to the resolution;
[0017] Compress the picture quality of the video frame data with a resolution greater than the resolution in the basic resolution interval, and add the compressed video frame data to the picture data group corresponding to the resolution;
[0018] Do not add the video frame data with a resolution less than the resolution in the basic resolution interval to the picture data group;
[0019] Unify the picture data groups at each resolution and mark them as a picture set.
[0020] Preferably, use a model training assistance tool with a graphical interface to monitor the training data of the initial training model during training to determine the monitoring data of the initial training model;
[0021] Perform statistics on the monitoring data to obtain a data change curve, and read the training state according to the data change curve to determine the training state;
[0022] If the training state is an abnormal state, adjust the parameters of the initial training model and retrain the initial training model until the training state of the initial training model is a normal state;
[0023] If the training state of the initial training model is a normal state, analyze the data change curve to determine the parameter data with an accuracy rate greater than the built-in benchmark accuracy rate to obtain a mature detection model.
[0024] Preferably, judge the change trend of the data change curve to determine whether the data change of the data change curve is in a stable fluctuation state;
[0025] If the data change of the data change curve is not in a stable fluctuation state, continuously train the initial training model until the data change of the data change curve is in a stable fluctuation state;
[0026] If the data change of the data change curve is in a stable fluctuation state, stop training the initial training model and calculate the mean value of the data values in the stable fluctuation stage to obtain the recognition accuracy data;
[0027] Compare the recognition accuracy data with the built-in benchmark accuracy data. If the recognition accuracy is greater than the built-in benchmark accuracy data, mark the initial training model as a mature detection model.
[0028] Preferably, obtain the intersection information of the road in the road video data and determine the virtual detection line according to the intersection information;
[0029] Extract video frames from the road video data to obtain the picture data to be recognized, and input the extracted picture data to be recognized into the mature detection model for vehicle recognition;
[0030] Based on the time data, sequentially input the picture data to be recognized into the mature detection model for vehicle recognition to obtain the recognition data and the rectangular recognition frame of the corresponding recognized vehicle;
[0031] Match the rectangular recognition frame of the vehicle with the virtual detection line once. When one side of the rectangular recognition frame coincides with the virtual detection line, determine that the vehicle corresponding to the rectangular recognition frame passes through the virtual detection line, and mark the side that coincides with the virtual detection line as the first side data;
[0032] Based on the first side data and the rectangular recognition frame corresponding to the first side data, determine the positional relationship between the other side parallel to the first side data in the corresponding rectangular recognition frame and the virtual detection line, and determine the driving direction of the vehicle to obtain the driving state data;
[0033] Summarize the recognition data, the driving state data, and the time data when the first side data of the corresponding rectangular recognition frame coincides with the virtual detection line to obtain the traffic flow data and output it.
[0034] Preferably, extract video frames from the road video data to obtain the picture data to be judged;
[0035] Determine the resolution of the road video data based on the road video data and record it as the resolution to be matched;
[0036] Match the resolution to be matched with the built-in recognition rate table to determine the serial number of the resolution to be matched in the recognition rate table, and mark the serial number as the video serial number;
[0037] Based on the built-in recognition rate table, judge the video serial number to determine whether the video serial number is the first sequence;
[0038] If it is determined that the video serial number is the first sequence, do not perform image processing on the image data to be judged;
[0039] If it is determined that the video serial number is not the first sequence, then according to the recognition rate table, screen the video serial number to obtain the resolution whose serial number is greater than the video serial number and the recognition rate is greater than or equal to the recognition rate corresponding to the video serial number, and mark it as the first screening result;
[0040] Perform resolution screening on the first screening result to obtain the resolution whose resolution is less than the resolution to be matched, and mark it as the second screening result;
[0041] Based on the resolution corresponding to the second screening result, perform compression processing on the image data to be judged to obtain the image data to be recognized, and input the image data to be recognized into a mature detection model for vehicle recognition.
[0042] In a second aspect, the present application provides a road traffic flow recognition and statistics system, adopting the following technical solutions:
[0043] A road traffic flow recognition and statistics system includes: a data set establishment module, a model training module, and a traffic flow recognition module;
[0044] The data set establishment module collects video of an actual traffic intersection to obtain video sample data, and processes the video sample data to obtain a picture set; marks the motor vehicles on each picture in the picture set to obtain vehicle marking data, and divides the vehicle marking data according to the built-in vehicle types to obtain labeled data; performs statistical marking on the labeled data and the corresponding pictures to obtain a localized data set;
[0045] The model training module obtains device hardware information, and configures parameters for the built-in initial model framework according to the device hardware information to obtain an initial training model; trains the initial training model based on the localized data set, and monitors the initial training model during the training process to determine the training results of the initial training model to obtain a mature detection model;
[0046] The traffic flow recognition module obtains road video data for which traffic flow needs to be counted, and inputs the road video data into a mature detection model for vehicle recognition to obtain recognition data, and performs statistical analysis on the recognition data to obtain traffic flow data and output it.
[0047] In summary, the present application includes at least one of the following beneficial technical effects:
[0048] 1. By collecting and analyzing video of actual traffic intersections, the trained detection model can be made to fit the application scenario. By extracting frames and annotating the collected video sample data, a localized dataset with local characteristics can be determined, making the model trained based on the localized dataset more accurate in vehicle recognition. By matching the device hardware information of the model for road traffic flow recognition with the built-in device hardware information, the initial training model of the initial model framework can be parameter-configured, so that the trained model fits the actual application device hardware, thus ensuring the stability of model operation and the performance utilization of the device hardware. By monitoring the training process, model data with a high-precision recognition rate can be determined, so that the vehicle data recognized according to the mature detection model is more accurate, improving the recognition accuracy rate;
[0049] 2. By using the picture quantity index to randomly extract video frames from the video sample data, the similarity between the extracted video frames can be made lower, which is conducive to improving the training effect of the model. By determining the image resolution of common video collection devices, the coverage range of the image resolution of the video sample data can be clarified, and then the corresponding image quality processing can be performed on the video frame data, so that the collected image quality can meet the image resolution of most common devices, and the trained model can still accurately identify motor vehicles when the image resolution changes. At the same time, by performing image quality processing on the video frame data to clarify the recognition results of the model under different image qualities, when the recognition results meet the requirements of the recognition accuracy rate, the data volume of the image data can be minimized, thus reducing the picture data volume of the pictures to be recognized, and improving the efficiency of the system in vehicle recognition under the same device processing performance;
[0050] 3. By matching the resolution and recognition rate of the picture data to be judged with the built-in recognition rate table, the recognition accuracy rate of the picture data to be judged in the mature detection model can be determined. When the recognition accuracy rate of the picture data to be judged is not the optimal solution in the mature detection model, by determining the recognition rate and resolution of the picture data to be judged, it can be determined whether the picture data to be judged is the optimal solution at this resolution. If it is determined to be the optimal solution at the current resolution, the picture data to be judged will not be processed. If it is determined not to be the optimal solution at the current resolution, the recognition rate table can be screened by using the recognition rate and resolution of the picture data to be judged, and then the optimal solution that can be satisfied at the current resolution can be determined, and the resolution of the picture data to be judged can be compressed and adjusted according to the resolution of the optimal solution, which not only improves the recognition accuracy rate of vehicles, but also reduces the picture data volume of the pictures to be recognized, improving the recognition efficiency. Description of the Drawings
[0051] Figure 1It is the flowchart of the steps of the road traffic flow recognition and statistics method in this embodiment;
[0052] Figure 2 It is the block diagram of the modules of the road traffic flow recognition and statistics system in this embodiment.
[0053] Reference numerals: 1. Dataset establishment module; 2. Model training module; 3. Traffic flow recognition module. Specific implementation manner
[0054] The following further elaborates on this application in conjunction with the attached Figure 1 - Figure 2 drawings.
[0055] An embodiment of this application discloses a road traffic flow recognition and statistics method and system.
[0056] Embodiment: As Figure 1 shown, a road traffic flow recognition and statistics method of the present invention includes:
[0057] S100. Perform video acquisition on the traffic intersections in actual application to obtain video sample data, and process the video sample data to obtain a picture set; the number of pictures to be extracted is built-in, and random frame extraction is performed on the video sample data according to the number of extracted pictures, so that the pictures in the dataset are not regular, thereby reducing the probability of misjudgment.
[0058] S200. Mark the motor vehicles on each picture in the picture set to obtain vehicle marking data, and divide the vehicle marking data according to the built-in vehicle types to obtain labeled data; the LabelImg software can be used to mark the motor vehicles on the pictures, thereby obtaining the corresponding labeled data.
[0059] S300. Perform statistical marking on the labeled data and the corresponding pictures to obtain a localized dataset; among them, the localized dataset includes a training set and a test set. The training set is used to train the initial training model, and the test set is used to test the initial training model after training, determine the training result of the initial training model, and mark the model with a qualified training result as a mature detection model.
[0060] S400. Obtain the device hardware information, and configure the parameters of the built-in initial model framework according to the device hardware information to obtain an initial training model; multiple common device hardware information is set in the system, and different device hardware information has corresponding parameter information of the initial model framework. Then, by matching the device hardware information of the scenario to be applied with the device hardware information built in the system, the parameter information of the initial model framework under the corresponding device hardware information can be determined.
[0061] S500. Train the initial training model based on the localized data set and monitor the initial training model during the training process to determine the training results of the initial training model, and obtain a mature detection model.
[0062] S600. Obtain the road video data for which the traffic flow needs to be counted, input the road video data into the mature detection model for vehicle recognition to obtain recognition data, and perform statistical analysis on the recognition data to obtain and output the traffic flow data.
[0063] In this embodiment, by collecting and analyzing video at the traffic intersections in actual applications, the trained detection model is made to fit the application scenario. By extracting frames and annotating the collected video sample data, a localized data set with local characteristics is determined, making the model trained based on the localized data set more accurate in vehicle recognition. By matching the device hardware information of the model for road traffic flow recognition with the built-in device hardware information, the initial training model of the initial model framework is configured with parameters, so that the trained model fits the actual application device hardware, thus ensuring the normal operation of the model and the utilization of the performance of the device hardware. By monitoring the training process, model data with a high-precision recognition rate is determined, so that the vehicle data recognized according to the mature detection model is more accurate, improving the recognition accuracy.
[0064] In step S100, video is collected at the traffic intersections in actual applications to obtain video sample data, and the video sample data is processed to obtain a picture set, including the following steps:
[0065] S110. Randomly extract frames from the video sample data based on the built-in picture quantity index to obtain video frame data.
[0066] S120. Obtain the image resolution of the common video collection devices at the traffic intersections to obtain an image resolution set; among them, the common video collection devices can be set by manual statistics input.
[0067] S130. Perform mathematical statistical judgment on the image resolutions in the image resolution set to determine the basic resolution interval; the basic resolution interval can be set manually. For example, the resolution interval when the satisfaction rate reaches 90%, the resolution interval when the satisfaction rate reaches 80%. For example, among 10 common models, there is 1 with a resolution of 4K, 2 with a resolution of 2K, 3 with a resolution of 1080p, and 4 with a resolution of 720p. Then the satisfaction rate of resolutions of 4K and above is 10%, the satisfaction rate of resolutions of 2K and above is 30%, the satisfaction rate of resolutions of 1080p and above is 60%, and so on.
[0068] S140, match the resolution of the video frame data with the resolution in the base resolution range, and add the video frame data with a resolution equal to the resolution in the base resolution range to the picture data group corresponding to that resolution;
[0069] S150, compress the picture quality of the video frame data with a resolution greater than the resolution in the base resolution range, and add the compressed video frame data to the picture data group corresponding to that resolution;
[0070] S160, do not add the video frame data with a resolution less than the resolution in the base resolution range to the picture data group;
[0071] S170, uniformly label the picture data groups at each resolution as a picture set.
[0072] In this embodiment, randomly extract video frames from the video sample data according to the picture quantity index, so that the similarity between the extracted video frames is relatively low, which is beneficial to the training effect of the extracted data set on the model. By determining the image resolution of common video capture devices, the coverage range of the corresponding image resolution is clarified, and then the corresponding image quality processing is performed on the video frame data, so that the captured image quality can meet the image resolution of most common devices. Furthermore, the trained model can still accurately identify motor vehicles when the image resolution changes. At the same time, by performing image quality processing on the video frame data, the recognition results of the model under different image qualities are clarified. Then, when the recognition results meet the requirements, the data volume of the image data is minimized, the picture data to be recognized is reduced, and the efficiency of the system for vehicle recognition is improved under the condition of the same device processing performance.
[0073] Exemplarily, the recognition rate of the trained model for pictures with 4K picture quality is 90%, and the recognition rate for pictures with 720p picture quality is also 90%. Since the data volume of pictures with 720p picture quality is much smaller than that of pictures with 4K picture quality, the processing efficiency of the system when processing pictures with 720p picture quality is faster than that of pictures with 4K picture quality. Therefore, the recognition efficiency is improved. At the same time, the data volume of pictures with 720p picture quality is much smaller than that of pictures with 4K picture quality, so the storage space of the system for pictures with 720p picture quality is smaller than that of pictures with 4K picture quality, reducing the requirement standard for the system device hardware.
[0074] In step S500, train the initial training model based on the localized data set, and monitor the initial training model during the training process to determine the training results of the initial training model and obtain a mature detection model, including the following steps:
[0075] S510. Use a model training assistance tool with a graphical interface to monitor the training data of an initial training model during training to determine the monitoring data of the initial training model. Among them, the monitoring data includes the training process and changes in key parameters. Among them, the model training assistance tool with a graphical interface can be TensorBoard software.
[0076] S520. Statistically analyze the monitoring data to obtain a data change curve, and read the training status based on the data change curve to determine the training status. By using TensorBoard software to monitor the initial training model, when the training status of the model is abnormal, an alarm signal is automatically output for alarm reminder, so as to clarify the training status of the model during the training process. Among them, the monitoring data can be the mean average precision.
[0077] S530. If the training status is an abnormal status, adjust the parameters of the initial training model and retrain the initial training model until the training status of the initial training model is a normal status. Among them, adjusting the parameters of the initial training model is to match the abnormal signal with the built-in abnormal handling program when the training status is abnormal, so as to determine the corresponding parameter adjustment data to adjust the parameters of the initial training model.
[0078] S540. If the training status of the initial training model is a normal status, analyze the data change curve to determine the parameter data with an accuracy rate greater than the built-in benchmark accuracy rate, and obtain a mature detection model.
[0079] In this embodiment, by using a model training assistance tool to monitor the training process of the initial training model, the training status of the initial training model is determined in real time. When the training status is abnormal, the parameters of the model are adjusted in time to ensure the effectiveness of the training of the initial training model. When the training status is normal, the training results of the model are determined by analyzing the data change curve, which improves the accuracy of vehicle recognition by the model.
[0080] In step S540, if the training status of the initial training model is a normal status, analyze the data change curve to determine the parameter data with an accuracy rate greater than the built-in benchmark accuracy rate, and obtain a mature detection model, including the following steps:
[0081] S541. Judge the change trend of the data change curve to determine whether the data change of the data change curve is in a stable fluctuation state. Among them, the stable fluctuation state means that the change range of the data change curve under the same change trend is within the built-in fluctuation range. Among them, the fluctuation range can be determined through scientific experiments.
[0082] S542. If the data change of the data change curve is not in a stable fluctuation state, continuously train the initial training model until the data change of the data change curve is in a stable fluctuation state;
[0083] S543. If the data change of the data change curve is in a stable fluctuation state, stop training the initial training model, calculate the mean value of the data values in the stable fluctuation stage to obtain the recognition accuracy data;
[0084] S544. Compare the recognition accuracy data with the built-in reference accuracy data. If the recognition accuracy is greater than the built-in reference accuracy data, mark the initial training model as a mature detection model.
[0085] In this embodiment, by judging the change trend of the data change curve and whether the data at the current time point of the data change curve is in a stable fluctuation state, it is clear whether the current trained model achieves the best recognition effect for motor vehicles. If the data change of the data change curve is not in a stable fluctuation state, it indicates that the recognition of the vehicle by the model has not reached the best recognition effect, and thus the model needs to be continuously trained. When the data change of the data change curve is in a stable fluctuation state, it indicates that the recognition of the vehicle by the model has reached the best recognition effect, and thus the training of the model is stopped. This not only reduces the waste of system resources caused by ineffective training but also ensures the effectiveness of the model training results, making the recognition accuracy reach the best.
[0086] Exemplarily, assume that the data change curve is the mean average precision. During the training process, the mean average precision of the initial training model for vehicle recognition in the picture gradually increases from value a until it fluctuates up and down near value b. If the overall trend of the collected data change curve is fluctuating upward, it indicates that there is a possibility that the mean average precision of the model will continue to increase after increasing the number of training times. If the overall trend of the collected data change curve is fluctuating up and down near value b, it indicates that the recognition of the picture vehicle by the model has reached the best and will not increase significantly due to increasing the number of training times.
[0087] In step S600, obtain the road video data for which the traffic flow needs to be counted, input the road video data into the mature detection model for vehicle recognition to obtain recognition data, and perform statistical analysis on the recognition data to obtain and output the traffic flow data, including the following steps:
[0088] S610. Obtain the intersection information of the road in the road video data, and determine the virtual detection line according to the intersection information; according to the built-in virtual detection line setting rules, set the virtual detection line at a position perpendicular to the road direction and crossing the intersection according to the road direction.
[0089] S620, extracting video frames from the road video data to obtain image data to be identified, and inputting the extracted image data to be identified into a mature detection model for vehicle identification; wherein, the method for extracting video frames from the road video data is the same as the method for extracting video frames from the video sample data of the localized data set.
[0090] S630, based on the time data, sequentially input the image data to be identified into the mature detection model for vehicle identification, and obtain identification data and a rectangular identification frame corresponding to the identified vehicle; wherein the identification data includes the type of vehicle and the position of the vehicle in the image.
[0091] S640, matching the rectangular recognition frame of the car with the virtual detection line. When one side of the rectangular recognition frame coincides with the virtual detection line, it is determined that the car corresponding to the rectangular recognition frame passes through the virtual detection line, and the side coincident with the virtual detection line is marked as first side data.
[0092] S650, based on the first edge data and the rectangular recognition frame corresponding to the first edge data, determining the positional relationship between another edge in the corresponding rectangular recognition frame that is parallel to the first edge data and the virtual detection line, determining the driving direction of the vehicle, and obtaining driving state data;
[0093] S660, summarizing the recognition data, the driving status data, and the time data when the first side data of the corresponding rectangular recognition box coincides with the virtual detection line to obtain and output the traffic flow data.
[0094] In this embodiment, the mature detection model obtained through training is used to extract and identify the pictures to be identified from the road video data to be identified, so as to determine the information of the vehicle on the picture to be identified, determine the type of vehicle and the position of the vehicle in the picture, and then determine the virtual detection line of the corresponding intersection based on the intersection information of the road in the road video data, and then determine the driving direction of the vehicle based on the virtual detection line and the rectangular recognition frame obtained through identification, and output the recognition data, driving status data and corresponding recognition time obtained through recognition and judgment, so that the staff can make corresponding arrangements for the traffic intersection according to the output data.
[0095] Exemplarily, the intersection information is a north-south traffic road. For example, according to the built-in virtual detection line setting rule, the set virtual detection line is on the road near the video acquisition device, and the specific coordinate is y = 10. Among them, taking the north-south direction as the vertical coordinate y and the east-west direction as the horizontal coordinate x, the horizontal coordinate x vertically passes through the traffic road. Using a mature detection model to identify vehicles from the road video data. For example, the coordinates of the four vertices A, B, C, and D of the rectangular recognition frame of the identified vehicle position are: A(10,10), B(20,10), C(10,0), D(20,0). Then, since the AB line coincides with the virtual detection line, it is determined that the vehicle passes through the intersection, that is, the traffic flow data is incremented by one. And if the coordinates of the four vertices A, B, C, and D of the rectangular recognition frame of the identified vehicle position are: A(10,5), B(20,5), C(10,0), D(20,0), then since the AB line does not coincide with the virtual detection line, it is determined that the vehicle does not pass through the intersection, that is, a vehicle is identified but the traffic flow of the identified vehicle is not counted.
[0096] In step S620, the road video data is extracted into video frames to obtain the picture data to be recognized, and the extracted picture data to be recognized is input into a mature detection model for vehicle recognition, including the following steps:
[0097] S621, Extract the road video data into video frames to obtain the picture data to be judged;
[0098] S622, Determine the resolution of the road video data based on the road video data and record it as the resolution to be matched;
[0099] S623, Match the resolution to be matched with the built-in recognition rate table to determine the serial number of the resolution to be matched in the recognition rate table, and mark this serial number as the video serial number; among them, the recognition rate table is when training the model, the accuracy of the model in recognizing vehicles on pictures with different resolutions is statistically calculated and plotted into table data with the recognition rate as the first criterion and the picture resolution as the second criterion. For example, the recognition rate of a picture with a resolution of 4k is 90%, the recognition rate of a picture with a resolution of 2k is 80%, the recognition rate of a picture with a resolution of 1080p is 80%, and the recognition rate of a picture with a resolution of 720p is 70%. Then the sorting of the recognition rate table is: serial number 1: 90%: 4k; serial number 2: 80%: 1080p; serial number 3: 80%: 2k; serial number 4: 70%: 720p.
[0100] S624, Based on the built-in recognition rate table, judge the video serial number to determine whether the video serial number is the first sequence; among them, the first sequence is the serial number 1.
[0101] S625, if it is determined that the video serial number is the first sequence, no image processing is performed on the image data to be judged;
[0102] S626, if it is determined that the video serial number is not the first sequence, then according to the recognition rate table, the video serial number is screened to obtain a resolution whose serial number is greater than the video serial number and whose recognition rate is greater than or equal to the recognition rate corresponding to the video serial number, and it is marked as the first screening result;
[0103] S627, perform resolution screening on the first screening result to obtain a resolution smaller than the resolution to be matched, and mark it as the second screening result;
[0104] S628, perform compression processing on the image data to be judged based on the resolution corresponding to the second screening result to obtain the image data to be recognized, and input the image data to be recognized into a mature detection model for vehicle recognition.
[0105] In this embodiment, by matching the resolution and recognition rate of the image data to be judged with the built-in recognition rate table, the recognition accuracy rate of the image data to be judged in the mature detection model is determined. Furthermore, when the recognition accuracy rate of the image data to be judged is not the optimal solution in the mature detection model, it is determined whether the image data to be judged is the optimal solution at this resolution by using the recognition rate and resolution of the image data to be judged. If it is determined to be the optimal solution at the current resolution, no image processing is performed on the image data to be judged. If it is determined not to be the optimal solution at the current resolution, the recognition rate table is screened by using the recognition rate and resolution of the image data to be judged, and then the optimal solution that can be satisfied at the current resolution is determined. And the resolution of the image data to be judged is compressed and adjusted according to the resolution of the optimal solution, which not only improves the recognition accuracy rate of the vehicle, but also reduces the amount of image data of the image to be recognized, and improves the recognition efficiency.
[0106] Exemplarily, the recognition rate of a 4k resolution image is 90%, the recognition rate of a 2k resolution image is 80%, the recognition rate of a 1080p resolution image is 80%, and the recognition rate of a 720p resolution image is 70%. Then the sorting of the recognition rate table is: serial number 1: 90%: 4k; serial number 2: 80%: 1080p; serial number 3: 80%: 2k; serial number 4: 70%: 720p.
[0107] If the video serial number is serial number 3, then compare serial number 3 with serial number 2 and serial number 1, compare the recognition rate of serial number 3 with the recognition rates of serial number 2 and serial number 1, compare the resolution of serial number 3 with the resolutions of serial number 2 and serial number 1. Through the comparison of recognition rates, it is obtained that the recognition rates of serial number 2 and serial number 1 are both greater than that of serial number 3. Through the comparison of resolutions, it is obtained that the resolution of serial number 2 is less than that of serial number 3. Therefore, the picture quality of the picture of serial number 3 is compressed according to the resolution of serial number 2.
[0108] Based on the description of the embodiments of the above traffic flow recognition and statistics method, the embodiments of the present invention also disclose a traffic flow recognition and statistics system:
[0109] As Figure 2 shown, a traffic flow recognition and statistics system, by applying the above traffic flow recognition and statistics method, includes: a data set establishment module 1, a model training module 2, and a traffic flow recognition module 3;
[0110] The data set establishment module 1 collects video samples of actual traffic intersections to obtain video sample data, processes the video sample data to obtain a picture set; marks the motor vehicles on each picture in the picture set to obtain vehicle marking data, and divides the vehicle marking data according to the built-in vehicle types to obtain labeled data; statistically marks the labeled data and the corresponding pictures to obtain a localized data set;
[0111] The model training module 2 obtains device hardware information, and configures parameters for the built-in initial model framework according to the device hardware information to obtain an initial training model; trains the initial training model based on the localized data set, and monitors the initial training model during the training process to determine the training results of the initial training model to obtain a mature detection model;
[0112] The traffic flow recognition module 3 obtains road video data for which traffic flow needs to be counted, inputs the road video data into the mature detection model for vehicle recognition to obtain recognition data, and statistically analyzes the recognition data to obtain traffic flow data and outputs it.
[0113] Compared with the existing traffic flow recognition and statistics methods and systems, the present invention improves the accuracy of vehicle recognition.
[0114] The above are all the preferred embodiments of this application. The protection scope of this application is not limited by this. Therefore, all equivalent changes made according to the structure, shape, and principle of this application should be covered within the protection scope of this application.
Claims
1. A road traffic flow identification and statistics method, characterized in that: include: Capturing videos of traffic intersections in actual applications to obtain video sample data, and processing the video sample data to obtain a picture set; Mark the motor vehicles on each picture in the picture set to obtain vehicle marking data, and divide the vehicle marking data according to the built-in vehicle type to obtain annotated data; Statistically mark the labeled data and the corresponding images to obtain a localized data set; Obtain device hardware information, and configure the parameters of the built-in initial model framework according to the device hardware information to obtain the initial training model; The initial training model is trained based on the localized data set, and the initial training model is monitored during the training process to determine the training results of the initial training model and obtain a mature detection model; Obtain the road video data for which traffic flow statistics are required, input the road video data into a mature detection model for vehicle identification, obtain identification data, perform statistical analysis on the identification data, obtain and output traffic flow data.
2. A road traffic flow identification and statistics method according to claim 1, characterized in that: The video of the traffic intersection in actual application is collected to obtain video sample data, and the video sample data is processed to obtain a picture set, specifically: Based on the built-in picture quantity index, randomly extract frames from the video sample data to obtain video frame data; Obtain image resolutions of commonly used video acquisition devices at traffic intersections to obtain an image resolution set; Perform mathematical and statistical judgment on the image resolutions in the image resolution set to determine the basic resolution range; Matching the resolution of the video frame data with the resolution in the basic resolution interval, and adding the video frame data with a resolution equal to the resolution in the basic resolution interval to the picture data group of the corresponding resolution; Compress the video frame data with a resolution greater than the resolution in the basic resolution interval, and add the compressed video frame data to the image data group of the corresponding resolution; The video frame data with a resolution smaller than the resolution in the basic resolution range is not added to the picture data group; The image data groups at different resolutions are uniformly labeled as image sets.
3. A road traffic flow identification and statistics method according to claim 1, characterized in that: The initial training model is trained based on the localized data set, and the initial training model is monitored during the training process to determine the training results of the initial training model and obtain a mature detection model, specifically: Using a model training auxiliary tool with a graphical interface, the training data of the initial training model in training is monitored to determine the monitoring data of the initial training model; Perform statistics on the monitoring data to obtain a data change curve, and read the training status according to the data change curve to determine the training status; If the training state is an abnormal state, the parameters of the initial training model are adjusted and the initial training model is retrained until the training state of the initial training model is a normal state; If the training state of the initial training model is normal, the data change curve is analyzed to determine parameter data with an accuracy greater than a built-in benchmark accuracy, and a mature detection model is obtained.
4. A road traffic flow identification and statistics method according to claim 3, characterized in that: If the training state of the initial training model is normal, the data change curve is analyzed to determine the parameter data with an accuracy greater than the built-in benchmark accuracy, and a mature detection model is obtained, specifically: Judging the changing trend of the data change curve to determine whether the data change of the data change curve is in a stable fluctuation state; If the data change of the data change curve is not in a stable fluctuation state, the initial training model is continuously trained until the data change of the data change curve is in a stable fluctuation state; If the data change of the data change curve is in a stable fluctuation state, stop training the initial training model, and calculate the mean of the data values in the stable fluctuation stage to obtain the recognition accuracy data; The recognition accuracy data is compared with the built-in benchmark accuracy data. If the recognition accuracy is greater than the built-in benchmark accuracy data, the initial training model is marked as a mature detection model.
5. A road traffic flow identification and statistics method according to claim 1, characterized in that: The method of obtaining road video data for which traffic flow statistics are required, inputting the road video data into a mature detection model for vehicle identification, obtaining identification data, performing statistical analysis on the identification data, obtaining and outputting traffic flow data, is specifically as follows: Obtaining intersection information of the road in the road video data, and determining a virtual detection line according to the intersection information; Extract video frames from road video data to obtain image data to be identified, and input the extracted image data to be identified into a mature detection model for vehicle identification; Based on the time data, the image data to be identified is sequentially input into the mature detection model for vehicle identification, and the identification data and the rectangular identification frame corresponding to the identified vehicle are obtained; Match the rectangular recognition frame of the car with the virtual detection line once. When one edge of the rectangular recognition frame coincides with the virtual detection line, it is determined that the car corresponding to the rectangular recognition frame passes through the virtual detection line, and the edge coincident with the virtual detection line is marked as the first edge data; Based on the first edge data and the rectangular recognition frame corresponding to the first edge data, determine the positional relationship between another edge in the corresponding rectangular recognition frame that is parallel to the first edge data and the virtual detection line, determine the driving direction of the vehicle, and obtain driving state data; The recognition data, driving status data and the time data when the first side data of the corresponding rectangular recognition box coincides with the virtual detection line are summarized to obtain the traffic flow data and output it.
6. A road traffic flow identification and statistics method according to claim 5, characterized in that: The video frames of the road video data are extracted to obtain the image data to be identified, and the extracted image data to be identified is input into a mature detection model for vehicle identification, specifically: Extracting video frames from road video data to obtain image data to be judged; Determine the resolution of the road video data based on the road video data, and record it as the resolution to be matched; Perform resolution matching of the resolution to be matched with the built-in recognition rate table, determine the sequence number of the resolution to be matched in the recognition rate table, and mark the sequence number as the video sequence number; Based on the built-in recognition rate table, the video sequence number is judged to determine whether the video sequence number is the first sequence; If the video sequence number is determined to be the first sequence, no image processing is performed on the image data to be determined; If it is determined that the video sequence number is not the first sequence, the video sequence number is screened according to the recognition rate table to obtain a resolution whose sequence number is greater than the video sequence number and whose recognition rate is greater than or equal to the recognition rate corresponding to the video sequence number, and mark it as the first screening result; Perform resolution screening on the first screening result, obtain a resolution smaller than the resolution to be matched, and mark it as the second screening result; The image data to be judged is compressed based on the resolution corresponding to the second screening result to obtain the image data to be identified, and the image data to be identified is input into a mature detection model for vehicle identification.
7. A road traffic flow identification and statistics system, characterized in that: The system is used to implement a road traffic flow identification and statistics method as described in any one of claims 1 to 6: comprising: a data set establishment module, a model training module and a traffic flow identification module; The data set establishment module collects videos of traffic intersections in actual application to obtain video sample data, and processes the video sample data to obtain a picture set; marks the motor vehicles on each picture in the picture set to obtain vehicle marking data, and divides the vehicle marking data according to the built-in vehicle types to obtain marked data; and statistically marks the marked data and the corresponding pictures to obtain a localized data set; The model training module obtains device hardware information, and configures parameters of the built-in initial model framework according to the device hardware information to obtain an initial training model; trains the initial training model based on a localized data set, and monitors the initial training model during the training process to determine the training results of the initial training model and obtain a mature detection model; The traffic flow identification module obtains road video data for which traffic flow statistics are required, and inputs the road video data into a mature detection model for vehicle identification to obtain identification data, performs statistical analysis on the identification data, obtains and outputs vehicle flow data.