Traffic jam detection method and device, electronic equipment and storage medium
Through the method of identifying and reducing congestion areas in traffic images, fully automated traffic congestion detection is realized, solving the problems of low efficiency and safety hazards of existing traffic congestion management methods, and improving the accuracy and timeliness of traffic congestion areas. .
Patent Information
- Application Number
- CN202410808782.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-08
AI Technical Summary
Existing traffic congestion management methods rely on manual monitoring, which is inefficient and poses safety risks. Traffic congestion and accidents are likely to occur, especially during periods when there is no traffic police management or in areas where traffic lights are not installed.
By obtaining the target vehicle expansion frame in the traffic image, the congestion area is identified and reduced, and the congestion area is fully automated based on vehicle number and distance judgment. The expansion frame and filter module are used to accurately determine the congestion area in the traffic image.
It achieves fully automated and efficient traffic congestion detection, reduces the need for manual monitoring, improves the accuracy and timeliness of traffic congestion areas, and reduces the risk of traffic accidents.
Smart Images

Figure CN118747875A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of road traffic technology, specifically relating to a traffic congestion detection method, device, electronic equipment, and storage medium. Background Technology
[0002] With urbanization, urban traffic congestion is becoming increasingly severe. Current traffic congestion management methods involve assigning fixed police officers to specific intersections at fixed times to direct traffic and prevent congestion. This method is not only time-consuming and labor-intensive but also poses certain safety risks to traffic police. Furthermore, traffic congestion is highly likely to occur during periods without police intervention or in areas without traffic lights.
[0003] Even with surveillance cameras installed in various locations, real-time human monitoring is still necessary, which is inefficient. In the event of traffic congestion, if no one proactively identifies the problem, timely intervention and traffic control cannot be implemented, potentially leading to traffic accidents. Summary of the Invention
[0004] Therefore, the purpose of this application is to provide a traffic congestion detection method, device, electronic device and storage medium to accurately determine congested areas in traffic images.
[0005] In a first aspect, embodiments of this application provide a traffic congestion detection method, the method comprising: acquiring a target bounding box corresponding to each target vehicle in a traffic image, each target bounding box including a target vehicle region and a neighboring region, the target vehicle region being the image region where the target vehicle corresponding to the target bounding box is located, and the neighboring region being the adjacent image region of the target vehicle corresponding to the target bounding box; acquiring vehicles in a congested state within the target bounding box, obtaining congested vehicles within each target bounding box; reducing the target bounding box based on the coordinates of the congested vehicles within the target bounding box, generating candidate boxes corresponding to each target bounding box; and performing overlap filtering on all candidate boxes to obtain a congestion box, the congestion box including the congested area in the traffic image.
[0006] The traffic congestion detection method described above expands the vehicles in the traffic image to obtain an expanded bounding box that includes the traffic conditions around the vehicles. Then, it shrinks the expanded bounding box based on the congested vehicles to obtain the congested area. This method can accurately determine the congested area in the traffic image, and it is fully automated and highly efficient.
[0007] In one optional embodiment of this application, the step of obtaining all target vehicles in the traffic image and the target bounding box corresponding to each target vehicle includes: identifying all vehicles in the traffic image to obtain candidate vehicles; obtaining an area within a preset range centered on the candidate vehicles to generate a candidate bounding box for each candidate vehicle; obtaining candidate bounding boxes that meet preset congestion conditions from all candidate bounding boxes to obtain multiple target bounding boxes, wherein the candidate vehicle corresponding to the target bounding box is the target vehicle.
[0008] In the above embodiments, an expanded bounding box is generated with the vehicle as the center. The expanded bounding box includes the traffic conditions around the vehicle, thereby accurately identifying the areas involved in traffic in the traffic image. Furthermore, the expanded bounding boxes are filtered, and only those that meet the congestion conditions are used as target expanded bounding boxes, which can increase the accuracy of detecting congested areas from the expanded bounding boxes.
[0009] In one optional embodiment of this application, identifying all vehicles in the traffic image to obtain candidate vehicles includes: identifying all vehicles and all lanes in the traffic image; and determining vehicles located in lanes as candidate vehicles.
[0010] In the above embodiments, only vehicles located in the lanes are retained, while vehicles not participating in road traffic are excluded, which can increase the accuracy of judging road congestion.
[0011] In one optional embodiment of this application, the preset congestion condition is that the number of vehicles in the candidate expansion boxes is greater than a preset threshold. The step of obtaining candidate expansion boxes that meet the preset congestion condition from all candidate expansion boxes to obtain multiple target expansion boxes includes: obtaining the number of vehicles in the candidate expansion boxes to obtain the number of vehicles in each candidate expansion box; determining the relationship between the number of vehicles in each candidate expansion box and the preset threshold, and determining the candidate expansion boxes with a number of vehicles greater than the preset threshold as target expansion boxes.
[0012] The above embodiments provide a method for setting congestion conditions, which uses the number of vehicles within the expanded frame as the congestion condition, and can easily and quickly determine the expanded frames where congestion may occur.
[0013] In one optional embodiment of this application, obtaining the vehicles in a congested state within the target expansion frame, and obtaining the congested vehicles in each target expansion frame, includes: selecting vehicles within the target expansion frame one by one, obtaining the detection distance of the selected vehicle, wherein the detection distance is the minimum distance between the selected vehicle and other vehicles; determining the magnitude between the detection distance of each vehicle and a preset detection threshold, and identifying vehicles whose detection distance is less than the preset threshold as vehicles in a congested state.
[0014] The above embodiments provide a method for determining congestion status, which quickly filters out congested vehicles within the extended frame based on vehicle distance, thereby accelerating algorithm computation time and saving computing power.
[0015] In one optional embodiment of this application, the step of shrinking the target expansion box based on the coordinates of the congested vehicles within the target expansion box to generate multiple candidate boxes includes: determining the coordinates of the congested vehicles as the boundary coordinates of the target expansion box; moving the boundary of the target expansion box to the position of the boundary coordinates to generate the candidate boxes.
[0016] In the above embodiments, the coordinates of congested vehicles are used as the boundary points of the expanded box after shrinking, thereby quickly shrinking the expanded box. The traffic conditions displayed by the shrunken expanded box only include the vehicles and the surrounding congested vehicles, thus obtaining the congested area in the traffic image.
[0017] In one optional embodiment of this application, the step of performing overlap filtering on all candidate boxes to obtain congested boxes includes: selecting any one of the candidate boxes as the target box; calculating the overlap ratio between the target box and other candidate boxes one by one, and removing candidate boxes with an overlap ratio greater than a preset threshold.
[0018] The above embodiments provide a method for filtering candidate boxes, which can select independent candidate boxes from the candidate boxes to obtain independent congestion areas in the traffic image, facilitating the reporting and monitoring of congestion areas.
[0019] Secondly, embodiments of this application provide a traffic congestion detection device, the device comprising: an expanded box acquisition module, configured to acquire a target expanded box corresponding to each target vehicle in a traffic image, each target expanded box including a target vehicle region and a neighboring region, the target vehicle region being the image region where the target vehicle corresponding to the target expanded box is located, and the neighboring region being the adjacent image region of the target vehicle corresponding to the target expanded box; a congested vehicle acquisition module, configured to acquire vehicles in a congested state within the target expanded box, obtaining congested vehicles within each target expanded box; a reduction module, configured to reduce the target expanded box based on the coordinates of the congested vehicles within the target expanded box, generating candidate boxes corresponding to each target expanded box; and a filtering module, configured to perform overlap filtering on all candidate boxes to obtain a congestion box, the congestion box including the congested area in the traffic image.
[0020] Thirdly, embodiments of this application provide an electronic device that performs the method described in any one of the first aspects.
[0021] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, performs the method described in any one of the first aspects.
[0022] Other features and advantages of this application will be set forth in the following description. The objectives and other advantages of this application can be realized and obtained through the structures specifically pointed out in the written description and the accompanying drawings. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. The above and other objects, features, and advantages of this application will become clearer through the accompanying drawings.
[0024] Figure 1 A schematic diagram of a traffic congestion detection process provided in an embodiment of this application is shown;
[0025] Figure 2 This illustration shows a schematic diagram of the generation of a target expansion box according to an embodiment of this application;
[0026] Figure 3 This illustration shows a schematic diagram of a method for determining congested vehicles according to an embodiment of this application;
[0027] Figure 4 This illustration shows a schematic diagram of the generation of an alternative selection box according to an embodiment of this application;
[0028] Figure 5 A schematic block diagram of a traffic congestion detection device also provided in an embodiment of this application is shown;
[0029] Figure 6 A schematic block diagram of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0030] In the following description, embodiments of the present application are described in detail with reference to the accompanying drawings. It should be noted that although the same elements are shown in different drawings, they will be designated by the same reference numerals. In the following description, specific details such as detailed configurations and components are provided only to aid in a comprehensive understanding of the embodiments of the present application. Therefore, those skilled in the art will understand that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Furthermore, for clarity and brevity, descriptions of well-known functions and constructions have been omitted. The terminology described below is defined in consideration of the functions in this application and may vary depending on the user, the user's intent, or habits. Therefore, the definitions of the terms should be determined based on the content throughout this specification.
[0031] This application may have various modifications and embodiments, and the embodiments are described in detail below with reference to the accompanying drawings. However, it should be understood that this application is not limited to the embodiments, but includes all modifications, equivalents, and substitutions within the scope of this application.
[0032] The terminology used herein is for describing various embodiments of this application only and is not intended to limit the application. Unless the context clearly indicates otherwise, the singular form is intended to include the plural form. In this application, it should be understood that the terms "comprising" or "having" indicate the presence of features, quantities, steps, operations, structural elements, components, or combinations thereof, and do not preclude the possibility of the presence of one or more other features, quantities, steps, operations, structural elements, components, or combinations thereof, or the addition of one or more other features, quantities, steps, operations, structural elements, components, or combinations thereof.
[0033] Unless otherwise defined, all terms used herein shall have the same meaning as understood by one of ordinary skill in the art to which this application pertains. Unless expressly defined in this application, terms (such as those defined in a general dictionary) shall be interpreted as having the same meaning as in the context of the relevant field, and shall not be interpreted as having an idealized or overly formal meaning.
[0034] An electronic device according to one embodiment can be one of various types of electronic devices. The electronic device may include, for example, a portable communication device (e.g., a smartphone), a computer, a portable multimedia device, a portable medical device, a camera, a wearable device, or a home appliance. According to one disclosed embodiment, the electronic device is not limited to those described above.
[0035] The terminology used herein is not intended to limit the application, but rather to include various modifications, equivalents, or substitutions of the corresponding embodiments. Similar reference numerals may be used to denote similar or related elements in relation to the description of the drawings. Unless the relevant context clearly indicates otherwise, the singular form of the noun corresponding to an item may include one or more things. As used herein, each of the phrases such as “A or B,” “at least one of A and B,” “at least one of A or B,” “A, B, or C,” “at least one of A, B, and C,” and “at least one of A, B, or C” may include all possible combinations of the items listed together in the corresponding one of the phrases. As used herein, terms such as “first,” “second,” “first,” and “second” may be used to distinguish a corresponding component from another component, and are not intended to limit the component in other respects (e.g., importance or order). The intention is that if an element (e.g., a first element) is referred to as being "combined," "connected to," "attached," or "linked" to another element (e.g., a second element) with or without the terms "operably" or "communically," it indicates that the element can be combined with the other element directly (e.g., wired), wirelessly, or via a third element.
[0036] As used herein, the term "module" may include a unit implemented in hardware, software, or firmware, and may be used interchangeably with other terms (e.g., "logic," "logic block," "component," and "circuit"). A module may be a single integrated component or its smallest unit or component suitable for performing one or more functions. For example, according to one embodiment, a module may be implemented as an application-specific integrated circuit (ASIC).
[0037] like Figure 1 As shown, Figure 1 A flowchart illustrating a traffic congestion detection method provided in an embodiment of this application is shown. Figure 1 As shown, the method includes steps 110 to 140:
[0038] Step 110: Obtain the target bounding box corresponding to each target vehicle in the traffic image. Each target bounding box includes a target vehicle region and a neighboring region. The target vehicle region is the image region where the target vehicle corresponding to the target bounding box is located, and the neighboring region is the adjacent image region of the target vehicle corresponding to the target bounding box.
[0039] Traffic images are acquired through information collection devices, such as surveillance cameras, drones, etc. The traffic images include images of vehicles, such as images of cars driving on highways or at entrances and exits.
[0040] Then, target vehicles are obtained from the traffic image. Target vehicles can be all vehicles in the traffic image or some vehicles in the traffic image that meet the conditions. For example, a target recognition algorithm can be used to identify all vehicles in the traffic image, and some of the identified vehicles can be selected as target vehicles.
[0041] In this application, a vehicle can be an image region that includes only vehicle pixels. For example, when using a segmentation algorithm, a traffic image containing vehicle pixels will be obtained. A vehicle can also be a detection box that includes vehicle pixels. For example, when using an object recognition algorithm, a detection box of vehicles in a traffic image will be obtained. This detection box includes all the smallest rectangles that the algorithm can determine to include vehicles.
[0042] For each target vehicle, a target bounding box is obtained. The target bounding box includes the target vehicle region and the adjacent region. The target vehicle region is the image region of the target vehicle, and the adjacent region is the other image regions around the target vehicle.
[0043] In this application, the target bounding box is generated to obtain the traffic situation around the vehicle. Therefore, the included area is a large area, and the adjacent area it includes can at least accommodate one vehicle. For example, when using target recognition algorithms, although the vehicle is the detection box, the area outside the vehicle that the detection box usually includes is usually too small to be used as an bounding box.
[0044] In one embodiment of this application, the step of obtaining all target vehicles in a traffic image and the target bounding box corresponding to each target vehicle includes: identifying all vehicles in the traffic image to obtain candidate vehicles; obtaining a region within a preset range centered on the candidate vehicles to generate a candidate bounding box for each candidate vehicle; obtaining candidate bounding boxes that meet preset congestion conditions from all candidate bounding boxes to obtain multiple target bounding boxes, wherein the candidate vehicle corresponding to the target bounding box is the target vehicle.
[0045] For example, a drone carrying a camera flies along a road and transmits images to a ground-based algorithm analysis center. The algorithm center uses a trained algorithm to detect vehicles in the images. For instance, the YOLOv8-CAR algorithm is used for vehicle detection, and vehicles are detected.
[0046] Furthermore, the step of identifying all vehicles in the traffic image to obtain candidate vehicles includes: identifying all vehicles and all lanes in the traffic image; and determining vehicles located in lanes as candidate vehicles.
[0047] The YOLOv8-car model can be used for vehicle detection, and the YOLOv8-seg-street model for lane segmentation. For a vehicle detected by YOLOv8-car, it is determined whether the vehicle's bounding box is within the lane segmented by YOLOv8-seg-street. Specifically, the center coordinates of the vehicle's bounding box are taken and checked against the lane contour point dataset. If not, the vehicle is not in the lane and is discarded. The remaining vehicles are then considered as candidate vehicles.
[0048] In the above embodiments, only vehicles located in the lanes are retained, while vehicles not participating in road traffic are excluded, which can increase the accuracy of judging road congestion.
[0049] For the detected candidate vehicles, an expanded candidate list is generated. Specifically, such as... Figure 2 As shown, the detection box of the car can be expanded by six times its width to the left and right, and by six times its length to the front and rear, all centered on the car's detection box. If the detection box exceeds the image range, the image's edge is used. This results in an expanded box, which remains upright regardless of whether the car is upright or angled. The expanded box encompasses all lanes.
[0050] For each candidate expansion box, identify the candidate expansion box that meets the preset congestion conditions, and take the candidate expansion box that meets the preset congestion conditions as the target expansion box. In this way, the target candidate expansion box can be obtained from all candidate expansion boxes, and multiple target expansion boxes can be obtained. At this time, the candidate vehicle corresponding to the target expansion box is the target vehicle.
[0051] In the above embodiments, an expanded bounding box is generated with the vehicle as the center. The expanded bounding box includes the traffic conditions around the vehicle, thereby accurately identifying the areas involved in traffic in the traffic image. Furthermore, the expanded bounding boxes are filtered, and only those that meet the congestion conditions are used as target expanded bounding boxes, which can increase the accuracy of detecting congested areas from the expanded bounding boxes.
[0052] In one embodiment of this application, the preset congestion condition is that the number of vehicles in the candidate expansion boxes is greater than a preset threshold. The step of obtaining candidate expansion boxes that meet the preset congestion condition from all candidate expansion boxes to obtain multiple target expansion boxes includes: obtaining the number of vehicles in the candidate expansion boxes to obtain the number of vehicles in each candidate expansion box; determining the relationship between the number of vehicles in each candidate expansion box and the preset threshold, and determining the candidate expansion boxes with a number of vehicles greater than the preset threshold as target expansion boxes.
[0053] For each candidate vehicle's bounding box, determine if the number of all vehicles within that vehicle's bounding box exceeds a threshold. If not, the lanes within the bounding box centered on that vehicle are not considered congested. For example, this can be determined using IOU (Intersection Over Union). IOU is calculated by comparing the vehicle's detection box with a preset bounding box. The IOU calculation is the intersection of bounding boxes A and B divided by their union, using the following formula:
[0054]
[0055] By calculating the Interchange of Union (IOU) between the expanded bounding box of this vehicle and the bounding boxes of other vehicles within the expanded bounding box, the number of all vehicles within the candidate expanded bounding box range of this vehicle is obtained based on the IOU. If the IOU exceeds a threshold, the number of vehicles in a congested state within the expanded bounding box range of this vehicle is then obtained.
[0056] The above embodiments provide a method for setting congestion conditions, which uses the number of vehicles within the expanded frame as the congestion condition, and can easily and quickly determine the expanded frames where congestion may occur.
[0057] Step 120: Obtain the vehicles in a congested state within the target expansion frame, thus obtaining the congested vehicles within each target expansion frame.
[0058] For each target bounding box, identify the congested vehicles within it. Congested vehicles are those that are currently in a congested state. The congestion status can be set based on conditions, such as defining vehicles with a movement speed less than a preset speed threshold as congested vehicles, or defining vehicles with a movement time greater than a time threshold as congested vehicles.
[0059] In one embodiment of this application, obtaining the vehicles in a congested state within the target expansion frame, and obtaining the congested vehicles in each target expansion frame, includes: selecting vehicles within the target expansion frame one by one, obtaining the detection distance of the selected vehicle, wherein the detection distance is the minimum distance between the selected vehicle and other vehicles; determining the magnitude between the detection distance of each vehicle and a preset detection threshold, and identifying vehicles whose detection distance is less than the preset threshold as vehicles in a congested state.
[0060] To determine if a vehicle is in a congested state, you can check if the nearest distance between the vehicle and the four corners of the detection box of all vehicles within the expanded bounding box is less than the vehicle's length. If any of these distances is less than the vehicle's length, then the vehicle is considered to be in a congested state. For example,... Figure 3As shown, in the embodiment where the vehicle is the detection frame, the vehicle length is replaced by the longer side of the vehicle's detection frame. For an expanded frame, the distance between each vehicle and other vehicles is detected. If the distance between any other vehicle and the detected vehicle is less than the vehicle length, then that vehicle is in a congested state.
[0061] The above embodiments provide a method for determining congestion status, which quickly filters out congested vehicles within the extended frame based on vehicle distance, thereby accelerating algorithm computation time and saving computing power.
[0062] Furthermore, it can be determined whether the number of vehicles in a congested state within the expanded bounding box of this vehicle exceeds a threshold. If it exceeds the threshold, it indicates that the expanded bounding box is a congested bounding box. Then, based on the coordinates of the congested vehicles within the congested bounding box, the congested bounding box is reduced to generate a candidate box corresponding to each congested bounding box.
[0063] Step 130: Based on the coordinates of the congested vehicles within the target expansion box, the target expansion box is reduced in size to generate a candidate box corresponding to each target expansion box.
[0064] Extract the coordinates of the congested vehicles within the expanded bounding box to narrow down the bounding box. The narrowed bounding box is then used as a candidate bounding box for traffic congestion on the road segment where the vehicle is located.
[0065] In one embodiment of this application, the step of shrinking the target expansion box based on the coordinates of congested vehicles within the target expansion box to generate multiple candidate boxes includes: determining the coordinates of the congested vehicles as the boundary coordinates of the target expansion box; moving the boundary of the target expansion box to the position of the boundary coordinates to generate the candidate boxes.
[0066] For example, such as Figure 4 As shown, the coordinates of the left, right, bottom, and top endpoints of the detection frame for congested vehicles are used to form a new frame, i.e., the candidate frame. The coordinates of the top-left corner of the candidate frame are set to... The coordinates of the bottom right corner are Then it will look like this:
[0067]
[0068] Wherein: the alternative selection box is represented as newBox.
[0069]
[0070] In the above embodiments, the coordinates of congested vehicles are used as the boundary points of the expanded box after shrinking, thereby quickly shrinking the expanded box. The traffic conditions displayed by the shrunken expanded box only include the vehicles and the surrounding congested vehicles, thus obtaining the congested area in the traffic image.
[0071] Step 140: Overlap filtering is performed on all candidate boxes to obtain congestion boxes, which include the areas in the traffic image where there is congestion.
[0072] The system detects the degree of overlap between candidate boxes and removes candidate boxes with an overlap greater than a threshold, thereby performing overlap filtering on all candidate boxes. The remaining candidate boxes are the final traffic congestion detection boxes.
[0073] The traffic congestion detection method described above expands the vehicles in the traffic image to obtain an expanded bounding box that includes the traffic conditions around the vehicles. Then, it shrinks the expanded bounding box based on the congested vehicles to obtain the congested area. This method can accurately determine the congested area in the traffic image, and it is fully automated and highly efficient.
[0074] In one embodiment of this application, the step of performing overlap filtering on all candidate boxes to obtain congested boxes includes: selecting any one of the candidate boxes as the target box; calculating the overlap ratio between the target box and other candidate boxes one by one, and removing candidate boxes with an overlap ratio greater than a preset threshold.
[0075] For all candidate boxes, select any candidate box and use it as the target box. Calculate the IOU between the target box and each other candidate box. Remove other candidate boxes with an IOU greater than the threshold, thereby eliminating candidate boxes with an overlap greater than the threshold. Finally, the candidate boxes that are separated from each other are left. The remaining candidate boxes are the congested boxes.
[0076] The above embodiments provide a method for filtering candidate boxes, which can select independent candidate boxes from the candidate boxes to obtain independent congestion areas in the traffic image, facilitating the reporting and monitoring of congestion areas.
[0077] The yolov8-car and yolov8-seg-street models used in the above embodiments are based on yolov8 and optimized. yolov8 includes three parts: Backbone, Neck, and Head. The Backbone consists of 5 convolutional modules, 4 C2F modules, and 1 SPPF module. Each convolutional module consists of a 2D convolution, a BatchNorm2D activation function, and a SiLU activation function. The C2F module first passes through a convolutional module with k=1, s=1, p=0, and c=c_out, then undergoes a split process, and is processed by n Darknet Bottleneck modules. The results from the residual module and the backbone module are then concatenated, and finally processed by a convolutional module for output. The Neck module uses a PAN-FPN network. PAN-FPN inputs the Backbone outputs p3, p4, and p5 into the network, enabling the fusion of feature maps at multiple scales. Specifically, p5 is upsampled and fused with p4 to obtain F1. f1 is passed through a C2f layer and upsampled once, then fused with p3 to obtain T1. T1 is passed through a convolutional layer and fused with F1 to obtain F2. F2 is passed through a C2f layer to obtain T2. T2 is passed through a convolutional layer and fused with P5 to obtain F3. F3 is passed through a C2f layer to obtain T3. Finally, T1, T2, and T3 are the outputs of the entire Neck network. The Head part processes T1, T2, and T3 to generate the model's output.
[0078] The fine-tuning process can be as follows: Collect and label a traffic vehicle dataset, with the labeled object and label being "car". Perform data augmentation on the labeled data, including mosaic data augmentation, brightness change data augmentation, and scaling data augmentation. Divide the labeled data into training, validation, and test sets in an 8:1:1 ratio. Train the training set using YOLOv8 to obtain a YOLOv8-car detection model. Use this model to perform object detection on the input image or video to obtain the car detection bounding box.
[0079] A traffic road dataset was collected and labeled, with the labeled object and label being "road". The labeled data was divided into training, validation, and test sets in an 8:1:1 ratio. The training set was then trained using YOLOv8-SEG to obtain the YOLOv8-SEG-Street segmentation model. YOLOv8-SEG is a segmentation model improved from YOLOv8. The backbone and neck network of this model remain consistent with YOLOv8, but the detection head is replaced with a segmentation head, which uses the YOLACT segmentation network. This model is then used to segment input images or videos, obtaining the segmented road regions.
[0080] The specific formula for the SiLU activation function is as follows:
[0081] fx = x * sigmoid x
[0082] Where x is the data obtained from the input feature map.
[0083] The sigmoid function is used to solve binary classification problems. Its formula is as follows:
[0084]
[0085] like Figure 5 As shown, Figure 5 An embodiment of this application also illustrates a traffic congestion detection device, which includes: an expanded frame acquisition module 510, a congested vehicle acquisition module 520, a narrowed frame module 530, and a filtering module 540;
[0086] The expanded box acquisition module 510 is used to acquire the target expanded box corresponding to each target vehicle in the traffic image. Each target expanded box includes a target vehicle region and a neighboring region. The target vehicle region is the image region where the target vehicle corresponding to the target expanded box is located, and the neighboring region is the adjacent image region of the target vehicle corresponding to the target expanded box.
[0087] The congested vehicle acquisition module 520 is used to acquire vehicles in a congested state within the target expansion frame, thereby obtaining the congested vehicles within each target expansion frame.
[0088] The shrinking module 530 is used to shrink the target expansion box according to the coordinates of the congested vehicles within the target expansion box, and generate a candidate box corresponding to each target expansion box;
[0089] The filtering module 540 is used to perform overlapping filtering on all candidate boxes to obtain congestion boxes, wherein the congestion boxes include the areas in the traffic image where there is congestion.
[0090] In an optional embodiment of this application, the expanded frame acquisition module 510 includes:
[0091] The identification submodule is used to identify all vehicles in the traffic image and obtain candidate vehicles; to obtain a region within a preset range centered on the candidate vehicles and generate a candidate expansion box for each candidate vehicle;
[0092] The acquisition submodule is used to acquire candidate expansion boxes that meet the preset congestion conditions from all candidate expansion boxes, and obtain multiple target expansion boxes. The vehicle corresponding to the target expansion box is the target vehicle.
[0093] In one optional embodiment of this application, the identification submodule is specifically used to identify all vehicles and all lanes in the traffic image; and to identify vehicles located in the lanes as candidate vehicles.
[0094] In one optional embodiment of this application, the acquisition submodule is specifically used to acquire the number of vehicles in the candidate expansion boxes, obtain the number of vehicles in each candidate expansion box; determine the relationship between the number of vehicles in each candidate expansion box and a preset threshold, and determine the candidate expansion boxes with a number of vehicles greater than the preset threshold as target expansion boxes.
[0095] In one optional embodiment of this application, the congested vehicle acquisition module 520 is specifically used to select vehicles within the target expansion box one by one, acquire the detection distance of the selected vehicles, wherein the detection distance is the minimum distance between the selected vehicles and other vehicles; determine the magnitude between the detection distance of each vehicle and a preset detection threshold, and identify candidate vehicles whose detection distance is less than the preset threshold as vehicles in a congested state.
[0096] In one optional embodiment of this application, the shrinking module 530 is specifically used to determine the coordinates of the congested vehicle as the boundary coordinates of the target expanded box; move the boundary of the target expanded box to the position of the boundary coordinates, and generate the candidate box.
[0097] In one optional embodiment of this application, the filtering module 540 is specifically used to select any one of the candidate boxes as the target box from the candidate boxes; calculate the overlap ratio between the target box and other candidate boxes one by one, and remove candidate boxes with an overlap ratio greater than a preset threshold.
[0098] The traffic congestion detection device provided in this application embodiment has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.
[0099] like Figure 6 As shown, Figure 6 A schematic block diagram of an electronic device 600 according to an embodiment of this application is shown. The electronic device 600 includes: a processor 610 and a memory 620;
[0100] The processor 610, the memory 620, and other components are electrically connected directly or indirectly to enable data transmission or interaction. For example, these components can be electrically connected via one or more communication buses or signal lines. The memory 620 is used to store computer programs, such as those containing... Figure 5The software functional module shown is the traffic congestion detection device 500. The traffic congestion detection device 500 includes at least one software functional module that can be stored in the memory 620 in the form of software or firmware, or embedded in the operating system (OS) of the electronic device 600. The processor 610 is used to execute the executable module stored in the memory 620, such as the software functional module or computer program included in the traffic congestion detection device 500.
[0101] The memory 620 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0102] Processor 610 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), a microprocessor, etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. Alternatively, processor 610 can also be any conventional processor.
[0103] This application embodiment also provides a non-volatile computer-readable storage medium (hereinafter referred to as the storage medium) storing a computer program, which is executed by a computer such as the electronic device 600 described above to perform the traffic congestion detection method described above.
[0104] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0105] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0106] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0107] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions to cause a computer device (which may be a personal computer, laptop, server, or electronic device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned computer-readable storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0108] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A traffic congestion detection method, characterized in that: The method comprises: Acquire a target expansion frame corresponding to each target vehicle in the traffic image, each of the target expansion frames includes a target vehicle area and an adjacent area, the target vehicle area is an image area where the target vehicle corresponding to the target expansion frame is located, and the adjacent area is an adjacent image area of the target vehicle corresponding to the target expansion frame; Acquire vehicles in a congested state in the target expansion frame, and obtain congested vehicles in each of the target expansion frames; The target expansion box is reduced according to the coordinates of the congested vehicles in the target expansion box, and an alternative box corresponding to each target expansion box is generated; Overlap filtering is performed on all candidate frames to obtain a congestion frame, where the congestion frame includes a congested area in the traffic image.
2. The method according to claim 1, characterized in that The step of obtaining all target vehicles in the traffic image and a target expansion frame corresponding to each target vehicle includes: Identify all vehicles in the traffic image and obtain candidate vehicles; Acquire an area within a preset range centered on the candidate vehicle, and generate a candidate expansion box for each candidate vehicle; A candidate expansion box that meets a preset congestion condition is obtained from all candidate expansion boxes to obtain a plurality of target expansion boxes, and the candidate vehicles corresponding to the target expansion boxes are the target vehicles.
3. The method according to claim 2, characterized in that The step of identifying all vehicles in the traffic image and obtaining candidate vehicles includes: Identifying all vehicles and all lanes in the traffic image; The vehicle in the lane is determined as a candidate vehicle.
4. The method according to claim 2, characterized in that: The preset congestion condition is that the number of vehicles in the candidate expansion box is greater than a preset threshold, and the candidate expansion box that meets the preset congestion condition is obtained from all the candidate expansion boxes to obtain multiple target expansion boxes, including: Obtain the number of vehicles in the candidate expansion box, and obtain the number of vehicles in each candidate expansion box; The relationship between the number of vehicles in each candidate expansion box and a preset threshold is determined, and a candidate expansion box with a number of vehicles greater than the preset threshold is determined as a target expansion box.
5. The method according to claim 1, characterized in that: The acquiring of the vehicles in the target expansion frame that are in a congested state, and obtaining the congested vehicles in each target expansion frame, includes: Select the vehicles in the target expansion box one by one, and obtain the detection distance of the selected vehicle, where the detection distance is the minimum distance between the selected vehicle and other vehicles; The difference between the detection distance of each vehicle and a preset detection threshold is determined, and vehicles whose detection distance is less than the preset threshold are determined as vehicles in a congested state.
6. The method according to claim 1, characterized in that The step of reducing the target expansion box according to the coordinates of the congested vehicle in the target expansion box to generate multiple candidate boxes includes: Determine the coordinates of the congested vehicle as the boundary coordinates of the target expansion box; The boundary of the target extension box is moved to the position of the boundary coordinates to generate the candidate box.
7. The method according to claim 1, characterized in that The overlapping filtering of all candidate boxes to obtain the congestion box includes: Select any one of the candidate boxes as the target box; The overlapping ratios between the target frame and the other candidate frames are calculated one by one, and the candidate frames with overlapping ratios greater than a preset threshold are removed.
8. A traffic congestion detection device, characterized in that: The device comprises: An expansion frame acquisition module is used to acquire a target expansion frame corresponding to each target vehicle in the traffic image, each of the target expansion frames includes a target vehicle area and an adjacent area, the target vehicle area is an image area where the target vehicle corresponding to the target expansion frame is located, and the adjacent area is an adjacent image area of the target vehicle corresponding to the target expansion frame; A congested vehicle acquisition module, used to acquire vehicles in a congested state in the target expansion frame, and obtain congested vehicles in each of the target expansion frames; A reduction module, used to reduce the target expansion box according to the coordinates of the congested vehicles in the target expansion box, and generate an alternative box corresponding to each target expansion box; The filtering module is used to perform overlapping filtering on all candidate frames to obtain a congestion frame, wherein the congestion frame includes a congested area in the traffic image.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.
Citation Information
Patent Citations
Complex scene dense target detection method based on local context awareness
CN111368775A
Vehicle gathering monitoring method and computer readable storage medium
CN111540209A
Crowded scene pedestrian detection method combined with density estimation
CN112115862A
Target aggregation detection method and computer readable storage medium
CN113887372A
Expressway congestion judgment method, device, equipment and medium
CN113936458A
Cited By
Data resource collecting and labeling method based on big data mining
CN119479280A
A data resource collection and annotation method based on big data mining
CN119479280B
Method, device and equipment for identifying road congestion state in real time and storage medium
CN121034073A
