Vehicle converse driving detection method for expressway
By analyzing the relative positional changes of vehicle trajectory and lane information in real time during highway vehicle wrong-way detection, and dynamically generating a multi-level detection area parallel input model, the problems of high computational overhead and high false alarm rate in traditional methods are solved, achieving efficient and accurate vehicle wrong-way detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-03-13
AI Technical Summary
Traditional methods for detecting vehicles driving in the wrong direction on highways suffer from high computational overhead due to frame-by-frame analysis of lane areas, and are prone to background interference and missed detection of small vehicles, leading to safety hazards and false alarms.
By analyzing the relative positional changes of vehicle trajectory and identified lane information in real time, multiple hierarchical target detection areas are dynamically generated and input into the target detection model for inference. By combining lane tilt angle to identify occlusion, lane lines are optimized, reducing computational overhead and improving detection efficiency.
It significantly reduces computational costs and false alarm rates in high-speed scenarios, improves the detection rate of small vehicles, ensures the accuracy of lane information, and achieves vehicle reverse-driving detection with low human intervention, high real-time performance, and high accuracy.
Smart Images

Figure CN121661845A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of vehicle driving detection technology, and in particular to a method for detecting vehicles driving in the wrong direction on highways. Background Technology
[0002] Driving against the flow of traffic on highways is one of the core contributing factors to serious traffic accidents. Real-time and accurate identification of vehicles driving against the flow of traffic can effectively prevent such accidents.
[0003] Traditional traffic monitoring relies on manual patrols or simple sensors, which is not only inefficient but also prone to misjudgments. Modern reverse-driving identification and detection technologies mainly utilize computer vision and deep learning algorithms to achieve efficient, automated, and real-time monitoring and alarms.
[0004] For example, patent application CN116363859A discloses a technique for detecting vehicles driving in the wrong direction using a spherical camera. This method utilizes the YOLACT model to simultaneously output vehicle target detection boxes and their lane-level mask maps in the image. Based on this, it outputs dual detection results: on the one hand, by comparing the lane mask map generated in the current frame with a preset static base lane mask map in real time, it determines whether the spherical camera has rotated; on the other hand, assuming the spherical camera's viewing angle is stable, it analyzes the motion trajectory between consecutive frames by combining the detected vehicle target information, thereby identifying whether a driving in the wrong direction event has occurred.
[0005] Firstly, relying on instance segmentation models such as YOLACT to extract full-map road features frame by frame and identifying changes in camera field of view by comparing features of consecutive frames results in high computational overhead. Secondly, the full-map detection scheme is prone to introducing background interference, and the high rate of missed detection of distant / small vehicles poses a significant safety hazard. Finally, cameras installed on both sides of the road often have missing lane lines due to fixed obstructions such as flower beds. If the missing lane lines are not optimized, it can easily lead to false alarms of vehicles driving in the wrong direction. Summary of the Invention
[0006] The purpose of this invention is to provide a vehicle wrong-way detection method for highways, so as to solve the problem of high computational overhead caused by analyzing lane areas frame by frame in traditional vehicle wrong-way detection methods for highway scenarios.
[0007] To achieve the above objectives, the technical method adopted by the present invention is: a method for detecting vehicles driving in the wrong direction on highways, the method comprising the following steps:
[0008] S1: Read the initial data of a single frame of high-speed video stream, input the initial data into the lane line detection model to obtain lane lines, and generate initial lane information based on the lane lines, wherein the initial lane information includes lane area and initial direction of lane;
[0009] S2: Based on the information of the lane area, adaptively generate the first area and the second area;
[0010] S3: Continuously read subsequent frame data from the high-speed video stream, input the first region and the second region in parallel into the target detection model to obtain the vehicle detection result for each region; fuse the vehicle detection results and input the fused vehicle detection results into the multi-target tracking algorithm to obtain vehicle trajectory information;
[0011] S4: Based on the vehicle trajectory information and lane information, determine the driving direction of the lane, and repeat S3-S4 until the driving direction of all lanes is determined.
[0012] S5: Based on the current vehicle's trajectory information and the direction of travel in its lane, identify whether the current vehicle is driving in the wrong direction.
[0013] Further, in S1, generating initial lane information based on the lane lines includes connecting the feature points of two adjacent lane lines in a preset order to form a closed polygonal lane region, and setting the initial direction of the lane based on the extension trend of the lane lines. The lane lines consist of a set of points arranged from near to far. Setting the initial direction of the lane specifically includes:
[0014] S1.1: Calculate the coordinates of the midpoint of the left lane line and the coordinates of the point to the right of the midpoint, and use them as the first left coordinate and the second left coordinate;
[0015] S1.2: Calculate the coordinates of the midpoint of the right lane line and the coordinates of the point to the right of the midpoint, and use them as the first right coordinate and the second right coordinate;
[0016] S1.3: The midpoint between the left first coordinate point and the right first coordinate point is taken as the starting point of the initial direction of the lane, and the midpoint between the left second coordinate point and the right second coordinate point is taken as the ending point of the initial direction of the lane. The direction from the starting point to the ending point is the initial direction of the lane.
[0017] Further, S3.1: Integrate the detection results of the first region into a first set and the detection results of the second region into a second set;
[0018] S3.2: Perform boundary shrinkage on the second region to obtain the second detection shrinkage region. The remaining region within the second region is the second detection boundary region. The targets in the second set that are located within the second detection boundary region constitute the second boundary set.
[0019] S3.3: Delete targets in the first set that are within the second detection shrinkage region, including deleting targets on the border line of the second detection shrinkage region, to obtain the first shrinkage set;
[0020] S3.4: Traverse each target in the second boundary set, calculate the intersection-union ratio (IUR) of each target with the target box of the first shrinking set, and if the IUR is greater than 0, remove the corresponding target from the second set; otherwise, retain the corresponding target to obtain the second shrinking set.
[0021] S3.5: Take the union of the first contracted set and the second contracted set to obtain the fused vehicle detection result.
[0022] Furthermore, it also includes an adaptively generated third region; the specific process of adaptively generating multiple regions includes:
[0023] Calculate the smallest bounding rectangle containing all lane lines, and use it as the first region;
[0024] Set a horizontal reference direction and a vertical reference direction, calculate the first angle between the initial direction of the lane and the horizontal reference direction, and the second angle between the initial direction of the lane and the vertical reference direction, and compare the first angle with 90° to determine the lane line inclination direction, specifically including:
[0025] When the first included angle of the leftmost and rightmost lanes is greater than 90°, select the upper left 1 / 4 sub-region of the first region as the second region, and select the upper left 1 / 4 sub-region of the second region as the third region.
[0026] When the first included angle of the leftmost and rightmost lanes is less than or equal to 90°, select the upper right 1 / 4 sub-region of the first region as the second region, and select the upper right 1 / 4 sub-region of the second region as the third region.
[0027] In other cases, the 1 / 4 sub-region directly above the first region is selected as the second region, and the 1 / 4 sub-region directly above the second region is selected as the third region.
[0028] Furthermore, boundary shrinking of the second region includes: when the second target region is taken from the upper left 1 / 4 sub-region or the upper right 1 / 4 sub-region of the first region:
[0029] Obtain the corner points of the second region that are inside the first region, connect the corner points with two adjacent corner points in the second region to form two sides, and shrink the maximum pixel size of the vehicle's position box across the boundary between the first and second regions towards the center point of the second region to obtain the second detection shrinkage region;
[0030] When the second target area is taken directly above the first area:
[0031] The maximum pixel size of the vehicle's location box at the intersection of the first and second regions is shrunk by moving the three edges of the second region, which are located inside the first region, toward the center point of the second region, to obtain the second detection shrinkage region.
[0032] Furthermore, in S3, it also includes simultaneously identifying whether the camera's field of view has changed based on the vehicle target trajectory features: if a change in the camera's field of view is detected, the current lane information is deleted and the process proceeds to S1; if the camera's field of view has not changed, the subsequent steps are continued, wherein the camera is installed on a fixed support structure for road monitoring.
[0033] Furthermore, identifying whether the camera's field of view changes based on vehicle target trajectory features includes:
[0034] Based on the target tracking algorithm results, obtain the number N of vehicles that were stably tracked in the previous frame, and the number P of vehicles that were lost in the current frame, where P does not include vehicles that have disappeared from the frame; calculate the loss ratio. ,when When, determine if the current camera's field of view has changed; when At that time, it is determined that the current camera field of view has not changed;
[0035] Alternatively, the number of vehicles within the road area and the number of vehicles detected across the entire image area can be counted. If more than half of the vehicles detected across the entire image area are not within the road area, it is determined that the camera's field of view has changed; otherwise, it is determined that the camera's field of view has not changed. Here, the road area is the union of the third area and all lane areas.
[0036] Furthermore, the camera will switch to S1 only if the field of view changes and then remains unchanged for a preset duration.
[0037] Further, in S4, the lane information includes lane tilt angle information, wherein the tilt angle information is the average of the first included angles of all lanes, and determining the driving direction of the lane specifically includes:
[0038] S4.1: Calculate the vehicle's lane based on the vehicle's location box and the lane's tilt angle information;
[0039] S4.2: Calculate the vehicle's driving direction based on the vehicle trajectory information;
[0040] S4.3: Calculate the third angle between the vehicle's direction of travel and the vertical reference direction;
[0041] S4.4: When the third included angle and the second included angle of more than half of the vehicles in the lane are both greater than 90° or both less than or equal to 90°, the initial direction of the lane is determined to be the driving direction of the lane; otherwise, the opposite direction of the initial direction is determined to be the driving direction of the lane.
[0042] Furthermore, in step S4, the lane information also includes an optimized lane area, and the specific steps for optimizing the lane area include:
[0043] Starting from the left side of a single frame image, find two adjacent lanes with opposite lane directions, and label them as the first lane and the second lane.
[0044] When the first angle between the first lane and the second lane is less than 90°, it is determined that the right lane line of the first lane is obscured.
[0045] Obtain the coordinate point sequence of the left and right lane lines of the left lane adjacent to the first lane;
[0046] Select matching point pairs in the left and right lane lines of the left lane, such that each pair of matching points and its corresponding third point satisfy the geometric relationship that the three points are collinear and the distance from the middle point to the two end points is equal. The first two points are from the left lane line and the right lane line of the left lane, respectively, and the third point is a point on the right lane line of the first lane to be generated.
[0047] The coordinates of the right lane line of the first lane are calculated based on the geometric relationship, and the calculated points are subjected to image boundary range constraint processing.
[0048] The shorter point sequence length between the left lane line and the right lane line of the left lane is selected as the point sequence length of the right lane line of the first lane after fitting, thus obtaining the complete fitted lane line.
[0049] The right lane line of the fitted first lane is connected to the left lane line of the first lane in sequence to form the corrected lane area.
[0050] When the first angle between the first lane and the second lane is greater than or equal to 90°, it is determined that the left lane line of the second lane is obscured.
[0051] Obtain the coordinate sequence of the left and right lane lines of the right lane adjacent to the second lane;
[0052] Select matching point pairs in the left and right lane lines of the right lane, such that each pair of matching points and its corresponding third point satisfy the geometric relationship that the three points are collinear and the distance from the middle point to the two end points are equal. The first two points come from the left lane line and the right lane line of the right lane, and the third point is a point on the left lane line of the second lane to be generated.
[0053] The coordinates of the left lane line of the second lane are calculated based on the geometric relationship, and the calculated points are subjected to image boundary range constraint processing.
[0054] The shorter point sequence length between the left and right lane lines of the right lane is selected as the point sequence length of the left lane line of the second lane after fitting, thus obtaining the complete fitted lane line.
[0055] The left lane line of the fitted second lane is connected to the right lane line of the second lane in sequence to form the corrected lane area.
[0056] Furthermore, in step S3, the method for obtaining the vehicle detection result includes:
[0057] The system continuously reads subsequent frames of the high-speed video stream, merges the first, second, and third regions, inputs the merged three regions in parallel into the target detection model, and fuses the target detection results of the three regions to obtain the vehicle detection result.
[0058] Compared with the prior art, the beneficial effects of the present invention are:
[0059] This invention analyzes the relative positional changes of the vehicle's trajectory and the identified lane information in real time to accurately and efficiently determine whether the camera's field of view has changed. It triggers a single lane line analysis only after the field of view changes and remains unchanged for a period of time. Based on the lane line results, it completes lane information identification and updating, significantly reducing the computational overhead of invalid lane analysis. Ultimately, this reduces the computational cost of detecting wrong-way driving in high-speed scenarios and improves detection efficiency.
[0060] This invention dynamically generates multiple hierarchical target detection regions (e.g., first region, second region, and third region) based on real-time lane information, inputs them in parallel into the target detection model for inference, and fuses the detection results of different levels, significantly improving the detection rate of small-sized vehicles; at the same time, it focuses on the lane area and reduces non-lane background interference, thereby reducing the false alarm rate of vehicles.
[0061] This invention automatically identifies occlusion by analyzing lane tilt angles, automatically optimizes lane lines with occlusion, compensates for lane information deviation caused by occlusion, ensures the accuracy of lane information, and reduces the risk of false alarms due to inaccurate lane position determination. Attached Figure Description
[0062] To more clearly illustrate the technical method of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only one embodiment of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0063] Figure 1 This is a flowchart of a vehicle reverse driving detection method for highways in an embodiment of the present invention;
[0064] Figure 2 These are schematic diagrams of the first, second, and third regions according to an embodiment of the present invention;
[0065] Figure 3 This is a diagram illustrating the target detection effect of a multi-level detection area according to an embodiment of the present invention.
[0066] Figure 4A This is the lane information map when the lane lines are obscured in Scenario 1;
[0067] Figure 4B This is the lane information map after lane line optimization in scenario 1;
[0068] Figure 5A This is the lane information map when the lane lines are obscured in scenario 2;
[0069] Figure 5B This is the lane information map after lane line optimization in scenario 2. Detailed Implementation
[0070] The technical methods of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0071] The technical methods of this application will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0072] In recent years, deep learning technology based on computer vision has been gradually applied in the field of vehicle reverse driving detection in high-speed scenes. It mainly determines reverse driving by calculating the consistency between the vehicle's driving direction and the preset direction. This method has problems such as high dependence on manual labor, requiring manual labeling of lane areas and driving directions in advance, poor deployment flexibility, and difficulty in adapting to complex or changing road environments (such as changes in camera perspective). Existing solutions use lane segmentation models to analyze road information in real time and automatically update lane information by comparing road features between frames one by one. However, they have the following shortcomings: (1) Analyzing lane areas frame by frame incurs high computational overhead; (2) Vehicle target pixels account for a low proportion in high-speed scenes. Directly inputting the decoded data into the target detection model often results in many vehicles being missed, creating significant traffic safety hazards; (3) The camera installation angle may cause some lane lines to be obscured. Existing methods do not address this issue, resulting in inaccurate lane position recognition and false alarms in reverse driving detection.
[0073] This invention provides a method for detecting vehicles driving in the wrong direction on highways. First, a lane detection model is invoked to initialize lane information. Then, based on the lane detection results, multi-level lane target detection regions are adaptively generated as input to the target detection model to detect vehicle targets on the road. On one hand, lane direction is determined and lane regions are corrected based on road vehicle trajectory information. After determining all lane directions, a vehicle driving in the wrong direction event is judged. On the other hand, the camera's field of view is analyzed in real time based on vehicle trajectory information to detect changes in the camera's field of view. When a change in the camera's field of view is detected and then remains unchanged for a period of time, a lane detection, i.e., lane information initialization, is performed.
[0074] Figure 1 A flowchart of a vehicle wrong-way detection method for highways provided by an embodiment of the present invention is shown. Figure 1 As shown, the method includes the following steps:
[0075] S1: Read the initial data of a single frame from the high-speed video stream and initialize the lane.
[0076] During system initialization, the lane detection algorithm needs to be called once to initialize the lanes. A frame I of the high-speed video stream, with dimensions W×H, is read and input into the lane detection model to obtain the lane lines for the current image. Each lane line consists of a set of feature points arranged from near to far, denoted as: ,in: i Indicates the number counting from the left. i There are 3 lane lines, and the number of feature points for each lane line is denoted as len. i , N The number of lane lines, among which, i ≤ N , jRepresented as the first j There are 10 points. Connect the feature points of two adjacent lane lines sequentially to form a closed polygonal lane region, denoted as . ,in, c Indicates the number from the left c One lane, of which c ≤ N -1, the initial direction of lane c: ,in:
[0077] ,
[0078] ,
[0079] ,
[0080] .
[0081] S2: Adaptively generate the first region, the second region, and the third region.
[0082] In vehicle detection, the focus is typically only on the movement of vehicles within the lane, while other areas, such as parking lots and plazas, are not analyzed. By selecting effective lane areas for target detection, interference from other areas can be eliminated, and the image input size can be increased without increasing computational load, thus improving the detection rate of small vehicles. Simultaneously, focusing on the lane area reduces interference from non-lane backgrounds, thereby lowering the false alarm rate.
[0083] Generate the first region R 1. Based on the lane information obtained from S1, find the smallest bounding rectangle that includes all lane lines; this is the first region. R 1.
[0084] Generate a second region R 2 and the third area R 3. To further improve the detection rate of small targets, a second region is generated based on the tilt of the lane lines in the image. R 2. Specifically includes:
[0085] Establish a coordinate system with the top-left corner of the image as the origin, the X-axis pointing horizontally to the right, and the Y-axis pointing vertically downwards, and set the horizontal reference direction. and vertical reference direction Calculate separately and the initial direction of all lanes The included angle Calculate separately and included angle ;
[0086] analyze and Relationship with 90°:
[0087] if and ,Pick R 1 / 4 of the rectangular area at the top left corner of 1 is used as R 2. Take R 1 / 4 of the rectangular area at the top left corner of 2 is used as R 3;
[0088] if and ,Pick R 1 / 4 of the rectangular area in the upper right corner of 1 is used as R 2. Take R 1 / 4 of the rectangular area in the upper right corner of 2 is used as R 3;
[0089] In other cases, take R 1 / 4 of the rectangular area directly above 1 is used as R 2. Take R 1 / 4 of the rectangular area directly above 2 is used as R 3.
[0090] Figure 2 It shows when and At that time, the first, second, and third areas generate renderings. R The area defined by the white solid line is 1. R The area of 2 is defined by a larger black solid line frame. R The area of 3 is defined by a smaller black solid line box.
[0091] S3: Continuously read subsequent frame data from the high-speed video stream and input them into the target detection model and multi-target tracking algorithm to obtain vehicle trajectory information.
[0092] The first and second regions are input into the network in parallel for parallel inference, and the resulting vehicle detection sets are denoted as follows: and Since the second region is part of the first region, vehicle targets (3, 5, 6, 7) will be detected twice in the second region and cannot be directly input into the target tracking algorithm. Therefore, it is necessary to fuse the detection results from the two sets, such as... Figure 3 As shown, the detection result fusion process when the second target region is taken from the upper right 1 / 4 sub-region of the first region is as follows:
[0093] (1) Obtain the corner point of the second region that is inside the first region, connect the corner point with two adjacent corner points in the second region to form two sides, and shrink them towards the center point of the second region. R1 and R The maximum pixel size of the vehicle's bounding box at the intersection of two points is used to obtain the second detection contraction region, the extent of which is determined by... Figure 2 The area is demarcated by a white dashed line.
[0094] (2) Delete the vehicle target in A1 within the second detection shrinkage area (including the border line), denoted as ;
[0095] (3) Match the remaining targets in A2 that are located within the second detection contraction area (located within the border line of the second area and completely within the L-shaped area), namely targets 3, 4, and 5, with... The intersection and union (IoU) of the target values is calculated. If the IoU is greater than 0, it indicates that... If the target is already included in A2, delete the target from A2; otherwise, keep the target. Record the result of the deletion as the set of vehicle targets. ;
[0096] (4) Merging and The fused vehicle detection results are obtained as {1,2,3,4,5,6,7,8}.
[0097] The fused vehicle target is input into the target tracking algorithm, and the same target in consecutive frames is matched. After inputting multiple frames of images, the vehicle's driving trajectory can be formed, which includes the vehicle's position box and ID information at each time.
[0098] When the second target region is taken directly above the first region, the three sides of the second region, which is inside the first region, are shrunk towards the center point of the second region. The maximum pixel size of the vehicle's position box at the intersection of the first and second regions is then shrunk to obtain the second detection shrinkage region.
[0099] Optionally, in S3, the first, second, and third regions are input into the target detection model in parallel, and the fused vehicle detection result is obtained according to the fusion method described above. This further improves the detection rate of small target vehicles.
[0100] To address the issue of high computational overhead caused by comparing lane mask features across consecutive frames to identify changes in the camera's field of view, this invention analyzes the relative positional relationship between the vehicle's trajectory and known lane lines to accurately and efficiently determine whether the camera's field of view has changed. Lane line analysis is triggered only after a change in the camera's field of view has occurred and stabilized, significantly reducing the computational overhead of invalid lane analysis.
[0101] During the detection process, the camera's field of view may change due to zooming and camera shake. For example, if a pedestrian appears on the highway or a collision occurs, the camera will zoom in to examine details before returning to normal focus. The process of identifying whether the camera's field of view has changed based on vehicle target trajectory features includes: if a change in the camera's field of view is detected, the current lane information is deleted, and the process proceeds to step S1; if the camera's field of view has not changed, subsequent steps are continued. The camera can be installed on a highway gantry or on monitoring poles or pillars along the roadside, depending on actual needs.
[0102] When the camera's field of view changes, the lane's position in the image changes accordingly, and lane information needs to be updated promptly. When the camera's field of view remains unchanged, most vehicles will maintain stable tracking and will not suddenly disappear in the middle of the road. Using this phenomenon, we can statistically analyze vehicle tracking in the first region: Let N be the number of vehicles stably tracking in the previous frame, and P be the number of vehicles lost in the current frame. Here, P does not include vehicles that have disappeared from the frame. The loss ratio is... ,when When the camera's field of view changes, lane information is deleted. If the camera's field of view has not changed, then the output will be "Cannot be determined".
[0103] In practical operation, the camera's field of view may change slowly, making it impossible to detect such changes using the above method. Therefore, the following method is designed for collaborative judgment: The number of vehicles within the road area and the number of vehicles detected across the entire image are counted. If more than half of the vehicles detected across the entire image are not within the road area, it is determined that the camera's field of view has changed. Here, the lane area refers to the union of the polygonal regions of all lanes obtained in S1 and the third region obtained in S2. Since distant lane lines are often undetectable during actual lane detection, the final identified lane area may be small. Therefore, by taking the union of the polygonal regions of all lanes and the third region, information on all lane areas and small, distant vehicles within the lanes can be obtained to the greatest extent possible.
[0104] Lane initialization is performed only after the camera's field of view changes and then remains unchanged for Q seconds. Q can be set based on experience, preferably 1-5 seconds, or according to actual needs. In this embodiment, it is set to 2 seconds.
[0105] S4: Determine the driving direction of the lane based on vehicle trajectory information and lane information.
[0106] The specific process for determining the driving direction of a lane based on vehicle trajectory information is as follows:
[0107] (1) Determine the lane number of the vehicle: Due to the camera installation angle, the lane lines often have a certain angle, which makes it difficult to select the vehicle rectangle if the conventional method is used. The center point of the bottom edge, i.e. The lane in which the vehicle is located will cause a certain deviation. This embodiment of the invention redefines the vehicle's location by adding the offset caused by the camera's tilt to the midpoint of the vehicle's bottom edge.
[0108] ,
[0109] in, This is the average of the inclination angles of all lanes.
[0110] (2) Determine the driving direction of the lane: Obtain the vehicle's trajectory information ,in, Let be the vehicle ID location bounding box information at time n. The following explanation will use lane c as an example: the initial direction of the lane is... Continuously count the driving directions of M vehicles within lane c, and define the driving direction of the vehicles as: = Calculate the S2 definition and The included angle ω id When more than half of the vehicles in the lane have ω id The results calculated in S2 When the magnitudes of all directions are consistent with 90° (i.e., all directions are greater than 90° or less than or equal to 90°), the initial direction of the lane is the driving direction of the lane. Otherwise, the opposite direction of the initial direction of the lane is the driving direction of the lane, that is... Repeat steps S3-S4 until the driving direction determination for all lanes is completed.
[0111] To address the issue that the camera installation angle may cause some lane lines to be obscured, this embodiment of the invention optimizes the lane area. Based on lane information and prior knowledge, the specific process of lane area optimization will be described in detail below.
[0112] Generally, on highways, the oncoming and outgoing lanes are separated by flower beds. Due to camera position and angle, one side of the lane lines may be obscured by the flower beds, making that lane area appear larger and thus affecting vehicle position judgment. This invention fits the lane lines obscured by flower beds based on the lane's tilt angle. Starting from the left side of the image, two adjacent lanes with opposite directions are found. and The initial direction of the lane is The included angles are denoted as follows: and :
[0113] if ,judge The lane is relatively wide, requiring fitting of the lane line that is obscured on the right side. In this scenario, the camera is mounted on the monitoring pole on the far left side of the lane (not shown in the figure). The fitting process is as follows: Obtain the... m -1 lane line and the m lane lines For each pair of matching points on the lane line, the following relationship is satisfied: AB=BC, and points A, B, and C are collinear, where A is L. m-1 Point B is L m Point C is the point to be generated. Points on the right lane line are calculated using a geometric transformation function.
[0114] ,
[0115] Finally, image boundary constraints are applied to the calculated points. All matching points are processed to obtain the fitted lane line, denoted as... ,in , will L m and The points on the track are connected in sequence to obtain the corrected lane area. Figure 4A This shows a lane information map when the lane lines are obscured in this scenario. Figure 4B The image shows the optimized lane information map for this scenario. As can be seen from the image, the lane lines that were obscured by the flower bed have been re-identified.
[0116] if Then judge The lane is relatively wide, requiring fitting of the lane line that is obscured on the left side. In this scenario, the camera is mounted on the monitoring pole on the far right side of the lane (not shown in the figure). The fitting process is as follows: Obtain the... m +2 lane lines L m+2 and the m +3 lane lines L m+3 For each pair of matching points on the lane line, the following relationship is satisfied: CA=AB, and points C, A, and B are collinear, where A is the L. m+2 Point B is L m+3 Point C is the point to be generated. Points on the left lane line are calculated using a geometric transformation function:
[0117] ,
[0118] Finally, image boundary constraints are applied to the calculated points. All matching points are processed to obtain the fitted lane line, denoted as... ,in ,Will and L m+2 The points on the track are connected in sequence to obtain the corrected lane area. Figure 5A This shows a lane information map when the lane lines are obscured in this scenario. Figure 5B The image shows the optimized lane information map for this scenario. As can be seen from the image, the lane lines that were obscured by the flower bed have been re-identified.
[0119] In other cases, if the camera is installed in the middle of the road and there is no possibility of flower beds obstructing the lane lines, no operation is required.
[0120] S5: Based on the current vehicle's trajectory information and the direction of travel in its lane, identify whether the current vehicle is driving in the wrong direction.
[0121] Obtain the current vehicle's trajectory information The method in S4 is used to identify the current lane of the vehicle and obtain the current driving direction of the vehicle. Calculate the direction of travel in the lane you are in. and respectively with The included angles α and β are used to determine whether the vehicle is traveling in the wrong direction. If α and β are not in a relationship with 90°, the vehicle is considered to be traveling in the wrong direction. Otherwise, the vehicle is not traveling in the wrong direction.
[0122] This invention provides a method for detecting changes in the camera's field of view in real time based on vehicle trajectory and lane information, rather than using specially extracted lane masks, thus avoiding the introduction of additional model calculations. It triggers a single lane analysis only after a change in the camera's field of view, avoiding continuous invalid lane calculations. Multiple hierarchical target detection regions are dynamically generated based on real-time lane information. These regions are grouped into detection batches and input into the target detection model in parallel for inference. By focusing on lane areas, background interference from non-lane areas can be effectively filtered out, significantly improving the detection rate of small vehicles. Obscured lane lines are identified and located based on lane tilt angles, and the obscured lane lines are reconstructed through model fitting, achieving accurate lane area identification and reducing false alarms of wrong-way driving events caused by inaccurate area positioning. This invention provides a vehicle wrong-way driving detection method with low human intervention, high real-time performance, and high accuracy, offering proactive control and timely early warning support for traffic management departments.
[0123] The above embodiments should be understood as being used only to illustrate the present invention more clearly, and not to limit the scope of the present invention. After reading the present invention, any modifications of the present invention in various equivalent forms by those skilled in the art fall within the scope defined by the appended claims.
Claims
1. A method for detecting vehicles driving in the wrong direction on highways, characterized in that, The method includes the following steps: S1: Read the initial data of a single frame of high-speed video stream, input the initial data into the lane line detection model to obtain lane lines, and generate initial lane information based on the lane lines, wherein the initial lane information includes lane area and initial direction of lane; S2: Based on the information of the lane area, adaptively generate the first area and the second area; S3: Continuously read subsequent frame data from the high-speed video stream, input the first region and the second region in parallel into the target detection model to obtain the vehicle detection result for each region; fuse the vehicle detection results and input the fused vehicle detection results into the multi-target tracking algorithm to obtain vehicle trajectory information; S4: Based on the vehicle trajectory information and lane information, determine the driving direction of the lane, and repeat S3-S4 until the driving direction of all lanes is determined. S5: Based on the current vehicle's trajectory information and the direction of travel in its lane, identify whether the current vehicle is driving in the wrong direction.
2. The method for detecting vehicles driving in the wrong direction on highways according to claim 1, characterized in that, In step S1, generating initial lane information based on the lane lines includes connecting the feature points of two adjacent lane lines in a preset order to form a closed polygonal lane region, and setting the initial direction of the lane based on the extension trend of the lane lines. The lane lines consist of a set of points arranged from near to far. Setting the initial direction of the lane specifically includes: S1.1: Calculate the coordinates of the midpoint of the left lane line and the coordinates of the point to the right of the midpoint, and use them as the first left coordinate and the second left coordinate; S1.2: Calculate the coordinates of the midpoint of the right lane line and the coordinates of the point to the right of the midpoint, and use them as the first right coordinate and the second right coordinate; S1.3: The midpoint between the left first coordinate point and the right first coordinate point is taken as the starting point of the initial direction of the lane, and the midpoint between the left second coordinate point and the right second coordinate point is taken as the ending point of the initial direction of the lane. The direction from the starting point to the ending point is the initial direction of the lane.
3. The method for detecting vehicles driving in the wrong direction on highways according to claim 1, characterized in that, In step S3, the vehicle trajectory information includes the vehicle's location bounding box and ID information at each time point. The fusion of the vehicle detection results includes the following steps: S3.1: Integrate the detection results of the first region into a first set and the detection results of the second region into a second set; S3.2: Perform boundary shrinkage on the second region to obtain the second detection shrinkage region. The remaining region within the second region is the second detection boundary region. The targets in the second set that are located within the second detection boundary region constitute the second boundary set. S3.3: Delete targets in the first set that are within the second detection shrinkage region, including deleting targets on the border line of the second detection shrinkage region, to obtain the first shrinkage set; S3.4: Traverse each target in the second boundary set, calculate the intersection-union ratio (IUR) of each target with the target box of the first shrinking set, and if the IUR is greater than 0, remove the corresponding target from the second set; otherwise, retain the corresponding target to obtain the second shrinking set. S3.5: Take the union of the first contracted set and the second contracted set to obtain the fused vehicle detection result.
4. The method for detecting vehicles driving in the wrong direction on highways according to claim 3, characterized in that, It also includes an adaptively generated third region; the specific process of adaptively generating multiple regions includes: Calculate the smallest bounding rectangle containing all lane lines, and use it as the first region; Set a horizontal reference direction and a vertical reference direction, calculate the first angle between the initial direction of the lane and the horizontal reference direction, and the second angle between the initial direction of the lane and the vertical reference direction, and compare the first angle with 90° to determine the lane line inclination direction, specifically including: When the first included angle of the leftmost and rightmost lanes is greater than 90°, select the upper left 1 / 4 sub-region of the first region as the second region, and select the upper left 1 / 4 sub-region of the second region as the third region. When the first included angle of the leftmost and rightmost lanes is less than or equal to 90°, select the upper right 1 / 4 sub-region of the first region as the second region, and select the upper right 1 / 4 sub-region of the second region as the third region. In other cases, the 1 / 4 sub-region directly above the first region is selected as the second region, and the 1 / 4 sub-region directly above the second region is selected as the third region. Furthermore, boundary shrinking of the second region includes: when the second target region is taken from the upper left 1 / 4 sub-region or the upper right 1 / 4 sub-region of the first region: Obtain the corner points of the second region that are inside the first region, connect the corner points with two adjacent corner points in the second region to form two sides, and shrink the maximum pixel size of the vehicle's position box across the boundary between the first and second regions towards the center point of the second region to obtain the second detection shrinkage region; When the second target area is taken directly above the first area: The maximum pixel size of the vehicle's location box at the intersection of the first and second regions is shrunk by moving the three edges of the second region, which are located inside the first region, toward the center point of the second region, to obtain the second detection shrinkage region.
5. The method for detecting vehicles driving in the wrong direction on highways according to claim 4, characterized in that, In S3, the method also includes simultaneously identifying whether the camera's field of view has changed based on the vehicle target trajectory features: if a change in the camera's field of view is detected, the current lane information is deleted and the process proceeds to S1; if the camera's field of view has not changed, the subsequent steps are continued, wherein the camera is mounted on a fixed support structure for road monitoring.
6. The method for detecting vehicles driving in the wrong direction on highways according to claim 5, characterized in that, Whether the camera's field of view changes based on vehicle target trajectory features includes: Based on the target tracking algorithm results, obtain the number N of vehicles that were stably tracked in the previous frame, and the number P of vehicles that were lost in the current frame, where P does not include vehicles that have disappeared from the frame; calculate the loss ratio. ,when When, determine if the current camera's field of view has changed; when At that time, it is determined that the current camera field of view has not changed; Alternatively, the number of vehicles within the road area and the number of vehicles detected across the entire image area can be counted. If more than half of the vehicles detected across the entire image area are not within the road area, it is determined that the camera's field of view has changed; otherwise, it is determined that the camera's field of view has not changed. Here, the road area is the union of the third area and all lane areas.
7. The method for detecting vehicles driving in the wrong direction on highways according to claim 6, characterized in that, Switch to S1 only when the camera's field of view changes and then remains unchanged for a preset duration.
8. The method for detecting vehicles driving in the wrong direction on highways according to claim 4, characterized in that, In step S4, the lane information includes lane tilt angle information, wherein the tilt angle information is the average of the first included angles of all lanes, and determining the driving direction of the lane specifically includes: S4.1: Calculate the vehicle's lane based on the vehicle's location box and the lane's tilt angle information; S4.2: Calculate the vehicle's driving direction based on the vehicle trajectory information; S4.3: Calculate the third angle between the vehicle's direction of travel and the vertical reference direction; S4.4: When the third included angle and the second included angle of more than half of the vehicles in the lane are both greater than 90° or both less than or equal to 90°, the initial direction of the lane is determined to be the driving direction of the lane; otherwise, the opposite direction of the initial direction is determined to be the driving direction of the lane.
9. The method for detecting vehicles driving in the wrong direction on highways according to claim 8, characterized in that, In step S4, the lane information further includes an optimized lane area, and the specific steps for optimizing the lane area include: Starting from the left side of a single frame image, find two adjacent lanes with opposite lane directions, and label them as the first lane and the second lane. When the first angle between the first lane and the second lane is less than 90°, it is determined that the right lane line of the first lane is obscured. Obtain the coordinate point sequence of the left and right lane lines of the left lane adjacent to the first lane; Select matching point pairs in the left and right lane lines of the left lane, such that each pair of matching points and its corresponding third point satisfy the geometric relationship that the three points are collinear and the distance from the middle point to the two end points is equal. The first two points are from the left lane line and the right lane line of the left lane, respectively, and the third point is a point on the right lane line of the first lane to be generated. The coordinates of the right lane line of the first lane are calculated based on the geometric relationship, and the calculated points are subjected to image boundary range constraint processing. The shorter point sequence length between the left lane line and the right lane line of the left lane is selected as the point sequence length of the right lane line of the first lane after fitting, thus obtaining the complete fitted lane line. The right lane line of the fitted first lane is connected to the left lane line of the first lane in sequence to form the corrected lane area. When the first angle between the first lane and the second lane is greater than or equal to 90°, it is determined that the left lane line of the second lane is obscured. Obtain the coordinate sequence of the left and right lane lines of the right lane adjacent to the second lane; Select matching point pairs in the left and right lane lines of the right lane, such that each pair of matching points and its corresponding third point satisfy the geometric relationship that the three points are collinear and the distance from the middle point to the two end points are equal. The first two points come from the left lane line and the right lane line of the right lane, and the third point is a point on the left lane line of the second lane to be generated. The coordinates of the left lane line of the second lane are calculated based on the geometric relationship, and the calculated points are subjected to image boundary range constraint processing. The shorter point sequence length between the left and right lane lines of the right lane is selected as the point sequence length of the left lane line of the second lane after fitting, thus obtaining the complete fitted lane line. The left lane line of the fitted second lane is connected to the right lane line of the second lane in sequence to form the corrected lane area.
10. The method for detecting vehicles driving in the wrong direction on highways according to claim 4, characterized in that, In step S3, the method for obtaining the vehicle detection result includes: The system continuously reads subsequent frames of the high-speed video stream, merges the first, second, and third regions, inputs the merged three regions in parallel into the target detection model, and fuses the target detection results of the three regions to obtain the vehicle detection result.
Citation Information
Patent Citations
Vehicle retrograde driving event detection method based on dome camera
CN116363859A
Method for detecting full line of lane based on optical flow point locus statistics
CN105005771A
Expressway vehicle lane changing area analysis method based on deep learning
CN111598069A
Multi-lane traffic flow detection method for complex monitoring scene
CN113516853A
Road vehicle tracking method and system based on attention mechanism and multi-target tracking
CN114627447A