Traffic jam detection method and device, electronic equipment and storage medium
Through video stream acquisition and traffic congestion detection model analysis, combined with discrete event simulation model to generate route suggestions, the traditional method's problems of bad weather and artificial dependence are solved, and efficient and automated traffic congestion management and intelligent route planning are achieved.
Patent Information
- Application Number
- CN202411653388.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-02-28
AI Technical Summary
Traditional traffic congestion detection methods perform poorly in bad weather conditions and rely on manual monitoring, resulting in inefficiency and difficulty in achieving automated management.
By collecting video streams, storing them as image frames, and entering a traffic congestion detection model to obtain traffic congestion status and current traffic data. Enter the current traffic data into the discrete event simulation model, generate diversion strategies and route planning suggestions, and finally send this information to the navigation device.
Accurate traffic congestion detection and analysis under severe weather conditions is achieved, traffic efficiency is improved, real-time and intelligent route planning is provided, and user experience is improved.
Smart Images

Figure CN119541197A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of traffic management technology, and in particular to a traffic congestion detection method and device, an electronic device and a storage medium. Background Art
[0002] Traffic congestion is an important issue in urban traffic management. Traditional congestion detection methods mainly rely on ground sensors, cameras and traffic flow models. Traditional methods can monitor traffic conditions to a certain extent, but they often have some defects. For example, traditional methods perform poorly in adverse weather conditions such as rain, snow, and fog, resulting in reduced accuracy of data collection and analysis; some traditional methods rely on manual monitoring and intervention, resulting in low efficiency and difficulty in achieving automated management.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a traffic congestion detection method and device, an electronic device and a storage medium, aiming to accurately analyze the congestion situation and improve traffic efficiency.
[0005] To achieve the above object, one aspect of an embodiment of the present application provides a traffic congestion detection method, the method comprising the following steps:
[0006] Capture video streams and store them as image frames;
[0007] Inputting the image frame into a traffic congestion detection model to obtain a traffic congestion state and current traffic data;
[0008] Inputting the current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions;
[0009] The diversion strategy, the route planning suggestion and the traffic congestion status are sent to a navigation device.
[0010] In some embodiments, the stored image frames are preprocessed, and the preprocessing includes using contrast-constrained adaptive histogram equalization to enhance the contrast of the image and suppress noise.
[0011] In some embodiments, inputting the image frame into a traffic congestion detection model to obtain a traffic congestion state and current traffic data includes:
[0012] Inputting the image frame into a traffic congestion detection model;
[0013] Extracting image features of the image frame by using the traffic congestion detection model;
[0014] Determining the traffic congestion state according to the image features by using the traffic congestion detection model;
[0015] The current traffic data is outputted through the traffic congestion detection model, and the current traffic data includes vehicle flow, vehicle speed, congestion status, specific congestion range and specific congested lane.
[0016] In some embodiments, the image features include a detection box in each grid unit, and determining the traffic congestion state according to the image features by the traffic congestion detection model includes:
[0017] Eliminate overlapping detection frames by using non-maximum suppression through the traffic congestion detection model and retain the detection frame with the highest confidence, wherein the information of the detection frame includes target category, bounding box and confidence;
[0018] Obtaining target information of each detection frame through the traffic congestion detection model, wherein the target information includes vehicle position, category and confidence;
[0019] Using the target tracking algorithm through the traffic congestion detection model to obtain the movement trajectory of the vehicle;
[0020] Counting the number of vehicles in each detection frame by using the traffic congestion detection model;
[0021] Acquire the corresponding road capacity according to the vehicle position;
[0022] Calculating a congestion index according to the number of vehicles and the road capacity by using the traffic congestion detection model;
[0023] The traffic congestion state is determined according to the congestion index by using the traffic congestion detection model.
[0024] In some embodiments, the preprocessing of the stored image frames comprises:
[0025] Dividing the image frame into a plurality of small areas, wherein the small areas are square or rectangular;
[0026] Calculate the grayscale histogram of each small area;
[0027] Performing equalization processing on the grayscale histogram of each small area;
[0028] Performing contrast limitation on the histogram of each small area;
[0029] By using bilinear interpolation, the equalization results of each small area are combined to obtain the preprocessed image frame.
[0030] In some embodiments, the traffic congestion detection model includes an input end, a backbone network part, a neck network part, and a head network part, and the method further includes a step of training the traffic congestion detection model, wherein the training traffic congestion detection model includes:
[0031] Acquire historical traffic images, and randomly divide the historical traffic images into a training set and a test set, wherein the historical traffic images include true frames;
[0032] Inputting the training set to an input end for image processing, the input end performing a data enhancement algorithm, an adaptive anchor box calculation, and an adaptive image scaling operation;
[0033] The training set images processed by the input end are transmitted to the backbone network part, the feature map is extracted and optimized by the backbone network part, and the feature map is input into the neck network part;
[0034] The neck network part uses a feature pyramid network and a path aggregation network for instance segmentation to fuse the feature map, and inputs the fused features into the head network part;
[0035] The head network part performs target detection based on the fused features, outputs a predicted box, and uses a loss function to evaluate the difference between the predicted box and the true box.
[0036] In some embodiments, inputting the current traffic data into a discrete event simulation model to generate a diversion strategy and a route planning suggestion includes:
[0037] Establishing a simulation model of an urban traffic network, wherein the simulation model of the urban traffic network includes a road model, an intersection model and a signal light model;
[0038] Setting simulation initial conditions based on the current traffic data, the initial conditions including the vehicle's starting position, destination, and travel path;
[0039] updating simulation parameters according to the current traffic data, wherein the simulation parameters include a vehicle starting position, a destination, and a driving path, and the simulation parameters are used to simulate traffic conditions;
[0040] Running the simulation model of the urban traffic network to evaluate the congestion situation under the current traffic state, wherein the evaluation parameters of the congestion situation include average travel time and congestion duration;
[0041] If the congestion condition under the current traffic state is that there is a congestion event, a diversion strategy is generated according to preset conditions, and a route planning suggestion is generated in the discrete event simulation model according to the traffic condition and the diversion strategy using an optimization algorithm, and the route planning suggestion includes the best detour route for the affected vehicles.
[0042] To achieve the above object, another aspect of the embodiment of the present application provides a traffic congestion detection device, the device comprising:
[0043] The acquisition module is used to acquire video streams and store them as image frames;
[0044] A congestion detection module, used for inputting the image frame into a traffic congestion detection model to obtain a traffic congestion state and current traffic data;
[0045] A suggestion generation module, used for inputting the current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions;
[0046] The sending module is used to send the diversion strategy, the route planning suggestion and the traffic congestion status to the navigation device.
[0047] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.
[0048] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0049] The embodiments of the present application include at least the following beneficial effects: the present application provides a traffic congestion detection method and device, an electronic device and a storage medium. The scheme collects video streams and stores them as image frames; inputs the image frames into a traffic congestion detection model to obtain traffic congestion status and current traffic data, thereby detecting traffic flow in real time and accurately analyzing congestion conditions; inputs current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions, thereby reducing congestion and improving traffic efficiency; and sends diversion strategies, route planning suggestions and traffic congestion status to a navigation device to provide real-time, intelligent route planning, enhance user experience, and improve traffic efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is a flow chart of a traffic congestion detection method provided in an embodiment of the present application;
[0051] Figure 2 yes Figure 1 Flow chart of step S102 in FIG.
[0052] Figure 3 yes Figure 2 Flow chart of step S203 in FIG.
[0053] Figure 4 is a flow chart of the preprocessing steps of the traffic congestion detection method provided in an embodiment of the present application;
[0054] Figure 5 It is a flow chart of the steps of training a traffic congestion detection model of the traffic congestion detection method provided in an embodiment of the present application;
[0055] Figure 6 yes Figure 1 Flow chart of step S103 in FIG.
[0056] Figure 7 is another flow chart of the traffic congestion detection method provided in the embodiment of the present application;
[0057] Figure 8 It is a flow chart of the steps of a discrete event simulation model of a machine vision-based traffic congestion detection method provided in an embodiment of the present application;
[0058] Fig. 9 is a structural schematic diagram of a traffic congestion detection device provided in an embodiment of the present application;
[0059] Fig.10 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0061] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0062] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0064] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0065] 1) YOLOv5 (You Only Look Once version 5) is a deep learning-based target detection model that aims to achieve real-time object detection.
[0066] Traffic congestion is an important issue in urban traffic management. Traditional congestion detection methods mainly rely on ground sensors, cameras and traffic flow models. Traditional methods can monitor traffic conditions to a certain extent, but they often have some defects. For example, traditional methods perform poorly in adverse weather conditions such as rain, snow, and fog, resulting in reduced accuracy of data collection and analysis; some traditional methods rely on manual monitoring and intervention, resulting in low efficiency and difficulty in achieving automated management.
[0067] In view of this, a traffic congestion detection method, device, equipment and medium are provided in the embodiments of the present application. The scheme collects video streams and stores them as image frames; inputs the image frames into the traffic congestion detection model to obtain the traffic congestion status and current traffic data, thereby detecting traffic flow in real time and accurately analyzing the congestion situation; inputs the current traffic data into the discrete event simulation model to generate diversion strategies and route planning suggestions, thereby reducing congestion and improving traffic efficiency; and sends the diversion strategies, route planning suggestions and traffic congestion status to the navigation device to provide real-time, intelligent route planning, enhance user experience and improve traffic efficiency.
[0068] The traffic congestion detection method provided in the embodiment of the present application relates to the field of traffic management technology. The traffic congestion detection method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The server can also be a node server in a blockchain network; the software can be an application that implements the traffic congestion detection method, etc., but is not limited to the above forms.
[0069] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0070] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0071] Figure 1 is an optional flow chart of the traffic congestion detection method provided in the embodiment of the present application. Figure 1The method may include but is not limited to steps S101 to S106.
[0072] Step S101, capturing a video stream and storing it as an image frame.
[0073] Specifically, the preprocessing includes using contrast-constrained adaptive histogram equalization to enhance the contrast of the image and suppress noise.
[0074] In some embodiments, a video stream is captured by a video capture device, image frames are extracted using video decoding technology, and the image frames are stored in a server or a local storage device.
[0075] It can be understood that the video stream can be a real-time video stream or a stored video stream.
[0076] Optionally, an efficient compression method is used to store the image frames.
[0077] It is understandable that the video acquisition device may be a single device or multiple devices.
[0078] Furthermore, the stored image frames are preprocessed.
[0079] In this embodiment, video streams are collected and stored as image frames, preparing for subsequent detection of traffic congestion.
[0080] Step S102: input the image frame into a traffic congestion detection model to obtain the traffic congestion status and current traffic data.
[0081] Specifically, the current traffic data includes vehicle flow, vehicle speed, congestion status, specific congestion range, and specific congested lanes.
[0082] In some embodiments, the preprocessed image frames are input into a pre-trained traffic congestion detection model, and the traffic density is analyzed by the traffic congestion detection model to obtain the traffic congestion status and current traffic data.
[0083] Optionally, the traffic congestion detection model may adopt a YOLOv5 model or a convolutional neural network model.
[0084] In some embodiments, an image frame is input into a traffic congestion detection model; image features of the image frame are extracted through the traffic congestion detection model; traffic congestion status is determined according to the image features through the traffic congestion detection model; and current traffic data is output through the traffic congestion detection model.
[0085] In this embodiment, the image frame is input into the traffic congestion detection model to obtain the traffic congestion status and current traffic data, which is conducive to real-time detection of traffic flow and judgment of traffic status, and is conducive to accurate analysis of congestion conditions, providing data support for the subsequent generation of diversion strategies and route planning suggestions.
[0086] Step S103, inputting current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions.
[0087] Specifically, the route planning suggestion includes the best detour route for the affected vehicles.
[0088] In some embodiments, traffic flow is simulated based on current traffic data.
[0089] The current traffic data is input into the simulation model, and the model calculates the traffic flow distribution, congested sections, road network load conditions, etc., and then generates diversion strategies and route planning suggestions through the discrete event simulation model.
[0090] In some embodiments, a simulation model of an urban traffic network is established; initial simulation conditions are set based on current traffic data; simulation parameters are updated according to current traffic data; the simulation model of the urban traffic network is run to evaluate the congestion situation under the current traffic conditions; if the congestion situation under the current traffic conditions indicates that there is a congestion event, a diversion strategy is generated through preset conditions, and a route planning suggestion is generated in a discrete event simulation model based on the traffic conditions and the diversion strategy using an optimization algorithm.
[0091] Optionally, historical traffic data is introduced to enable the discrete event simulation model to generate more accurate diversion strategies.
[0092] In this embodiment, current traffic data is input into a discrete event simulation model to generate diversion strategies and route planning suggestions, and provide a traffic management solution based on real-time data, which is conducive to reducing congestion and improving traffic efficiency.
[0093] Step S104, sending the diversion strategy, route planning suggestions and traffic congestion status to the navigation device.
[0094] In some embodiments, the diversion strategy, route planning suggestions and traffic congestion status are sent to the navigation device, and the user is notified of the traffic congestion through the navigation device, and route planning suggestions are given.
[0095] Optionally, current traffic data and advice received are integrated by the navigation system to send notifications to the driver's navigation device.
[0096] Among them, the navigation device will show the specific scope of traffic congestion and the specific lane marked in red.
[0097] Optionally, the congestion conditions are divided into congestion, slow movement and smooth movement, with the congestion state indicated by red, the slow movement state indicated by yellow, and the smooth movement state indicated by green.
[0098] Furthermore, when the driver chooses a new route plan, the navigation device will feed back the driver's choice and whether it avoids congestion to the discrete event simulation model. Based on the feedback information, the driver's selection rate of the new route plan is counted, and the traffic conditions on the new route plan are continuously monitored. The effectiveness of the new route plan is evaluated, and the route plan and suggestions are further optimized until the congestion is completely alleviated.
[0099] Among them, the traffic congestion detection model monitors new traffic data and collects feedback information from navigation equipment and feeds it back to the discrete event simulation model to further optimize route planning and suggestions to achieve real-time road unblocking effects.
[0100] It is understandable that while the driver is driving, the discrete event simulation model dynamically updates the route to the navigation system, and the navigation system simultaneously pushes the latest route suggestions to the driver's device.
[0101] In this embodiment, the diversion strategy, route planning suggestions and traffic congestion status are sent to the navigation device, which is conducive to providing real-time and intelligent route planning, improving user experience and improving traffic efficiency.
[0102] Steps S101 to S104 shown in the embodiment of the present application are performed by collecting video streams and storing them as image frames; inputting the image frames into a traffic congestion detection model to obtain traffic congestion status and current traffic data, thereby detecting traffic flow in real time and accurately analyzing congestion conditions; inputting current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions, thereby reducing congestion and improving traffic efficiency; and sending diversion strategies, route planning suggestions and traffic congestion status to a navigation device to provide real-time, intelligent route planning, enhance user experience, and improve traffic efficiency.
[0103] See also Figure 2 In some embodiments, step S102 may include but is not limited to steps S201 to S204:
[0104] Step S201: input the image frame into the traffic congestion detection model.
[0105] In step S201 of some embodiments, the preprocessed image frame is input into a traffic congestion detection model.
[0106] Step S202: extracting image features of the image frame through a traffic congestion detection model.
[0107] In step S202 of some embodiments, a detection frame of the image frame is extracted using a YOLOv5 traffic congestion detection model.
[0108] Optionally, features such as traffic density, road occupancy, and road type are extracted through a convolutional neural network.
[0109] In this embodiment, the image features of the image frame are extracted through the traffic congestion detection model, which prepares for the subsequent congestion state judgment.
[0110] Step S203: determining the traffic congestion state according to the image features through a traffic congestion detection model.
[0111] In step S203 of some embodiments, non-maximum suppression is used through a traffic congestion detection model to eliminate overlapping detection frames and retain the detection frame with the highest confidence; the target information of each detection frame is obtained through the traffic congestion detection model; the movement trajectory of the vehicle is obtained by using a target tracking algorithm through the traffic congestion detection model; the number of vehicles in each detection frame is counted through the traffic congestion detection model; the corresponding road capacity is obtained according to the vehicle position; the congestion index is calculated according to the number of vehicles and the road capacity through the traffic congestion detection model; and the traffic congestion status is determined according to the congestion index through the traffic congestion detection model.
[0112] Furthermore, dynamic scheduling optimization can be achieved, and image features can be updated according to the real-time detected traffic conditions, thereby updating the traffic congestion status.
[0113] In this embodiment, the traffic congestion state is determined according to the image features by using the traffic congestion detection model, which is helpful to accurately judge the traffic conditions and identify the traffic congestion state.
[0114] Step S204: output current traffic data through the traffic congestion detection model.
[0115] Specifically, the current traffic data includes vehicle flow, vehicle speed, congestion status, specific congestion range, and specific congested lanes.
[0116] In step S204 of some embodiments, current traffic data is input into a discrete event simulation model through a traffic congestion detection model.
[0117] In this embodiment, the current traffic data is outputted through the traffic congestion detection model, so as to prepare for the subsequent generation of diversion strategies and route planning suggestions.
[0118] See also Figure 3 In some embodiments, step S203 may include but is not limited to steps S301 to S307:
[0119] Step S301 : Using a traffic congestion detection model and non-maximum suppression, the overlapping detection frames are eliminated and the detection frame with the highest confidence is retained.
[0120] Specifically, the information of the detection box includes the target category, bounding box and confidence;
[0121] In step S301 of some embodiments, non-maximum suppression is used to eliminate overlapping detection frames, and the formula for retaining the detection frame with the highest confidence is as follows:
[0122]
[0123] Among them, B represents the set of detection boxes; b i Represented as the i-th detection box; b j Represented as the jth detection box; IoU(b i ,b j ) is represented as the detection box b i and b j The intersection-and-union ratio of ; threshold represents the threshold value;
[0124] It should be noted that the intersection-and-union ratio formula is as follows:
[0125]
[0126] Among them, A and C represent the detection frames; A∩C represents the overlapping area of the two detection frames; A∪C represents the union area of the two detection frames;
[0127] Step S302: Obtain target information of each detection frame through a traffic congestion detection model.
[0128] Specifically, the target information includes vehicle location, category, and confidence.
[0129] In step S302 of some embodiments, the information expression of the detection box is as follows:
[0130] bboxi=(xi,yi,wi,hi,ci,pi)
[0131] Among them, xi and yi represent the center coordinates of the detection box; wi and hi represent the width and height of the detection box; ci represents the vehicle category; and pi represents the confidence level.
[0132] Step S303, using a target tracking algorithm through a traffic congestion detection model to obtain a motion trajectory of the vehicle.
[0133] Optionally, the target tracking algorithm may adopt a CamShift algorithm or a Deep SORT algorithm, but is not limited thereto.
[0134] In step S303 of some embodiments, the Deep SORT algorithm is used to track the detected vehicle to obtain the movement trajectory of the vehicle.
[0135] Step S304: Count the number of vehicles in each detection frame using a traffic congestion detection model.
[0136] In step S304 of some embodiments, the number of vehicles in each detection frame is counted, and the formula for the number of vehicles is as follows:
[0137]
[0138] Among them, N t It is represented by the number of vehicles in time t; M is represented by the number of detection boxes; Expressed as an indicator function, if the detection box b i If it is a vehicle, it is 1, otherwise it is 0.
[0139] Step S305, obtaining the corresponding road capacity according to the vehicle position.
[0140] In some embodiments, the road where the vehicle is located is determined based on the vehicle position, and then the corresponding road capacity is obtained.
[0141] Step S306, calculating the congestion index according to the number of vehicles and road capacity through the traffic congestion detection model.
[0142] In some embodiments, the congestion index is calculated based on the number of vehicles and the road capacity. The formula of the congestion index is as follows:
[0143]
[0144] Among them, C t Expressed as the congestion index within time t; N t Expressed as the number of vehicles in time t; C max Expressed as the maximum capacity of the road.
[0145] Step S307: determining the traffic congestion state according to the congestion index through a traffic congestion detection model.
[0146] In some embodiments, traffic congestion status is divided into congestion, slow traffic and smooth traffic according to the congestion index.
[0147] Optionally, the traffic congestion state is determined by a congestion threshold and a congestion index.
[0148] For example, the congestion threshold is 0.8 and the busy threshold is 0.5. When the congestion index is ≥ 0.8, the congestion condition is congested; when 0.8> the congestion index ≥ 0.5, the congestion condition is slow; when 0.5> the congestion index, the congestion condition is smooth.
[0149] See also Figure 4In some embodiments, the traffic congestion detection method further includes a preprocessing step of the stored image frames, and the preprocessing step may include but is not limited to steps S401 to S405:
[0150] Step S401, dividing the image frame into a plurality of small areas.
[0151] Specifically, the small area is a square or a rectangle.
[0152] Step S402, calculating the grayscale histogram of each small area.
[0153] In step S402 of some embodiments, a grayscale histogram is calculated for each small area, and the formula of the grayscale histogram is as follows:
[0154]
[0155] Among them, H k (g) is the histogram of small area k; h(d,e) is the gray value of the pixel in the dth row and the eth column; R k It is represented as the range of a small region k; δ(x) is represented as the Kronecker function, which is 1 when x=0 and 0 otherwise.
[0156] Step S403, performing equalization processing on the grayscale histogram of each small area.
[0157] In step S403 of some embodiments, the histogram of each small area is equalized, and the cumulative distribution function formula is as follows:
[0158]
[0159] Among them, CDF k It is expressed as the cumulative distribution function of a small area k; H k (l) is represented by the histogram value of gray level l in small area k, that is, the number of times gray level l appears;
[0160] Furthermore, the formula for the grayscale value after equalization is as follows:
[0161]
[0162] Among them, s k (g) represents the gray value after equalization in the small area k; T represents the target gray level; N k It is represented as the total number of pixels in the small area k.
[0163] Step S404: performing contrast limitation on the histogram of each small area.
[0164] In some embodiments, a contrast limit is applied to the histogram of each small region, and when the histogram of the gray level exceeds the contrast limit threshold, it is clipped to the contrast limit threshold;
[0165] Step S405: using bilinear interpolation, the equalization results of each small area are combined to obtain a preprocessed image frame.
[0166] In some embodiments, bilinear interpolation is used to merge the equalization results of each small area, and the final equalized gray value formula is as follows:
[0167]
[0168] Where (m,n) represents the pixel position; s(m,n) represents the final equalized grayscale value of pixel (m,n); s k (g) represents the gray value after equalization in the small area k; h(m,n) represents the gray value of pixel (m,n); W k Represented as weight; neighbors(m,n) is represented as the set of small areas to which pixel (m,n) belongs.
[0169] See also Figure 5 In some embodiments, the traffic congestion detection method further includes a step of training a traffic congestion detection model. The step of training a traffic congestion detection model may include but is not limited to steps S501 to S505:
[0170] Step S501: Acquire historical traffic images, and randomly divide the historical traffic images into a training set and a test set.
[0171] Specifically, the historical traffic image includes a real frame, and the traffic congestion detection model includes an input end, a Backbone part (i.e., a backbone network part), a Neck part (i.e., a neck network part) and a Head part (i.e., a head network part).
[0172] In some embodiments, the traffic congestion detection model is trained using a training set.
[0173] Step S502: input the training set to the input end for image processing.
[0174] Specifically, the input end performs data enhancement algorithm, adaptive anchor box calculation and adaptive image scaling operations.
[0175] In step S502 of some embodiments, a plurality of images are combined into one image according to a certain ratio by a data enhancement algorithm, and the data enhancement algorithm is used to enable the model to recognize the target in a smaller range. For example, a Mosaic data enhancement algorithm is used.
[0176] Furthermore, anchor boxes are dynamically generated according to the target size and shape in the training set through adaptive anchor box calculation; this method can reduce the overlap of anchor boxes, improve detection efficiency, and reduce the false detection rate, ultimately making the model perform better in complex scenarios.
[0177] In some embodiments, the image size is dynamically adjusted through adaptive image scaling to unify and standardize the image format.
[0178] Step S503, transmitting the training set images processed by the input end to the backbone network part, extracting and optimizing the feature map through the backbone network part, and inputting the feature map into the neck network part;
[0179] Specifically, the neck network part includes a Focus structure and a CSP structure.
[0180] In step S503 of some embodiments, the input image is divided into multiple small blocks through the Focus structure, and then these small blocks are spliced together to form a new feature map, which reduces the size of the feature map while maintaining important features; this can increase the number of channels and reduce the spatial dimension; the Focus structure helps the model improve accuracy and efficiency when processing complex scenes by optimizing the generation method of the feature map;
[0181] Furthermore, the CSP structure divides the input feature map into two parts, one part is processed by multiple convolutional layers, and the other part remains as it is, and then the features of the two parts are combined in the subsequent layers; the CSP structure not only improves the diversity of features, but also optimizes the use of computing resources; in tasks such as object detection and image classification, the CSP structure can significantly improve the accuracy of the model while maintaining low computing costs and memory usage.
[0182] Step S504, the neck network part uses a feature pyramid network and a path aggregation network for instance segmentation to fuse the feature map, and inputs the fused features into the head network part.
[0183] In step S504 of some embodiments, the feature pyramid network creates feature maps of different scales by constructing a pyramid feature map, and combines low-level features with high-level features through upsampling, so that the model can extract features at different scales, thereby improving the detection capability of small objects.
[0184] It should be noted that the path aggregation network used for instance segmentation enhances the fusion of high-level semantic information and low-level detail information by horizontally connecting and aggregating features of different layers, thereby improving detection accuracy.
[0185] It can be understood that the feature pyramid network provides top-down feature transfer; the path aggregation network for instance segmentation provides bottom-up feature fusion; forming a more efficient information flow path.
[0186] Step S505, the head network part performs target detection based on the fused features, outputs a predicted box, and uses a loss function to evaluate the difference between the predicted box and the true box.
[0187] In step S505 of some embodiments, the difference between the predicted frame and the real frame is evaluated by a loss function to improve positioning accuracy and enhance the performance of the traffic congestion detection model.
[0188] Optionally, a difference threshold is set, and the traffic congestion detection model is regularly trained until the difference between the predicted frame and the real frame is less than the difference threshold, thereby obtaining the traffic congestion detection model.
[0189] Furthermore, after the training of the traffic congestion detection model is completed, the test set is input into the traffic congestion detection model to obtain the detection results, the detection results are compared with the true annotations of the test set, the average precision mean is calculated, and the model optimization is completed based on the average precision mean.
[0190] See also Figure 6 In some embodiments, step S103 includes but is not limited to steps S601 to S605:
[0191] Step S601, establishing a simulation model of the urban transportation network.
[0192] Specifically, the simulation model of the urban traffic network includes a road model, an intersection model and a traffic light model.
[0193] Step S602, setting the initial conditions of the simulation based on the current traffic data.
[0194] Specifically, the initial conditions include the vehicle's starting position, destination, and driving path.
[0195] In step S602 of some embodiments, the simulation initial conditions are set for the model using current traffic data.
[0196] Step S603: Update simulation parameters according to current traffic data.
[0197] Specifically, the simulation parameters include the vehicle's starting position, destination, and driving path, and the simulation parameters are used to simulate traffic conditions.
[0198] It is understandable that traffic simulation requires continuous adjustment and updating of simulation parameters based on current traffic data.
[0199] In some embodiments, the vehicle position expression is as follows:
[0200] update_state(t)=(new_position,new_path);
[0201] Where update_state(t) represents the position at time t; t represents the current time; new_position represents the new position of the vehicle; new_path represents the new driving path of the vehicle;
[0202] Step S604, running the simulation model of the urban traffic network to evaluate the congestion situation under the current traffic conditions.
[0203] Specifically, the evaluation parameters of the congestion condition include average travel time and congestion duration.
[0204] In some embodiments, a simulation model of an urban traffic network is run to simulate traffic flow and congestion conditions, and to evaluate congestion conditions under current traffic conditions.
[0205] Step S605: If the congestion condition under the current traffic state is that there is a congestion event, a diversion strategy is generated according to preset conditions, and a route planning suggestion is generated in a discrete event simulation model according to the traffic condition and the diversion strategy using an optimization algorithm.
[0206] Specifically, the route planning suggestions include the best detour routes and estimated travel times for affected vehicles.
[0207] In some embodiments, a corresponding event is triggered according to a preset condition, and triggering the corresponding event according to the preset condition includes diverting traffic when congestion occurs (ie, generating a diversion strategy).
[0208] It can be understood that after identifying the congestion, the optimization algorithm is used to generate the best detour route for the affected vehicles in the discrete event simulation model according to the traffic conditions and diversion strategy. The expression of the best detour route is as follows:
[0209] optimal_path=find_path(G,s,d,current_traffic);
[0210] Among them, optimal_path represents the optimal path; find_path represents the path to be found; G represents the traffic network diagram; s represents the current position of the vehicle; d represents the destination of the vehicle; current_traffic represents the current traffic conditions;
[0211] Furthermore, route planning suggestions are generated in a discrete event simulation model.
[0212] Understandably, the detour route is dynamically adjusted according to real-time traffic conditions to ensure that vehicles can be cleared quickly.
[0213] Figure 7 is another optional flow chart of the traffic congestion detection method provided in the embodiment of the present application. Figure 7 The method may include but is not limited to the following steps.
[0214] Step S1, using high-definition cameras installed at intersections and road sections to collect video streams and store them as image frames, using the YOLOv5 traffic congestion detection model to monitor traffic conditions in real time, obtain real-time traffic data, evaluate traffic congestion status and determine the specific scope and lanes of traffic congestion.
[0215] In this embodiment, the traffic congestion detection model adopts the YOLOv5 traffic congestion detection model.
[0216] In step S1 of some embodiments, the stored image frames are subjected to data preprocessing, and the preprocessing includes using contrast-limited adaptive histogram equalization to enhance the contrast of the image and suppress noise.
[0217] In some embodiments, the contrast-limited adaptive histogram equalization is used to divide the image frame into a plurality of small areas, each of which is a square or a rectangle, and the size of each small area is M×N pixels;
[0218] Calculate the grayscale histogram for each small area. The grayscale histogram formula is as follows:
[0219]
[0220] Among them, H k (g) is the histogram of small area k; h(d,e) is the gray value of the pixel in the dth row and the eth column; R k It is represented as the range of the small region k; δ(x) is represented as the Kronecker function, which is 1 when x = 0 and 0 otherwise;
[0221] Furthermore, the histogram of each small area is equalized, and the cumulative distribution function formula is as follows:
[0222]
[0223] Among them, CDF k It is expressed as the cumulative distribution function of a small area k; H k (l) is represented by the histogram value of gray level l in small area k, that is, the number of times gray level l appears;
[0224] It can be understood that the gray value after equalization is as follows:
[0225]
[0226] Among them, s k (g) represents the gray value after equalization in the small area k; T represents the target gray level; N k It is expressed as the total number of pixels in the small area k;
[0227] Optionally, a contrast limit is applied to the histogram of each small region, and when the histogram of the gray level exceeds the contrast limit threshold, it is clipped to the contrast limit threshold;
[0228] In some embodiments, bilinear interpolation is used to combine the equalization results of each small area, and the formula is as follows:
[0229]
[0230] Where (m,n) represents the pixel position; s(m,n) represents the final equalized grayscale value of pixel (m,n); s k (g) represents the gray value after equalization in the small area k; h(m,n) represents the gray value of pixel (m,n); W k Represented as weight; neighbors(m,n) is represented as the set of small areas to which pixel (m,n) belongs.
[0231] Furthermore, the preprocessed image frames are input into the YOLOv5 traffic congestion detection model for recognition;
[0232] Among them, the YOLOv5 traffic congestion detection model extracts image features through convolutional neural networks and predicts the target category, bounding box and confidence in each grid cell;
[0233] Specifically, non-maximum suppression is used to eliminate overlapping detection frames. The information of the detection frame includes the target category, bounding box and confidence. The detection frame with the highest confidence is retained. The detection frame formula is as follows:
[0234]
[0235] Among them, B represents the set of detection boxes; b i Represented as the i-th detection box; b j Represented as the jth detection box; IoU(b i ,b j ) is represented as the detection box b i and b j The intersection-and-union ratio of ; threshold represents the threshold value;
[0236] It should be noted that the intersection-and-union ratio formula is as follows:
[0237]
[0238] Among them, A and C represent detection boxes; A∩C represents the overlapping area of the two detection boxes; A∪C represents the union area of the two detection boxes.
[0239] For example, when b i and b j The overlapping area is 20 square centimeters, b i The area of b is 50 square centimeters. j The area of the object is 60 square centimeters, then IoU(b i ,b j ) = 20 / (50 + 60 - 20) = 0.22;
[0240] Furthermore, the information of each detection box is obtained, including the vehicle position, category and confidence level; the information of the detection box bbox i =(x i ,y i ,w i ,h i ,c i ,p i ), where x i and i Represented as the center coordinate of the detection box; w i and h i Expressed as the width and height of the detection box; c i Represents the vehicle category; p i Expressed as confidence;
[0241] Optionally, the Deep SORT algorithm is used to track the detected vehicle to obtain the vehicle's motion trajectory;
[0242] In some embodiments, the number of vehicles in each detection frame is counted, and the formula is as follows:
[0243]
[0244] Among them, N t It is represented by the number of vehicles in time t; M is represented by the number of detection boxes; Expressed as an indicator function, if the detection box b i If it is a vehicle, it is 1, otherwise it is 0;
[0245] Specifically, the congestion index is calculated based on the number of vehicles and road capacity, and the formula is as follows:
[0246]
[0247] Among them, C t Expressed as the congestion index within time t; N tExpressed as the number of vehicles in time t; C max It is expressed as the maximum capacity of the road;
[0248] For example, the maximum road capacity is 100 vehicles, and the current number of vehicles is 80, then: C t =100 / 80=0.8;
[0249] According to the congestion index, the congestion conditions are divided into congested, slow traffic and smooth traffic;
[0250] When C t When ≥0.8, the congestion condition is congested;
[0251] When 0.8>C t When ≥0.5, the congestion condition is slow traffic;
[0252] When 0.5>C t When , the congestion condition is smooth;
[0253] Current C t =0.8≥0.8, so the current congestion condition is congestion;
[0254] The YOLOv5 traffic congestion detection model determines the specific scope of traffic congestion through the coverage of the congestion situation, detects the specific lane where the traffic congestion occurs, and marks the specific scope and specific lane where the traffic congestion occurs in red.
[0255] The YOLOv5 traffic congestion detection model outputs real-time traffic data (i.e., current traffic data), which includes vehicle flow, vehicle speed, congestion status, specific congestion range, and specific congested lanes.
[0256] Optionally, the congestion conditions are divided into congestion, slow traffic and smooth traffic according to the congestion index.
[0257] According to the above scheme, the YOLOv5 traffic congestion detection model includes an input end, a Backbone part, a Neck part and a Head part.
[0258] According to the above scheme, the historical traffic images are randomly divided into training set and test set;
[0259] Specifically, the training set images are input to the input end for image processing, which includes the Mosaic data enhancement algorithm, adaptive anchor box calculation, and adaptive image scaling;
[0260] It can be understood that the Mosaic data enhancement algorithm is used to combine multiple pictures into one picture according to a certain ratio; the Mosaic data enhancement algorithm is used to enable the model to recognize the target in a smaller range;
[0261] It should be noted that adaptive anchor box calculation is used to dynamically generate anchor boxes based on the target size and shape in the training set; this method can reduce the overlap of anchor boxes, improve detection efficiency, and reduce the false detection rate, ultimately making the model perform better in complex scenes;
[0262] Among them, adaptive image scaling is used to dynamically adjust the image size and standardize the image format;
[0263] Furthermore, after being processed by the input end, the training set images are transmitted to the Backbone part, which includes the Focus structure and the CSP structure;
[0264] The Focus structure divides the input image into multiple small blocks, and then stitches these small blocks together to form a new feature map, which reduces the size of the feature map while maintaining important features. This can increase the number of channels and reduce the spatial dimension. The Focus structure helps the model improve accuracy and efficiency when processing complex scenes by optimizing the way feature maps are generated.
[0265] It should be noted that the CSP structure divides the input feature map into two parts, one part is processed by multiple convolutional layers, and the other part remains as it is, and then the features of the two parts are combined in the subsequent layers; the CSP structure not only improves the diversity of features, but also optimizes the use of computing resources; in tasks such as object detection and image classification, the CSP structure can significantly improve the accuracy of the model while maintaining low computing costs and memory usage;
[0266] Furthermore, the Neck part adopts a combination of a feature pyramid network and a path aggregation network for instance segmentation.
[0267] Among them, the feature pyramid network creates feature maps of different scales by constructing pyramid feature maps, and combines low-level features with high-level features through upsampling, so that the model can extract features at different scales, thereby improving the detection ability of small objects;
[0268] Among them, the path aggregation network for instance segmentation enhances the fusion of high-level semantic information and low-level detail information by horizontally connecting and aggregating features of different layers, thereby improving detection accuracy;
[0269] It can be understood that the feature pyramid network provides top-down feature transfer; the path aggregation network for instance segmentation provides bottom-up feature fusion; forming a more efficient information flow path;
[0270] It should be noted that the Head part includes the Bounding box loss function, which evaluates the difference between the predicted box and the real box, improves the positioning accuracy, and improves the performance of the YOLOv5 traffic congestion detection model.
[0271] According to the above scheme, after the training of the YOLOv5 traffic congestion detection model is completed, the test set is input into the YOLOv5 traffic congestion detection model to obtain the detection results, the detection results are compared with the true annotations of the test set, the average precision mean is calculated, and the model optimization is completed based on the average precision mean.
[0272] Step S2, input the acquired real-time traffic data into the discrete event simulation model, generate diversion strategies through discrete event simulation, and optimize route planning suggestions, and transmit the optimized route planning, traffic data and traffic congestion status evaluation to the navigation system via the Internet.
[0273] In step S2 of some embodiments, a simulation model of the urban traffic network is established, including a road model, an intersection model, and a signal light model; the initial conditions of the simulation are set by real-time traffic data, and the initial conditions include the vehicle's starting position, destination, and driving path; the simulation parameters are dynamically updated according to the real-time traffic data to generate specific route planning suggestions, and the simulation parameters include the vehicle's starting position, destination, and driving path to simulate the current traffic conditions. The flow chart of the steps of the discrete event simulation model of the traffic congestion detection method based on machine vision is as follows Figure 8 shown.
[0274] For example, there is a simple traffic network including 4 intersections (O, P, Q, R) and 6 road segments; the initial conditions of the simulation are set by real-time traffic data, and the initial conditions include the vehicle starting position o=O, the destination p=R and the driving path q0=O→P→Q→R; the simulation parameters are dynamically updated according to the real-time traffic data, and the simulation parameters include the vehicle starting position, the destination and the driving path to simulate the current traffic conditions; the current time t=10:00;
[0275] It can be understood that the expression for the vehicle position is as follows:
[0276] update_state(t)=(new_position,new_path);
[0277] Where update_state(t) represents the position at time t; t represents the current time; new_position represents the new position of the vehicle; new_path represents the new driving path of the vehicle;
[0278] It should be noted that the vehicle is currently at intersection P, and the new driving path is P→X→R.
[0279] Further, the simulation model is run to simulate traffic flow and congestion conditions, and the congestion conditions under the current traffic conditions are evaluated, and the evaluation parameters of the congestion conditions include average travel time and congestion duration;
[0280] It should be noted that the corresponding events are triggered according to the preset conditions, and the corresponding events are triggered according to the preset conditions, including diversion when congestion occurs;
[0281] Furthermore, when congestion is detected at intersection C, the optimal detour routes for affected vehicles are generated in the discrete event simulation model using an optimization algorithm based on traffic conditions and diversion strategies;
[0282] optimal_path=find_path(G,s,d,current_traffic);
[0283] Among them, optimal_path represents the optimal path; find_path represents the path to be found; G represents the traffic network diagram; s represents the current position of the vehicle; d represents the destination of the vehicle; current_traffic represents the current traffic conditions;
[0284] Further, a specific route planning suggestion is generated, which includes a recommended driving path and an estimated travel time;
[0285] Exemplarily, a specific route planning suggestion is generated as O→Y→Z→R, and the estimated travel time is calculated to be 20 minutes.
[0286] In this embodiment, the detour route is dynamically adjusted according to the real-time traffic conditions to ensure that vehicles can be cleared quickly.
[0287] In step S3, the navigation system integrates the received real-time traffic data and suggestions, sends a notification to the driver's navigation device, displays the congestion status of the route ahead and provides alternative routes, and guides the driver to avoid congested areas or divert traffic.
[0288] Specifically, key information includes current traffic conditions, congested areas, and suggestions for new route planning;
[0289] In some embodiments, a notification is sent to the driver's navigation device, wherein the notification includes the congestion status of the road ahead, the estimated delay time, the affected road sections, and detailed information of the new route planning, wherein the detailed information of the new route planning includes the estimated travel time of the route and the congestion status of the route.
[0290] For example, the notification information is that the road section C ahead is congested and the estimated delay is 15 minutes; the new route planning suggested is O→Y→Z→R, and the estimated travel time is 20 minutes;
[0291] In step S4, the YOLOv5 traffic congestion detection model monitors new traffic data and collects feedback information from navigation devices and feeds it back to the discrete event simulation model to further optimize route planning and suggestions to achieve real-time road unblocking effects.
[0292] In step S4 of some embodiments, when the driver selects a new route plan, the navigation device feeds back the driver's choice and whether to avoid congestion to the discrete event simulation model, and based on the feedback information, counts the driver's selection rate of the new route plan, continuously monitors the traffic conditions on the new route plan, evaluates the effectiveness of the new route plan, and further optimizes the route plan and suggestions until the congestion is completely alleviated.
[0293] Step S5: The discrete event simulation model dynamically updates the route to the navigation system, and the navigation system simultaneously pushes the latest route suggestion to the driver's device.
[0294] The embodiment of the present application combines YOLOv5 with a discrete event simulation model to accurately analyze congestion conditions, dynamically generate optimal detour routes, optimize vehicle driving paths, and improve traffic efficiency; provide accurate congestion information and new route planning suggestions through the navigation system to save travel time and improve travel experience; and reduce vehicle density on the road, alleviate traffic congestion, and improve traffic conditions through effective diversion and path planning.
[0295] See also Fig. 9 The embodiment of the present application also provides a traffic congestion detection device, which can implement the above-mentioned traffic congestion detection method, and the device includes:
[0296] The acquisition module 901 is used to acquire video streams and store them as image frames;
[0297] The congestion detection module 902 is used to input the image frame into the traffic congestion detection model to obtain the traffic congestion status and current traffic data;
[0298] A suggestion generation module 903 is used to input current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions;
[0299] The sending module 904 is used to send the diversion strategy, route planning suggestions and traffic congestion status to the navigation device.
[0300] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0301] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned traffic congestion detection method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0302] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0303] See also Fig.10 , Fig.10 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0304] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0305] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the traffic congestion detection method of the embodiment of this application;
[0306] Input / output interface 1003, used to implement information input and output;
[0307] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0308] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );
[0309] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .
[0310] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned traffic congestion detection method is implemented.
[0311] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0312] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0313] The traffic congestion detection method, traffic congestion detection device, electronic device and storage medium provided in the embodiments of the present application collect video streams and store them as image frames; input the image frames into a traffic congestion detection model to obtain traffic congestion status and current traffic data, thereby detecting traffic flow in real time and accurately analyzing congestion conditions; input the current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions, thereby reducing congestion and improving traffic efficiency; and send the diversion strategies, route planning suggestions and traffic congestion status to a navigation device to provide real-time, intelligent route planning, enhance user experience and improve traffic efficiency.
[0314] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0315] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0316] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0317] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0318] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0319] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0320] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0321] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0322] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0323] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0324] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A traffic congestion detection method, characterized in that: The method comprises the following steps: Capture video streams and store them as image frames; Inputting the image frame into a traffic congestion detection model to obtain a traffic congestion state and current traffic data; Inputting the current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions; The diversion strategy, the route planning suggestion and the traffic congestion status are sent to a navigation device.
2. The method according to claim 1, characterized in that The method further comprises: The stored image frames are preprocessed, wherein the preprocessing includes utilizing contrast-constrained adaptive histogram equalization to enhance the contrast of the image and suppress noise.
3. The method according to claim 1, characterized in that The step of inputting the image frame into a traffic congestion detection model to obtain a traffic congestion state and current traffic data includes: Inputting the image frame into a traffic congestion detection model; Extracting image features of the image frame by using the traffic congestion detection model; Determining the traffic congestion state according to the image features by using the traffic congestion detection model; The current traffic data is outputted through the traffic congestion detection model, and the current traffic data includes vehicle flow, vehicle speed, congestion status, specific congestion range and specific congested lane.
4. The method according to claim 3, characterized in that The image features include a detection box in each grid unit, and determining the traffic congestion state according to the image features by the traffic congestion detection model includes: Eliminate overlapping detection frames by using non-maximum suppression through the traffic congestion detection model and retain the detection frame with the highest confidence, wherein the information of the detection frame includes target category, bounding box and confidence; Obtaining target information of each detection frame through the traffic congestion detection model, wherein the target information includes vehicle position, category and confidence; Using the target tracking algorithm through the traffic congestion detection model to obtain the movement trajectory of the vehicle; Counting the number of vehicles in each detection frame by using the traffic congestion detection model; Acquire the corresponding road capacity according to the vehicle position; Calculating a congestion index according to the number of vehicles and the road capacity by using the traffic congestion detection model; The traffic congestion state is determined according to the congestion index by using the traffic congestion detection model.
5. The method according to claim 2, characterized in that: The preprocessing of the stored image frames comprises: Dividing the image frame into a plurality of small areas, wherein the small areas are square or rectangular; Calculate the grayscale histogram of each small area; Performing equalization processing on the grayscale histogram of each small area; Performing contrast limitation on the histogram of each small area; By using bilinear interpolation, the equalization results of each small area are combined to obtain the preprocessed image frame.
6. The method according to claim 1, characterized in that The traffic congestion detection model includes an input end, a backbone network part, a neck network part and a head network part. The method also includes a step of training the traffic congestion detection model. The training traffic congestion detection model includes: Acquire historical traffic images, and randomly divide the historical traffic images into a training set and a test set, wherein the historical traffic images include true frames; Inputting the training set to an input end for image processing, the input end performing a data enhancement algorithm, an adaptive anchor box calculation, and an adaptive image scaling operation; The training set images processed by the input end are transmitted to the backbone network part, the feature map is extracted and optimized by the backbone network part, and the feature map is input into the neck network part; The neck network part uses a feature pyramid network and a path aggregation network for instance segmentation to fuse the feature map, and inputs the fused features into the head network part; The head network part performs target detection based on the fused features, outputs a predicted box, and uses a loss function to evaluate the difference between the predicted box and the true box.
7. The method according to claim 1, characterized in that The step of inputting the current traffic data into a discrete event simulation model to generate a diversion strategy and a route planning suggestion includes: Establishing a simulation model of an urban traffic network, wherein the simulation model of the urban traffic network includes a road model, an intersection model and a signal light model; Setting simulation initial conditions based on the current traffic data, the initial conditions including the vehicle's starting position, destination, and travel path; updating simulation parameters according to the current traffic data, wherein the simulation parameters include a vehicle starting position, a destination, and a driving path, and the simulation parameters are used to simulate traffic conditions; Running the simulation model of the urban traffic network to evaluate the congestion situation under the current traffic state, wherein the evaluation parameters of the congestion situation include average travel time and congestion duration; If the congestion condition under the current traffic state is that there is a congestion event, a diversion strategy is generated according to preset conditions, and a route planning suggestion is generated in the discrete event simulation model according to the traffic condition and the diversion strategy using an optimization algorithm, and the route planning suggestion includes the best detour route for the affected vehicles.
8. A traffic congestion detection device, characterized in that: The device comprises: The acquisition module is used to acquire video streams and store them as image frames; A congestion detection module, used for inputting the image frame into a traffic congestion detection model to obtain a traffic congestion state and current traffic data; A suggestion generation module, used for inputting the current traffic data into a discrete event simulation model to generate diversion strategies and route planning suggestions; The sending module is used to send the diversion strategy, the route planning suggestion and the traffic congestion status to the navigation device.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Method, device and equipment for identifying road congestion state in real time and storage medium
CN121034073A