Method for judging driving speed and direction of vehicle at curve intersection
By identifying the vehicle and calculating its center coordinates, and combining the coordinate information of three adjacent frames, the problem of difficult to accurately judge the vehicle's driving direction and speed in the prior art is solved, and the accuracy of traffic monitoring and road safety are improved.
Patent Information
- Application Number
- CN202411914494.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-05-13
AI Technical Summary
When handling complex road conditions such as curved intersections, existing traffic monitoring systems based on machine vision are difficult to accurately judge the vehicle's driving direction and speed. Especially when the number of vehicles changes greatly, they cannot effectively manage the vehicle's coordinate information and cannot take corresponding traffic management measures based on the vehicle's driving status.
By identifying the vehicle and drawing a rectangular box, calculating the center coordinates of the vehicle, storing the center coordinates of the three adjacent frames, sorting and distance calculations, finding the point pair with the smallest distance in the paired points, and judging the driving direction and speed of the vehicle.
It improves the accuracy and timeliness of traffic monitoring, provides more reaction time, improves road safety, and can adapt to changes in traffic flow, effectively manages vehicle coordinate information, and provides a scientific basis for traffic management.
Smart Images

Figure CN119992469A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of vehicle driving analysis, and in particular to a method for determining the driving speed and direction of a vehicle at a curved road intersection. Background Art
[0002] With the acceleration of urbanization, traffic safety issues are becoming increasingly prominent, especially in complex road conditions such as curved intersections. Due to obstructed vision, drivers often find it difficult to obtain the traffic conditions on the other side of the road in advance, which increases the risk of traffic accidents. Traditional traffic safety measures, such as convex mirrors, can improve vision to a certain extent, but they have shortcomings such as limited field of view and mirror cleaning problems. In addition, with the increase in traffic volume, it becomes particularly important to accurately monitor and analyze vehicle driving status in real time.
[0003] To solve this problem, machine vision technology has been introduced into the field of traffic monitoring. By capturing road conditions with cameras and analyzing vehicle behavior using image recognition algorithms, drivers can be provided with more accurate road condition information. As an advanced target detection algorithm, YOLOV5 can efficiently and accurately identify and locate vehicles in images, providing strong technical support for traffic monitoring.
[0004] However, existing machine vision-based traffic monitoring systems still face some challenges when dealing with complex road conditions such as curved intersections. For example, how to accurately determine the direction and speed of vehicles, especially when the number of vehicles changes greatly, how to effectively manage the vehicle's coordinate information, and how to take corresponding traffic management measures based on the vehicle's driving status. Summary of the invention
[0005] In order to solve the above-mentioned shortcomings of the prior art, the present invention provides a method for determining the speed and direction of vehicles at a curved intersection, which can effectively solve the problems in the prior art that the direction and speed of vehicles cannot be accurately determined, especially when the number of vehicles changes greatly, the coordinate information of the vehicles cannot be effectively managed, and corresponding traffic management measures cannot be taken according to the driving status of the vehicles.
[0006] To achieve the above objectives, the present invention is implemented through the following technical solutions:
[0007] The present invention provides a method for determining the speed and direction of a vehicle at a curved intersection, comprising the following steps:
[0008] S1, by identifying the rectangular frame drawn by the vehicle, calculate and obtain the center coordinates of the vehicle;
[0009] S2, storing the point sets of the first frame, the second frame, and the third frame into three point sets respectively;
[0010] S3, processing the three stored point sets, matching any two groups of the three point sets, and dividing them into three groups; processing the point set in each group, extracting the paired point sets, and there are three paired point sets in total;
[0011] S4, processing paired point sets;
[0012] S5. The point sets of three adjacent frames are stored and iterated.
[0013] Furthermore, the steps of S1 are as follows:
[0014] When the camera recognizes the corresponding vehicle type, it frames the vehicle to obtain a rectangular frame. The coordinates of the four diagonal points of the rectangular frame are (x0, y0), (x0, y1), (x1, y0), and (x1, y1). The center formula is:
[0015]
[0016] Get the center coordinates (x', y') of the vehicle.
[0017] Furthermore, the steps of S2 are as follows:
[0018] In the camera image, a coordinate system is defined according to the length and width of the camera image, with the length being the horizontal coordinate and the width being the vertical coordinate;
[0019] The entire screen is divided into four different areas, namely the parking area, the normal driving area, the left boundary area, and the right boundary area; four boundary lines are used to divide these areas, and then the calculated center coordinates of the vehicle are placed in the following three empty point sets middle:
[0020] First frame point set:
[0021]
[0022] Second frame point set:
[0023]
[0024] The third frame point set:
[0025]
[0026] In the above, A i1 represents the coordinates of the i-th point in the first frame, A j2 represents the coordinates of the jth point in the second frame, A k3 Represents the coordinates of the kth point in the 3rd frame.
[0027] Furthermore, the steps of S3 include:
[0028] The three stored point sets are processed, and any two of the three point sets are matched to form three groups; the point sets in each group are processed, and paired point sets are extracted, resulting in three paired point sets in total, including:
[0029] Point Set First sort by x coordinate size, Each point in The distance is calculated for each point in the equation:
[0030]
[0031] Where p = 0, 1, 2, ..., i
[0032] q=0,12,...,j;
[0033] for Each point in Calculate the distance of each point in the L, there are i×j points in total, and there are i points corresponding to the distance. Find the one with the smallest distance L min , and then set a distance minimum S, if the coordinates meet the following conditions:
[0034]
[0035] x left Indicates the left edge of the screen, x right Indicates the right border of the screen, T1(x) and T2(x) respectively represent the upper and lower border functions of the y coordinate determined by the x coordinate.
[0036] Further, Corresponds to The coordinates in satisfy the condition Then there is,
[0037] Put the coordinates into the empty point set get After the point set, follow the same method to Mid-coordinates and point sets The coordinates are calculated according to the above steps to find The coordinates that meet the above conditions are put into the empty point set in and The coordinates are calculated according to the above steps, and the corresponding coordinates are placed in As shown below:
[0038]
[0039] in, 是 The corresponding paired point sets;
[0040] yes The corresponding paired point sets;
[0041] yes The corresponding pair of points.
[0042] 6. A method for determining the speed and direction of vehicles at a curved intersection according to claim 5, characterized in that six point sets are obtained through steps S2-S3, which are
[0043] The six point sets are mutually corresponding. The x-coordinates and y-coordinates of the corresponding points are calculated to obtain their changes Δx and Δy. Δx and Δy represent the changes of the x-coordinates and y-coordinates respectively. The distance between the corresponding coordinates is calculated D according to the Euclidean distance formula, and a distance extreme value D is set. min , used to determine whether the vehicle is moving. If the distance D between two frames is greater than D min , the vehicle is considered to be moving.
[0044] The first frame of vehicle coordinates is (x a1 ,y a1 ), the second frame is (x a2 ,y a2 ), the third frame is (x a3 ,y a3 ), and the vehicle meets the following conditions through calculation:
[0045]
[0046] Where Δx 12 , Δy 12 Respectively represent the change in x and y coordinates from the first frame to the second frame, Δx 23 , Δy 23 Respectively represent the change in x and y coordinates from the second frame to the third frame, x 13 ,y 13 Respectively represent the changes in x and y coordinates from the first frame to the third frame, D 12 , D 13 , D 23 They respectively represent the distance traveled by the vehicle from the first frame to the second frame, the distance traveled by the vehicle from the second frame to the third frame, and the distance traveled by the vehicle from the first frame to the third frame.
[0047] If the vehicle meets any two of the following conditions, the vehicle is judged to be traveling at a slow speed:
[0048]
[0049] Where Δx 12 , Δy 12 , Δx 23 , Δy 23 , Δx 13 , Δy 13 Respectively represent the changes in x-coordinates and y-coordinates between adjacent frames.
[0050] Furthermore, if the vehicle coordinates in the first frame are (x a1 ,y a1 ), the second frame is (x a2 ,y a2 ), the third frame is (x a3 ,y a3 ), and the vehicle meets the following conditions through calculation:
[0051]
[0052] It is concluded that the vehicle's traveling direction is the outgoing direction.
[0053] Furthermore, based on steps S1-S5, 9 point sets are obtained, namely in What is stored is the coordinates of three adjacent frames. Clear the point set in φ, clear the point set in φ1, put the point set of φ2 into φ1, clear the point set in φ2, put the point set in φ3 into φ2, clear the point set in φ3, and put the point set of the next frame into φ3, so that φ1, φ2, and φ3 store the coordinates of three adjacent frames.
[0054] Compared with the known prior art, the technical solution provided by the present invention has the following beneficial effects:
[0055] By identifying the vehicle through the model and drawing a rectangular frame, the center coordinates of the vehicle are calculated. Then, the center coordinates of the vehicle in three adjacent frames are stored in a point set, and the point pair with the smallest distance in the paired point set is found through sorting and distance calculation. Finally, the direction and speed of the vehicle are determined based on the coordinate change and distance of the point pair, thereby improving the accuracy and timeliness of traffic monitoring, and providing drivers with more reaction time, thereby improving road safety;
[0056] In addition, this method can also adapt to changes in traffic flow, effectively manage vehicle coordinate information, and provide a scientific basis for traffic management. Through this method, the driver can be informed of the road conditions on the other side of the intersection in advance, giving the driver sufficient reaction time, greatly improving the safety of the intersection. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0058] Figure 1 It is a schematic diagram of the overall method of the present invention;
[0059] Figure 2 It is a schematic diagram of the recognition scene of the present invention;
[0060] Figure 3 This is one of the schematic diagrams for judging the vehicle condition of the present invention;
[0061] Figure 4 This is the second schematic diagram of vehicle condition determination of the present invention;
[0062] Figure 5 This is the third schematic diagram of vehicle condition determination of the present invention;
[0063] Figure 6 This is the fourth schematic diagram of vehicle condition judgment of the present invention. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0065] The present invention will be further described below in conjunction with the embodiments.
[0066] Example 1 (see Figure 1-Figure 6 ): A method for determining the speed and direction of a vehicle at a curved intersection, comprising at least:
[0067] S1: By identifying the rectangular frame drawn by the vehicle, the center coordinates of the vehicle are calculated, including:
[0068] like Figure 2 As shown, when the camera recognizes the corresponding vehicle type, it frames the vehicle to obtain a rectangular frame. The coordinates of the four diagonal points of the rectangular frame are (x0, y0), (x0, y1), (x1, y0), and (x1, y1). Through the center formula:
[0069]
[0070] Get the center coordinates (x', y') of the vehicle.
[0071] S2: Store the point sets of the first frame, the second frame, and the third frame into three point sets respectively.
[0072] like Figure 3 As shown in the figure, in the camera image, the coordinate system is defined according to the length and width of the camera image, with the length as the horizontal coordinate and the width as the vertical coordinate; the entire image is divided into four different areas, namely the parking area, the normal driving area, the left boundary area, and the right boundary area; four boundary lines are used to divide these areas, and then the calculated center coordinates of the vehicle are placed in the following three empty point sets middle:
[0073] First frame point set:
[0074]
[0075] Second frame point set:
[0076]
[0077] The third frame point set:
[0078]
[0079] In the above, A i1 represents the coordinates of the i-th point in the first frame, A j2 represents the coordinates of the jth point in the second frame, A k3 Represents the coordinates of the kth point in the 3rd frame.
[0080] S3: Process the three stored point sets, match any two of the three point sets, and divide them into three groups; process the point set in each group, extract the paired point sets, and there are three paired point sets in total, including:
[0081] Point Set First sort by x coordinate size, Each point in The distance is calculated for each point in the equation:
[0082]
[0083] Where p = 0, 1, 2, ..., i
[0084] q=0,12,...,j
[0085] for Each point in Calculate the distance of each point in the L, there are i×j points in total, and there are i points corresponding to the distance. Find the one with the smallest distance L min , and then set a distance minimum S, if the coordinates meet the following conditions:
[0086]
[0087] x left Indicates the left edge of the screen, x right represents the right boundary of the screen, T1(x) and T2(x) represent the upper and lower boundary functions of the y coordinate determined by the x coordinate respectively;
[0088] if Corresponds to The coordinates in the point set satisfy the condition and are placed in the empty point set. get After the point set, follow the same method to Mid-coordinates and point sets The coordinates are calculated according to the above steps to find The coordinates that meet the above conditions are put into the empty point set in and The coordinates are calculated according to the above steps, and the corresponding coordinates are placed in As shown below:
[0089]
[0090] in, yes The corresponding paired point sets;
[0091] yes The corresponding paired point sets;
[0092] yes The corresponding paired point sets;
[0093] S4. Through steps S2-S3, 6 point sets are obtained, which are These six point sets are mutually corresponding. The x-coordinates and y-coordinates of the corresponding points are calculated to obtain their changes Δx and Δy. Δx and Δy represent the changes of the x-coordinates and y-coordinates respectively. The distance between the corresponding coordinates is calculated D according to the Euclidean distance formula, and a distance extreme value D is set. min , used to determine whether the vehicle is moving. If the distance D between the two frames is greater than D min , the vehicle is considered to be moving.
[0094] like Figure 4 As shown, the first frame of vehicle coordinates is (x a1 ,y a1 )(coordinates of the vehicle in the first frame), and the second frame is (x a2 ,y a2 )(coordinates of the vehicle in the second frame), and the third frame is (x a3 ,y a3 )(coordinates of the vehicle in the third frame), it is calculated that the vehicle meets the following conditions:
[0095]
[0096] Where Δx 12 , Δy 12 Respectively represent the change in x and y coordinates from the first frame to the second frame, Δx 23 , Δy 23 Respectively represent the changes in the x and y coordinates from the second frame to the third frame, x 13 ,y 13 Respectively represent the changes in x and y coordinates from the first frame to the third frame, D 12 , D 13 , D 23 They respectively represent the distance traveled by the vehicle from the first frame to the second frame, the distance traveled by the vehicle from the second frame to the third frame, and the distance traveled by the vehicle from the first frame to the third frame.
[0097] From the above formula, we can see that in the three adjacent frames, the changes in the horizontal and vertical coordinates of the vehicle are greater than 0, and the distance traveled by the vehicle is greater than the extreme distance D. min It can be concluded that the vehicle is traveling in the direction of the oncoming vehicle and is traveling very fast.
[0098] like Figure 5 As shown, by calculating that the vehicle satisfies any two of the following conditions, it can be determined that the vehicle is traveling at a slow speed:
[0099]
[0100] Where Δx 12 , Δy 12 , Δx 23 , Δy 23 , Δx 13 , Δy 13 Respectively represent the changes in x-coordinates and y-coordinates between adjacent frames.
[0101] From the above formula, it can be seen that the vehicle satisfies the first, third frame and the second, third frame or the first, third frame and the second, third frame or the first, second frame and the second, third frame, where the change of the horizontal coordinate or coordinate is greater than 0 and the vehicle's travel distance is less than the distance extreme value D min, it can be concluded that the vehicle is traveling in the direction of the oncoming vehicle and is traveling at a slower speed;
[0102] like Figure 6 As shown, the first frame of vehicle coordinates is (x a1 ,y a1 ), the second frame is (x a2 ,y a2 ), the third frame is (x a3 ,y a3 ), and the vehicle meets the following conditions through calculation:
[0103]
[0104] It can be seen from the above formula that in three adjacent frames, the changes in the horizontal and vertical coordinates of the vehicle are all less than 0, and it can be concluded that the driving direction of the vehicle is the direction of the vehicle going forward.
[0105] S5. At this time, there are 9 point sets, namely Among them, φ1, φ2, and φ3 store the coordinates of three adjacent frames. We first Clear all the point sets in φ1, then clear the point set in φ2, put the point set in φ1, clear the point set in φ2, put the point set in φ3 into φ2, clear the point set in φ3, and put the point set of the next frame into φ3. In this way, it can be ensured that the coordinates of three adjacent frames are stored in φ1, φ2, and φ3.
[0106] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements will not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for determining the speed and direction of vehicles at a curved intersection, characterized in that: The steps include: S1, by identifying the rectangular frame drawn by the vehicle, calculate and obtain the center coordinates of the vehicle; S2, storing the point sets of the first frame, the second frame, and the third frame into three point sets respectively; S3, processing the three stored point sets, matching any two groups of the three point sets, and dividing them into three groups; processing the point set in each group, extracting the paired point sets, and there are three paired point sets in total; S4, processing paired point sets; S5. The point sets of three adjacent frames are stored and iterated.
2. A method for determining the speed and direction of vehicles at a curved intersection according to claim 1, characterized in that: The steps of S1 are as follows: When the camera recognizes the corresponding vehicle type, it frames the vehicle to obtain a rectangular frame. The coordinates of the four diagonal points of the rectangular frame are (x0, y0), (x0, y1), (x1, y0), and (x1, y1). The center formula is: Get the center coordinates (x', y') of the vehicle.
3. A method for determining the speed and direction of vehicles at a curved intersection according to claim 2, characterized in that: The steps of S2 are as follows: In the camera image, a coordinate system is defined according to the length and width of the camera image, with the length being the horizontal coordinate and the width being the vertical coordinate; The entire screen is divided into four different areas, namely the parking area, the normal driving area, the left boundary area, and the right boundary area; Use four boundary lines to divide these areas, and then place the calculated center coordinates of the vehicle in the following three empty point sets: middle: First frame point set: Second frame point set: The third frame point set: In the above, A i1 represents the coordinates of the i-th point in the first frame, A j2 represents the coordinates of the jth point in the second frame, A k3 Represents the coordinates of the kth point in the 3rd frame.
4. A method for determining the speed and direction of vehicles at a curved intersection according to claim 3, characterized in that: The steps of S3 include: The three stored point sets are processed, and any two of the three point sets are matched to form three groups; the point sets in each group are processed, and paired point sets are extracted, resulting in three paired point sets in total, including: Point Set First sort by x coordinate size, Each point in The distance is calculated for each point in the equation: Where p = 0, 1, 2, ..., i for Each point in Calculate the distance of each point in the L, there are i×j points in total, and there are i points corresponding to the distance. Find the one with the smallest distance L min , and then set a distance minimum S, if the coordinates meet the following conditions: x left Indicates the left edge of the screen, x right Indicates the right boundary of the screen, T1(x) and T2(x) respectively represent the upper and lower boundary functions of the y coordinate determined by the x coordinate.
5. A method for determining the speed and direction of vehicles at a curved intersection according to claim 4, characterized in that: Corresponds to The coordinates in satisfy the condition Then there is, Put the coordinates into the empty point set get After the point set, follow the same method to Mid-coordinates and point sets The coordinates are calculated according to the above steps to find The coordinates that meet the above conditions are put into the empty point set in and The coordinates are calculated according to the above steps, and the corresponding coordinates are placed in As shown below: in, The corresponding paired point sets; yes The corresponding paired point sets; yes The corresponding pair of points.
6. A method for determining the speed and direction of vehicles at a curved intersection according to claim 5, characterized in that: Through steps S2-S3, 6 point sets are obtained, namely The six point sets are mutually corresponding. The x-coordinates and y-coordinates of the corresponding points are calculated to obtain their changes Δx and Δy. Δx and Δy represent the changes of the x-coordinates and y-coordinates respectively. The distance between the corresponding coordinates is calculated D according to the Euclidean distance formula, and a distance extreme value D is set. min , used to determine whether the vehicle is moving. If the distance D between two frames is greater than D min , the vehicle is considered to be moving.
7. A method for determining the speed and direction of vehicles at a curved intersection according to claim 6, characterized in that: The first frame of vehicle coordinates is (x a1 ,y a1 ), the second frame is (x a2 ,y a2 ), the third frame is (x a3 ,y a3 ), and the vehicle meets the following conditions through calculation: Where Δx 12 , Δy 12 Respectively represent the change in x and y coordinates from the first frame to the second frame, Δx 23 , Δy 23 Respectively represent the change in x and y coordinates from the second frame to the third frame, x 13 ,y 13 Respectively represent the changes in x and y coordinates from the first frame to the third frame, D 12 , D 13 , D 23 They respectively represent the distance traveled by the vehicle from the first frame to the second frame, the distance traveled by the vehicle from the second frame to the third frame, and the distance traveled by the vehicle from the first frame to the third frame.
8. The method for determining the speed and direction of vehicles at a curved intersection according to claim 7, characterized in that: If the vehicle meets any two of the following conditions, the vehicle is judged to be traveling at a slow speed: Where Δx 12 , Δy 12 , Δx 23 , Δy 23 , Δx 13 , Δy 13 Respectively represent the changes in x-coordinates and y-coordinates between adjacent frames.
9. The method for determining the speed and direction of vehicles at a curved intersection according to claim 8, characterized in that: If the vehicle coordinates in the first frame are (x a1 ,y a1 ), the second frame is (x a2 ,y a2 ), the third frame is (x a3 ,y a3 ), and the vehicle meets the following conditions through calculation: It is concluded that the vehicle's traveling direction is the outgoing direction.
10. The method for determining the speed and direction of vehicles at a curved intersection according to claim 9, characterized in that: Based on steps S1-S5, 9 point sets are obtained, namely φ1, φ2, φ3, Among them, φ1, φ2, and φ3 store the coordinates of three adjacent frames. Clear the point set in φ, clear the point set in φ1, put the point set of φ2 into φ1, clear the point set in φ2, put the point set in φ3 into φ2, clear the point set in φ3, and put the point set of the next frame into φ3, so that φ1, φ2, and φ3 store the coordinates of three adjacent frames.