A method, system, device and storage medium for counting vehicle flow at a crossroad
Patent Information
- Application Number
- CN202310931880.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-27
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-07-27
AI Technical Summary
[0004]1)现有的十字路口车流计数方法大多需要在每个路口都安装摄像装置,至少需要四个摄像头,成本较高
[0035]1) Existing technologies directly calculate traffic flow from traffic flow videos, which is easily affected by lateral traffic flow, leading to inaccurate traffic counts. This invention adds three parallel auxiliary lines to the traffic flow video, and then counts traffic flow by direction based on traffic light status and the encoding settings based on vehicle key points crossing the auxiliary lines. This greatly improves the accuracy of traffic flow counting and recognition.
Smart Images

Figure CN116959272B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of traffic information processing, and in particular to a method, system, device, and storage medium for counting traffic flows in different directions at an intersection. Background Technology
[0002] With the continuous development of the economy and information processing technology, the demand for vehicle data collection and processing during driving is constantly increasing. Addressing the data processing challenges in complex road sections, how to accurately and in real-time collect and process vehicle data using traffic light signals, especially at intersections with highly complex traffic conditions, has become a key research focus in real-time information processing.
[0003] Currently, existing technologies have the following drawbacks:
[0004] 1) Most existing methods for counting traffic flow at intersections require the installation of cameras at each intersection, with at least four cameras required, which is costly.
[0005] 2) Existing methods for counting traffic flow at intersections are easily affected by traffic flow in the lateral direction, leading to inaccurate counts of traffic flow. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method, system, device and storage medium for counting traffic flows in different directions at intersections with high accuracy and low cost.
[0007] The objective of this invention can be achieved through the following technical solutions:
[0008] According to a first aspect of the present invention, a method for counting traffic flows in different directions at an intersection is provided, the method comprising:
[0009] Cameras are installed at any two intersections to continuously capture real-time traffic flow video from all directions, viewed from the current lane.
[0010] Three parallel auxiliary lines are added to the traffic flow video captured by each camera device. The YOLO algorithm is used to identify vehicles in the traffic video stream, and the traffic flow is counted in different directions based on the traffic light status and the encoding settings based on the key points of vehicles crossing the auxiliary lines.
[0011] Preferably, the three parallel auxiliary lines include:
[0012] The first auxiliary line is set in the lane where the camera is located;
[0013] The second auxiliary line is set in the middle of the intersection;
[0014] The third auxiliary line is set in the lane opposite the camera.
[0015] Preferably, the first auxiliary line and the third auxiliary line are respectively set in front of the lane in the direction of the camera and in the middle of the zebra crossing, and in front of the lane in the opposite direction and in the middle of the zebra crossing; the second auxiliary line is set at the center line of the transverse lane.
[0016] Preferably, the encoding setting based on the vehicle's key points crossing the auxiliary line specifically includes:
[0017] If a vehicle's key point crosses an auxiliary line, the corresponding code position of the current auxiliary line is set to 1; otherwise, it is set to 0.
[0018] The traffic flow at the intersection is counted based on the traffic light status and the order in which vehicles cross the auxiliary lines at key points, using a coding query method. Specifically:
[0019] The first auxiliary line coding position is 1, the second auxiliary line coding position is 1, and the third auxiliary line coding position is 1, with the first auxiliary line coding position being set to 1 first, corresponding to vehicles going straight into the lane opposite the camera device;
[0020] The first auxiliary line coding position is 1, the second auxiliary line coding position is 1, and the third auxiliary line coding position is 1, with the third auxiliary line coding position being set to 1 first. The corresponding vehicle will proceed straight from the lane opposite the camera device into the lane where the camera device is located.
[0021] The first auxiliary line coding position 1, the second auxiliary line coding position 1, and the third auxiliary line coding position 0 correspond to vehicles turning left from the lane where the camera is located into its left-turn lane, that is, the left lane direction from the perspective of the camera.
[0022] The first auxiliary line coding position 0, the second auxiliary line coding position 1, and the third auxiliary line coding position 1 correspond to vehicles entering their left-turn lane from the lane opposite the camera device, that is, the right lane direction from the camera device's perspective.
[0023] The first auxiliary line coding position 1, the second auxiliary line coding position 0, and the third auxiliary line coding position 0 correspond to vehicles entering their right turn lane from the lane where the camera is located, i.e., the right lane direction from the camera's field of view.
[0024] The first auxiliary line coding position 0, the second auxiliary line coding position 0, and the third auxiliary line coding position 1 correspond to vehicles entering their right-turn lane from the lane opposite the camera device, i.e., the left lane direction from the camera device's perspective.
[0025] Preferably, camera devices are installed at any two intersections of the crossroads to continuously acquire real-time traffic flow video of the current lane. Specifically, when the traffic light in the direction of the current lane is green, the first camera device in the current lane starts working, while the second camera device in the other lane goes into sleep mode; when the traffic light in the direction of the current lane changes from green to red, the first camera device continues to collect data for k seconds and then goes into sleep mode, at which point the second camera device starts working, and this cycle repeats.
[0026] Preferably, the YOLO algorithm is used to identify vehicles in the traffic video stream, specifically as follows:
[0027] The input traffic video stream images undergo format adjustment and normalization preprocessing.
[0028] The preprocessed traffic video stream images are input into the YOLO v5 model to obtain prediction results, including bounding box coordinates, object category probabilities, and confidence scores.
[0029] Post-processing was performed using nonmaximum suppression.
[0030] Select the object category label as "vehicle" for the output, and draw anchor boxes for it and number them.
[0031] According to a second aspect of the present invention, a crossroads directional traffic flow counting system is provided. The system includes a camera device installed at the crossroads, a wireless communication module for system data transmission, a road condition information detection module for acquiring traffic light status information, a traffic flow counting module, and a result output module. The traffic flow counting module adopts the crossroads directional traffic flow counting method based on the YOLO algorithm, counts the crossroads directional traffic flows based on the traffic flow video collected by the camera device and the traffic light status information acquired by the road condition information detection module, and outputs the final directional traffic flow counting result by the result output module.
[0032] According to a third aspect of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the program to implement any of the methods described above.
[0033] According to a fourth aspect of the invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements any of the methods described herein.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] 1) Existing technologies directly calculate traffic flow from traffic flow videos, which is easily affected by lateral traffic flow, leading to inaccurate traffic counts. This invention adds three parallel auxiliary lines to the traffic flow video, and then counts traffic flow by direction based on traffic light status and the encoding settings based on vehicle key points crossing the auxiliary lines. This greatly improves the accuracy of traffic flow counting and recognition.
[0036] 2) The YOLO traffic counting algorithm used in this invention has a fast calculation speed, low complexity, and high recognition accuracy. It can dynamically identify traffic based on different road sections and the traffic light signal status at the intersection ahead, minimizing errors in the recognition process; and ensuring that traffic flow from other directions does not affect the accuracy of the detection technology. It has very promising application prospects for environments with extremely high requirements for recognition and counting accuracy.
[0037] 3) Compared with the existing technical solution that requires the installation of camera devices at every intersection, the present invention only requires two camera devices to conveniently obtain real-time traffic flow video information of the intersection within the maximum range, realize accurate counting of traffic flow in different directions at the intersection, and has low hardware cost.
[0038] 4) The system of the present invention relies on its own equipment transmission module to transmit data at the intersection, without relying on roadside node facilities in the public transportation network, without needing to lay pressure-sensitive coils in advance, without occupying public resources, and without incurring access fees to roadside node facilities. Attached Figure Description
[0039] Figure 1 This is a flowchart of the method of the present invention;
[0040] Figure 2 This is a system structure diagram of the present invention;
[0041] Figure 3 This is a schematic diagram of the intersection when the north-south direction of the intersection is green in the embodiment.
[0042] Figure 4 This is a schematic diagram of the intersection in the embodiment where the east-west direction of the intersection has a green light;
[0043] Figure 5 This is a schematic diagram of the trajectory corresponding to the coding settings of the vehicle's key points crossing the auxiliary lines in the embodiment; wherein, Figure 5 (a) to 5(f) correspond to the traffic flow trajectories under the six coding conditions, respectively;
[0044] Figure 6 This is a diagram showing the recognition effect in the embodiment. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0046] Example
[0047] This embodiment provides a method for counting traffic flows in different directions at an intersection, the method including:
[0048] Cameras are installed at any two intersections of the crossroads to continuously acquire real-time traffic flow video of the current lane: when the traffic light in the direction of the current lane is green, the first camera in the current lane starts working, while the second camera in the other lane goes into sleep mode; when the traffic light in the direction of the current lane changes from green to red, the first camera continues to collect data for k seconds and then goes into sleep mode, at which point the second camera starts working, and this cycle repeats.
[0049] Three parallel auxiliary lines are added to the traffic flow video captured by each camera device, corresponding to the direction of the lane where the current camera device is located.
[0050] The YOLO algorithm is used to identify vehicles in traffic video streams, and traffic flow counting is performed based on traffic light status and encoding settings for vehicle key points crossing auxiliary lines.
[0051] The YOLO algorithm is used to identify vehicles in traffic video streams, including:
[0052] The input traffic video stream images undergo format adjustment and normalization preprocessing.
[0053] The preprocessed traffic video stream images are input into the YOLO v5 model to obtain prediction results, including bounding box coordinates, object category probabilities, and confidence scores.
[0054] Post-processing was performed using nonmaximum suppression.
[0055] Select the object category label as "vehicle" for the output, and draw anchor boxes for it and number them.
[0056] The method of the present invention will now be described in detail.
[0057] The coding settings based on the vehicle's key points crossing the auxiliary lines are as follows:
[0058] If a vehicle's key point crosses an auxiliary line, the corresponding code position of the current auxiliary line is set to 1; otherwise, it is set to 0.
[0059] The traffic flow at the intersection is counted based on the traffic light status and the order in which vehicles cross the auxiliary lines at key points, using a coding query method. Specifically:
[0060] The first auxiliary line coding position is 1, the second auxiliary line coding position is 1, and the third auxiliary line coding position is 1, with the first auxiliary line coding position being set to 1 first, corresponding to vehicles going straight into the lane opposite the camera device;
[0061] The first auxiliary line coding position is 1, the second auxiliary line coding position is 1, and the third auxiliary line coding position is 1, with the third auxiliary line coding position being set to 1 first. The corresponding vehicle will proceed straight from the lane opposite the camera device into the lane where the camera device is located.
[0062] The first auxiliary line coding position 1, the second auxiliary line coding position 1, and the third auxiliary line coding position 0 correspond to vehicles turning left from the lane where the camera is located into its left-turn lane, that is, the left lane direction from the perspective of the camera.
[0063] The first auxiliary line coding position 0, the second auxiliary line coding position 1, and the third auxiliary line coding position 1 correspond to vehicles entering their left-turn lane from the lane opposite the camera device, that is, the right lane direction from the camera device's perspective.
[0064] The first auxiliary line coding position 1, the second auxiliary line coding position 0, and the third auxiliary line coding position 0 correspond to vehicles entering their right turn lane from the lane where the camera is located, i.e., the right lane direction from the camera's field of view.
[0065] The first auxiliary line coding position 0, the second auxiliary line coding position 0, and the third auxiliary line coding position 1 correspond to vehicles entering their right-turn lane from the lane opposite the camera device, i.e., the left lane direction from the camera device's perspective.
[0066] Figure 3 and Figure 4 These are schematic diagrams of an intersection when the north-south and east-west traffic lights are green. Two cameras are installed on the south and east sides of the intersection, respectively. The three auxiliary lines under this schematic diagram are set as follows:
[0067] The first auxiliary line (in this embodiment, it is a dashed line, but other forms of lines can also be used) is set in front of the lane where the camera is located and in the middle of the zebra crossing;
[0068] The second auxiliary line (a solid line in this embodiment, but other forms of lines may also be used) is set at the center line of the lane;
[0069] The third auxiliary line (in this embodiment, a dotted line is used, but other types of lines can also be used) is set in front of the lane opposite the camera device and in the middle of the zebra crossing.
[0070] There are a total of 12 coding scenarios for this traffic light status, covering the four cardinal directions (north, south, east, and west) and the three possible vehicle actions: going straight, turning left, and turning right. The coding scenarios are shown in Table 1 below. Figure 5 (a) to 5(f) correspond to the traffic flow trajectories under the six coding conditions where the north-south direction is green and the east-west direction is red.
[0071] Table 1
[0072]
[0073] Next, a system embodiment of the present invention is given: a crossroads directional traffic flow counting system. The system includes a camera device installed at the crossroads, a wireless communication module for system data transmission, a road condition information detection module for acquiring traffic light status information, a traffic flow counting module, and a result output module. The traffic flow counting module adopts the crossroads directional traffic flow counting method based on the above-mentioned YOLO algorithm, counts the crossroads directional traffic flows based on the traffic flow video collected by the camera device and the traffic light status information acquired by the road condition information detection module, and the result output module outputs the final directional traffic flow counting result.
[0074] Furthermore, such as Figure 2 As shown, the system includes a camera device 1, a data content generation module 2, a wireless communication module 3, a data transmission module 4, a road condition information detection module 5, a road condition information input module 6, a traffic flow counting module 7, and a result output module 8. The camera device 1 is installed above the road. The data content generation module 2 and the wireless communication module 3 are connected to the camera device 1. The road condition information detection module 5, the road condition information input module 6, and the traffic flow counting module 7 are connected to the data transmission module 4, and the data transmission module 4 is connected to the result output module 8.
[0075] The video acquired by camera device 1 is transmitted to data content generation module 2 and then transmitted to data transmission module 4 via wireless communication module 3. At the same time, traffic information detection module 5 detects the traffic light status during the current time period, determines which direction the camera device is in an effective working state, i.e., the transmitted information is accurate, and transmits the result to traffic information input module 6 via data transmission module 4. Traffic information input module 6 and traffic flow counting module 7 perform corresponding calculations on the information and then output it to result output module 8.
[0076] The system implementation process is as follows:
[0077] Step 1: Camera device 1 continuously acquires real-time traffic flow video.
[0078] Step 2: Determine the status of the traffic lights in the horizontal direction. If the green light is flashing, the data algorithm module begins to identify it.
[0079] Step 3: Start recognition. Identify all vehicles appearing in the video, draw anchor frames and number them, and mark the center point of the anchor frame with a red dot.
[0080] Step 4: Draw three auxiliary lines. The dashed line is located in front of the lane where your camera is located and in the middle of the zebra crossing. The dotted line is located in front of the lane in the opposite direction and in the middle of the zebra crossing. The solid line is located at the center line of the transverse lane.
[0081] Step 5: If a vehicle crosses the auxiliary line at a key point, the code lookup table (as shown in Table 1) cached in the traffic flow counting module 7 is queried according to the order of occurrence and the status of the traffic lights. Based on the results of the lookup table, the four directions of the intersection are counted separately.
[0082] Step 6: When the traffic information detection module detects that the green light in this direction has turned red, it continues to detect for k seconds (k=3 in this embodiment) and then stops working; at this time, the camera stops working, and the other camera starts to execute step 5 in a loop, and so on.
[0083] This invention utilizes data transmission counting and recognition algorithms, with the aid of an embedded platform, to solve the problem of traffic counting in complex road sections such as urban intersections.
[0084] The electronic device of this invention includes a central processing unit (CPU), which can perform various appropriate actions and processes according to computer program instructions stored in read-only memory (ROM) or loaded from a storage unit into random access memory (RAM). The RAM may also store various programs and data required for device operation. The CPU, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0085] Multiple components in the device are connected to the I / O interface, including: input units such as keyboards and mice; output units such as various types of displays and speakers; storage units such as disks and optical discs; and communication units such as network interface cards (NICs), modems, and wireless transceivers. The communication unit allows the device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0086] The processing unit performs the various methods and processes described above. For example, in some embodiments, the methods may be implemented as computer software programs tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed on the device via ROM and / or a communication unit. When the computer program is loaded into RAM and executed by the CPU, one or more steps of the methods described above may be performed. Alternatively, in other embodiments, the CPU may be configured to execute the methods by any other suitable means (e.g., by means of firmware).
[0087] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Load Programmable Logic Devices (CPLDs), and so on.
[0088] The program code used to implement the methods of the present invention can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0089] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0090] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for counting traffic flows in different directions at a crossroads, characterized in that, The method includes: Cameras are installed at any two intersections to continuously acquire real-time traffic flow video from all directions, viewed from the current lane. Specifically, when the traffic light for the current lane is green, the first camera in the current lane starts working, while the second camera in the other lane goes into sleep mode. When the traffic light for the current lane changes from green to red, the first camera continues to collect data for k seconds and then goes into sleep mode, at which point the second camera starts working, and this cycle repeats. Three parallel auxiliary lines are added to the traffic flow video captured by each camera device. The YOLO algorithm is used to identify vehicles in the traffic video stream, and the traffic flow is counted in different directions based on the traffic light status and the encoding settings based on the vehicle key points crossing the auxiliary lines. The three parallel auxiliary lines include: The first auxiliary line is set in the lane where the camera is located; The second auxiliary line is set in the middle of the intersection; The third auxiliary line is set in the lane opposite the camera device; The coding settings based on vehicle key points crossing auxiliary lines are as follows: If a key point of the vehicle crosses an auxiliary line, the corresponding code position of the current auxiliary line is set to 1; otherwise, it is set to 0. The traffic flow at the intersection is counted in each of the four directions by encoding and querying the traffic light status and the order in which vehicles cross the auxiliary lines at key points. The method involves encoding and querying traffic flow according to traffic light status and the order in which vehicles cross auxiliary lines at key points, and counting traffic flow in all four directions of the intersection. Specifically: The first auxiliary line coding position is 1, the second auxiliary line coding position is 1, and the third auxiliary line coding position is 1, with the first auxiliary line coding position being set to 1 first, corresponding to vehicles going straight into the lane opposite the camera device; The first auxiliary line coding position is 1, the second auxiliary line coding position is 1, and the third auxiliary line coding position is 1, with the third auxiliary line coding position being set to 1 first. The corresponding vehicle will proceed straight from the lane opposite the camera device into the lane where the camera device is located. The first auxiliary line coding position 1, the second auxiliary line coding position 1, and the third auxiliary line coding position 0 correspond to vehicles turning left from the lane where the camera is located into its left-turn lane, that is, the left lane direction from the perspective of the camera. The first auxiliary line coding position 0, the second auxiliary line coding position 1, and the third auxiliary line coding position 1 correspond to vehicles entering their left-turn lane from the lane opposite the camera device, that is, the right lane direction from the camera device's perspective. The first auxiliary line coding position 1, the second auxiliary line coding position 0, and the third auxiliary line coding position 0 correspond to vehicles entering their right turn lane from the lane where the camera is located, i.e., the right lane direction from the camera's field of view. The first auxiliary line coding position 0, the second auxiliary line coding position 0, and the third auxiliary line coding position 1 correspond to vehicles entering their right-turn lane from the lane opposite the camera device, i.e., the left lane direction from the camera device's perspective.
2. The method for counting traffic flows in different directions at an intersection according to claim 1, characterized in that, The first auxiliary line and the third auxiliary line are respectively set in front of the lane in the direction of the camera device and in the middle of the zebra crossing, and in front of the lane in the opposite direction and in the middle of the zebra crossing; the second auxiliary line is set at the center line of the transverse lane.
3. The method for counting traffic flows in different directions at a crossroads according to claim 1, characterized in that, The YOLO algorithm is used to identify vehicles in traffic video streams, specifically as follows: The input traffic video stream images undergo format adjustment and normalization preprocessing. The preprocessed traffic video stream images are input into the YOLO v5 model to obtain prediction results, including bounding box coordinates, object category probabilities, and confidence scores. Post-processing was performed using nonmaximum suppression. Select the object category label as "vehicle" for the output, and draw anchor boxes for it and number them.
4. A crossroads traffic flow counting system, characterized in that, The system includes a camera device installed at the intersection, a wireless communication module for system data transmission, a road condition detection module for acquiring traffic light status information, a traffic flow counting module, and a result output module. The traffic flow counting module adopts the crossroads traffic flow counting method according to any one of claims 1 to 3. It counts the crossroads traffic flow based on the traffic flow video collected by the camera device and the traffic light status information obtained by the road condition information detection module, and outputs the final crossroads traffic flow counting result by the result output module.
5. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Traffic light automatic adjusting method and system and traffic light system
CN104599512A
Traffic light system
CN107067744A
Intelligent flow identification and statistics method for complex traffic intersection
CN111554105A
Intersection multi-steering vehicle counting method and system
CN113936255A