Vehicle reverse driving detection method, device and medium suitable for ball camera changing view angle

By establishing a Cartesian coordinate system and a multi-target tracking algorithm on the PTZ camera, and adaptively adjusting lane division, the problem of misjudging vehicles driving in the wrong direction caused by changes in the PTZ camera's viewing angle was solved, achieving accurate and real-time detection of vehicles driving in the wrong direction on highways.

CN117789489BActive Publication Date: 2026-06-19NANJING UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING UNIV
Filing Date
2023-12-20
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In existing technologies, the fixed camera's single shooting angle makes vehicle reverse driving detection inflexible, the manual lane marking fails when the PTZ camera's angle changes, and the existing algorithms are slow and difficult to adapt to highway scenarios.

Method used

By constructing a multi-target tracking algorithm, establishing a Cartesian coordinate system, recording the vehicle's driving direction and the coordinates of the detection box, calculating the lane slope and projection line equation, and adaptively adjusting lane division, it is suitable for PTZ cameras with varying viewing angles and reduces system resource overhead.

Benefits of technology

It enables accurate and real-time detection of vehicles driving in the wrong direction even when the PTZ camera's viewing angle changes, avoiding the shortcomings of manual line marking. It is suitable for multi-channel video processing and saves manpower and system resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117789489B_ABST
    Figure CN117789489B_ABST
Patent Text Reader

Abstract

This invention discloses a method, equipment, and medium for detecting vehicles traveling in the wrong direction using a PTZ camera with varying viewing angles. A tracking area is set in the image captured by the PTZ camera. The direction of travel of the tracked vehicles and the coordinates of each vehicle's detection frame are recorded. The maximum horizontal coordinate of the uphill lane and the minimum horizontal coordinate of the downhill lane are calculated. The lane slope is calculated based on the vehicle's trajectory, and the projection line equation is calculated using the lane slope. Whether a vehicle is traveling in the wrong direction is determined by comprehensively considering the distance between the vehicle's direction of travel, the center coordinates of the detection frame, and the maximum / minimum coordinates of the two lanes on the projection line. When the PTZ camera's viewing angle changes, the lane slope and projection line equation are automatically updated based on the vehicle's trajectory. This invention eliminates the need for manual intervention and repeated lane area delineation, avoids the additional road surface detection algorithm that increases system overhead, and solves the problem of a single shooting angle, balancing the flexibility of the shooting angle with the real-time performance of the algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent transportation and image processing technology, and relates to a multi-target tracking algorithm based on convolutional neural networks and the judgment of driving attributes in road areas. It provides a method, equipment and medium for vehicle reverse driving detection suitable for PTZ cameras with changing viewing angles. Background Technology

[0002] Existing technologies offer several methods for detecting vehicles traveling in the wrong direction. Some methods rely on fixed cameras and deep learning-based approaches to detect vehicles and their direction of travel, comparing this information with a pre-defined correct direction to determine if a wrong-way travel event has occurred. However, these methods suffer from inflexible shooting angles and require manual definition of lane markings for both directions. Other methods use PTZ cameras, combining multi-object tracking and road surface area extraction algorithms to comprehensively assess vehicle travel. However, these methods suffer from high system overhead and slow algorithm execution. Still other methods utilize other landmarks, such as arrows and traffic markings, to assist in determining road surface attributes and then classifying the vehicle as traveling in the wrong direction. However, highway scenarios are often limited by the availability of such landmarks. Therefore, a fast and effective method for detecting vehicles traveling in the wrong direction, suitable for highway environments, is needed. Summary of the Invention

[0003] The problem this invention aims to solve is that while existing fixed road cameras can manually divide two-way lanes in advance and determine whether vehicles in each lane are driving in the wrong direction, they suffer from a single shooting angle, failing to meet road monitoring needs. PTZ cameras, with their flexible shooting angles, can render the method of manually dividing two-way lanes ineffective due to changes in shooting direction, leading to misjudgments of vehicle wrong-way detection. Using road surface extraction algorithms, such as YOLACT and Mask-RCNN, places higher demands on the overall system performance, reduces algorithm speed, and is unsuitable for processing multiple video streams simultaneously; furthermore, the uniformity of highway scenes makes it difficult to use landmarks to assist in judgment. Therefore, a better vehicle wrong-way detection method is needed, balancing accuracy and real-time performance.

[0004] The technical solution of this invention is: a vehicle reverse driving detection method applicable to PTZ camera with changing viewing angle, comprising the following steps:

[0005] Step 1: Construct a highway vehicle video dataset and obtain the network weights for the multi-target tracking algorithm through training;

[0006] Step 2: Use OpenCV to read the RTMP address of the PTZ camera to obtain the real-time video stream of the two-way lane;

[0007] Step 3: For the video frames in the acquired video stream, establish a rectangular coordinate system with the top left corner of the screen as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis. The maximum value of the x-axis is w, and the maximum value of the y-axis is h.

[0008] Step 4: Initialize parameters. Initialize the slope k of the two-way lane to 0. Assume that the maximum horizontal coordinate of the upward vehicle detection box in vehicle tracking is x. upmax The minimum horizontal coordinate of the downlink vehicle detection box is x. downmin The coordinates (x, y) of the extreme point (x, y) where the x-coordinate of the uphill lane area is maximum are obtained. upmax ,y up ), and the coordinates of the extreme point (x) where the x-coordinate of the downhill lane area is minimized. downmin ,y down ), y up y down They correspond to x respectively upmax x downmin The median of the ordinate of the detection box, (x upmax ,y up ) and (x downmin ,y down Initialize them to (0, 0) and (w, 0) respectively;

[0009] Step 5: Use a multi-object tracking algorithm to track vehicles in the video stream, obtain the ID, driving direction information, and detection box position coordinates of each vehicle, and calculate the coordinates of the uplink extreme point (x). upmax ,y up ) and the coordinates of the downtrend extreme point (x downmin ,y down The system calculates the average offset of the horizontal coordinate of the vehicle detection box during driving, and sets a threshold. If the average offset is less than or equal to the threshold, the lane slope direction is consistent with the camera's shooting angle, and proceeds to Step 6; otherwise, the angles are inconsistent, and proceeds to Step 7.

[0010] Step 6: Initialize parameters. Initialize the slope k of the two-way lanes to 0. Based on the driving direction of each vehicle and the x-coordinate of the center position of each vehicle's detection frame, periodically calculate the x-coordinate of the center position of each vehicle's detection frame and the x-coordinate of the extreme points of the up and down lanes. upmax x downmin absolute value of distance If a certain upward vehicle Less than Or a certain vehicle going downhill Less than If the vehicle is driving against traffic, it is considered to be driving normally;

[0011] Step 7: Based on the driving direction of each vehicle and the x-coordinate of the center position of each vehicle's detection frame obtained in Step 5, calculate the slope of the two-way lane, the slope of the projection line, the coordinates of the intersection point of the vehicle detection frame's center position coordinates on the projection line, and the coordinates of the intersection point of the extreme points of the up and down lanes on the projection line (x-coordinate). upmaxref ,y ref ), (x downminref ,y ref The system uses the absolute value of the distance between the intersection of the vehicle detection frame center coordinates on the projection line and the intersection of the coordinates of the extreme points of the up and down lanes on the projection line to comprehensively determine whether the vehicle is driving in the wrong direction.

[0012] Step 8: Compare the two-way lane slope k obtained in Step 6 or the two-way lane slope k calculated in Step 7 with the previously recorded two-way lane slope k. If the absolute value of the change is greater than the preset slope threshold, it indicates that the PTZ camera's shooting angle has changed. Then, jump to Step 4, re-initialize the parameters, and then determine whether the vehicle is driving in the wrong direction according to Steps 5-7.

[0013] The present invention also provides an electronic device, which includes a processor and a memory. The memory stores at least one instruction or at least one program, which is loaded and executed by the processor to realize the above-described vehicle reverse driving detection method applicable to PTZ camera changing viewing angle.

[0014] The present invention also provides a computer-readable storage medium storing at least one instruction or at least one program, wherein when the at least one instruction or at least one program is executed, the above-described vehicle reverse driving detection method applicable to PTZ camera changing viewing angle is implemented.

[0015] This invention sets a tracking area in the image captured by the PTZ camera and establishes a Cartesian coordinate system to record the direction of travel of the tracked vehicles and the coordinate values ​​of the detection boxes for each vehicle. Based on the coordinate values ​​of the vehicle detection boxes, the maximum abscissa value of the points in the uphill lane area and the minimum abscissa value of the points in the downhill lane area are statistically obtained. At the same time, the slope of the uphill and downhill lanes is calculated based on the travel trajectory of each vehicle. The projection line equation is calculated using the slope of the uphill and downhill lanes. The center coordinates of each vehicle detection box and the extreme coordinates of the uphill and downhill lane areas are projected onto the projection line. The distance between the travel direction and center coordinates of each vehicle and the extreme coordinates of the two lanes on the projection line is used to comprehensively determine whether the vehicle is traveling in the wrong direction. When the PTZ camera's shooting angle changes, the lane slope and projection line equation can be automatically updated according to the vehicle's travel trajectory. There is no need for manual intervention and repeated lane area delineation, and no need to use additional road surface detection algorithms to increase system overhead. At the same time, it solves the problem of a single shooting angle, and balances the flexibility of the shooting angle and the real-time operation of the algorithm.

[0016] Compared with the prior art, the present invention has the following advantages:

[0017] (1) It is suitable for PTZ cameras with flexible shooting angles, solving the problem of fixed cameras having a single shooting angle, and can also adapt to the changing angles of PTZ cameras.

[0018] (2) It overcomes the shortcomings of manual lane marking and lane driving attributes, and can adaptively divide and determine lane driving attributes according to changes in the shooting angle of the PTZ camera, saving manpower.

[0019] (3) The entire algorithm module does not require cascading other segmentation algorithms, saving system resources and is suitable for processing multiple video streams. Attached Figure Description

[0020] Figure 1 This is a flowchart of the vehicle reverse driving detection method applicable to the changing viewing angle of a PTZ camera according to the present invention.

[0021] Figure 2 This is a planar schematic diagram of the reverse detection logic of the present invention.

[0022] Figure 3 This is a diagram illustrating the effect of the invention in detecting vehicles driving in the wrong direction on a highway.

[0023] Figure 4 To maintain the coordinates of the downlink extreme point (x) in this invention downmin ,y down The image shows the effect of vehicle reverse driving detection in a highway scenario when (w, 0) is fixed. Detailed Implementation

[0024] This invention proposes a vehicle reverse driving detection method suitable for PTZ cameras with varying viewing angles. It adaptively divides the driving attributes of two-way lanes based on the vehicle's trajectory, and determines whether a vehicle is driving in the wrong direction by comprehensively judging the vehicle's driving direction and the lane it is in. This solves the problems of misjudgment of vehicle reverse driving caused by the single shooting angle of fixed cameras, the failure of manual division of two-way lanes when the shooting angle of PTZ cameras changes, etc., and can effectively detect vehicles driving in the wrong direction on highways.

[0025] This invention relates to deep learning and multi-target tracking methods, the overall steps of which are as follows: Figure 1 As shown, the specific implementation process is as follows:

[0026] Step 1: Construct a highway vehicle video dataset. Obtain videos taken by PTZ cameras on highways and segment the video frames. Create training, validation, and test sets. Train a convolutional neural network to obtain the network weights for the multi-target tracking algorithm.

[0027] Step 2: Use OpenCV to read the RTMP address of the PTZ camera to obtain the real-time video stream of the two-way lane.

[0028] Step 3: For the video frames in the acquired video stream, establish a rectangular coordinate system with the top left corner of the screen as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis. The maximum value of the x-axis is w, and the maximum value of the y-axis is h.

[0029] Step 4: Initialize parameters. Initialize the slope k of the two-way lane to 0. Assume that the maximum horizontal coordinate of the upward vehicle detection box in vehicle tracking is x. upmax The minimum horizontal coordinate of the downlink vehicle detection box is x. downmin The coordinates (x, y) of the extreme point (x, y) where the x-coordinate of the uphill lane area is maximum are obtained. upmax ,y up ), and the coordinates of the extreme point (x) where the x-coordinate of the downhill lane area is minimized. downmin ,y down ), y up y down They correspond to x respectively upmax x downmin The median of the ordinate of the detection box, (x upmax ,y up ) and (x downmin ,y down ) are initialized to (0, 0) and (w, 0) respectively.

[0030] Step 5: Use a multi-object tracking algorithm to track vehicles in the video stream, obtain the ID, driving direction information, and detection box position coordinates of each vehicle, and calculate the coordinates of the uplink extreme point (x). upmax ,y up ) and the coordinates of the downtrend extreme point (x downmin ,y down The system calculates the average offset of the horizontal coordinate of the vehicle detection box while the vehicle is in motion, and sets a preset threshold. The average offset is used to determine whether the lane matches the shooting viewpoint. The vehicle tracking algorithm includes, but is not limited to, deep learning methods such as SORT, DeepSORT, and FairMOT. The specific implementation is as follows.

[0031] Step 5.1: Based on a multi-target tracking algorithm, record the ID and bounding box coordinates of each vehicle every 1 second. And calculate the center position coordinates. The vehicle's direction of travel is determined by changes in the center position coordinates. If the ordinate of the center position coordinates gradually increases, the vehicle is moving downwards; if the ordinate gradually decreases, the vehicle is moving upwards. The number of upward-moving vehicles in progress is counted as n. up The number of vehicles going downhill is n down .

[0032] Step 5.2: Calculate the coordinates of the extreme points (x, y) every 1 second. upmax ,y up ) and the coordinates of the downtrend extreme point (x downmin ,y down The coordinates are calculated as follows:

[0033]

[0034]

[0035] Let y represent the upward and downward extrema of the previous time step, respectively. up y down They correspond to x respectively upmax x downmin The median of the ordinate of the detection box is used to update the maximum x-coordinate of the upward vehicle detection box in the statistics. upmax y is calculated based on the detection box corresponding to the latest maximum x-coordinate value. up x upmax Pick At that time, y up The calculation uses the ordinate of the detection box at time t, i.e. If the x-axis is still larger in the statistics, i.e., x upmax Values Then y up The calculation uses the ordinate of the detection box at time t-1, i.e. Similarly, according to x downmin The median y-axis of the corresponding detection box is calculated. down .

[0036] Step 5.3: Calculate the offset of the horizontal coordinate of the vehicles in motion every 1 second, and sum and average the offsets of all vehicles to obtain the average offset Δx.

[0037]

[0038] Step 5.4: Determine the value of Δx and the set threshold. If it is less than or equal to the threshold, the road direction is considered to be consistent with the PTZ camera's viewing angle, and there is no angle between them. Proceed to Step 6; otherwise, proceed to Step 7. In this embodiment, the threshold is set to 10 to determine whether there is an angle between the road direction and the PTZ camera's shooting direction.

[0039] This invention finds the maximum value of the horizontal coordinate of the uphill lane area and the minimum value of the horizontal coordinate of the downhill lane area by gradually determining the coordinate changes of uphill and downhill vehicles. For example, x upmax This is obtained by comparing the x-coordinate of the detection box for each uphill vehicle and taking the maximum value. (For reference...) Figure 2 x upmax At this time x upmax By continuously comparing and determining the x-coordinate of the vehicle detection box in the diagram, and by taking the maximum value of the x-coordinate each time, the maximum x-coordinate of the upward lane area can eventually be obtained through repeated comparisons. upmax The same applies to the downhill lane. Therefore, after a period of time, if the PTZ camera's viewing angle does not change, x upmax This will not change further, and the maximum horizontal coordinate of the uphill lane area will eventually be obtained. In this invention, there is no distinction between uphill and downhill lanes. The goal is to find the maximum value of the horizontal coordinates of the two lanes from beginning to end. By tracking each vehicle, the "boundary" of the two lanes is gradually found. Then, by comparing the distance between the center coordinate of each vehicle and these two horizontal coordinates, and combining the vehicle's driving direction, it is determined whether the vehicle is driving in the wrong direction.

[0040] For a two-way road, from the PTZ camera's perspective, the up-traffic lane is always to the right of the down-traffic lane. Initialize x... upmax x is 0 downmin For w, since the origin is the top left corner, all x upmax The maximum value will be gradually obtained through repeated comparisons, x downmin The minimum value will be gradually obtained through repeated comparisons, and Step 5.2 embodies this comparison process.

[0041] Step 6: Initialize parameters. Initialize the slope k of the two-way lanes to 0. Based on the driving direction of each vehicle and the x-coordinate of the center position of each vehicle's detection frame obtained in Step 5.1, calculate the x-coordinate of the center position of each vehicle's detection frame and the x-coordinate of the extreme point coordinates of the up and down lanes every 1 second. upmax x downmin absolute value of distance If a certain upward vehicle Less than Or a certain vehicle going downhill Less than If the vehicle is driving against traffic, it is considered to be driving normally; otherwise, it is considered to be driving in the wrong direction.

[0042] Step 7: Based on the driving direction of each vehicle and the x-coordinate of the center position of each vehicle's detection frame obtained in Step 5.1, simultaneously calculate the slope of the two-way lane, the slope of the projection line, the coordinates of the intersection point of the vehicle detection frame's center position coordinates on the projection line, and the coordinates of the intersection point of the extreme points of the up and down lanes on the projection line (x-coordinate). upmaxref ,y ref ), (x downminref ,y refThe system determines whether a vehicle is traveling in the wrong direction by comprehensively considering the absolute value of the distance between the intersection of the vehicle detection frame's center position coordinates on the projection line and the intersection of the coordinates of the extreme points of the up and down lanes on the projection line.

[0043] Step 7.1: Obtain the center coordinates of the detection box for each vehicle every 1 second. Every 5 seconds, the trajectory of each vehicle is fitted using the least squares method, and the slope k of each vehicle's trajectory is calculated based on the fitting results. id Finally, the average of the slopes fitted to the driving trajectories of each vehicle is summed to obtain the slope k of the two-way lane. If no vehicle passes through the video frame within 5 seconds, Step 5 is executed again until the slope k of each vehicle's driving trajectory is obtained. id and the slope k of the two-way lane:

[0044]

[0045]

[0046] This represents the average x-coordinate of the center position of the detection frame for each vehicle within 5 seconds. n represents the average ordinate of the center position of the detection frame for each vehicle within 5 seconds. up n represents the number of vehicles traveling in the uphill direction. down This indicates the number of vehicles traveling in the opposite direction.

[0047] Step 7.2: Calculate the trajectory equation formed by each vehicle's movement, and let the intercept of the projection line on the y-axis be... And it is perpendicular to the road, meaning the slope of the projected line is... And calculate the equation of the projection line:

[0048]

[0049]

[0050] y ref In the formula, x represents the independent variable of the projection line equation, based on the coordinates (0, h / 2) and the slope. Once a unique projection line equation is determined, the two equations from Step 7.2 can be used to finally solve for x, thus obtaining the coordinates of the intersection point between the trajectory of each vehicle and the projection line.

[0051] Step 7.3: Calculate the x-coordinate of the intersection point of the driving trajectory and the projection line for each vehicle using the two formulas in Step 7.2.

[0052] Step 7.4: Based on the coordinates of the upward extreme point (x) in Step 5.2 upmax ,y up) and the coordinates of the downtrend extreme point (x downmin ,y down Using the lane slope k from Step 7.1 and the projection line equation from Step 7.2, the x-coordinate of the intersection point of the extreme points on the projection line for both the up and down directions is calculated. upmaxref x downminref .

[0053] Step 7.5: Based on the driving direction of each vehicle obtained in Step 5.1, compare the x-coordinate from Step 7.3 every 1 second. x obtained in Step 7.4 upmaxref x downminref The absolute value of the distance on the projection line If a certain upward vehicle Less than Or a certain vehicle going downhill Less than If the vehicle is driving against traffic, it is considered to be driving normally;

[0054]

[0055]

[0056] Step 8: Compare the two-way lane slope k obtained in Step 6 or the two-way lane slope k calculated in Step 7 with the previously recorded two-way lane slope k. If the absolute value of the change is greater than the preset slope threshold, it indicates that the PTZ camera's shooting angle has changed. Then, jump to Step 4, re-initialize the parameters, and then determine whether the vehicle is driving in the wrong direction according to Steps 5-7.

[0057] In this embodiment, every 1 second, it is determined whether the vehicle is traveling in the wrong direction, and then the lane slope is compared. A variable is used to store the slope obtained each time, so as to facilitate comparison with the slope at the next moment. When comparing the slope each time, the lane slope at this moment is 0 when there is no angle of view. When there is an angle, the slope is k calculated in Step 7. The slope recorded last time is obtained according to the previous Step 6 or Step 7. The absolute value of the difference between the current slope value and the previous slope value is greater than 0.5, which means that the PTZ camera has rotated.

[0058] This invention can be implemented based on a computer program. Based on this, the invention also provides an electronic device comprising a processor and a memory. The memory stores at least one instruction or at least one program segment, which is loaded and executed by the processor to implement the aforementioned vehicle reverse-driving detection method applicable to PTZ camera changing viewing angles. A computer-readable storage medium is also provided, storing at least one instruction or at least one program segment. When the at least one instruction or at least one program segment is executed, it implements the aforementioned vehicle reverse-driving detection method applicable to PTZ camera changing viewing angles.

[0059] Figure 3 and Figure 4 This is an experimental result diagram of the reverse-driving detection of the present invention. Due to the lack of video verification of reverse-driving vehicles, the verification of the present invention was conducted in... Figure 3 Adjustments were made based on this, such as... Figure 4 As shown, in Figure 4 Fixed downward extreme value (x) downmin ,y down The coordinates remain unchanged from (w, 0) in step 4 initialization, so that in Figure 4 In the middle, according to the calculation in Step 7, the distance between the intersection of the truck's center point and the intersection of the two lanes' maximum and minimum points on the projection line is... Less than It can be determined that the vehicle is located in the uphill lane area, but the truck is going downhill. Therefore, the truck is determined to be going in the wrong direction, and the detection box is marked as going in the wrong direction.

Claims

1. A method for detecting vehicle reverse movement suitable for ball camera changing view angle, characterized in that Includes the following steps: Step 1: Construct a highway vehicle video dataset and obtain the network weights for the multi-target tracking algorithm through training; Step 2: Use OpenCV to read the RTMP address of the PTZ camera to obtain the real-time video stream of the two-way lane; Step 3: For the video frames in the acquired video stream, establish a rectangular coordinate system with the top left corner of the screen as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis. The maximum value of the x-axis is w, and the maximum value of the y-axis is h. Step4: initialize parameters, bidirectional lane slope Initialize to 0, set in vehicle tracking, the maximum value of the horizontal coordinate of the uplink vehicle detection box is , the minimum value of the horizontal coordinate of the downlink vehicle detection box is , the maximum value point coordinate of the uplink lane region horizontal coordinate is obtained , and the minimum value point coordinate of the downlink lane region horizontal coordinate is obtained , , The vertical coordinate median of the detection box corresponding to , , respectively, and and are initialized to (0, 0) and (w, 0), respectively; Step 5: Use a multi-object tracking algorithm to track vehicles in the video stream, obtain the ID, driving direction information, and detection box position coordinates of each vehicle, and calculate the coordinates of the uplink extreme point. and the coordinates of the downtrend extreme point The average offset of the horizontal coordinate of the vehicle detection box during driving is calculated. A preset threshold is set. If the average offset is less than or equal to the threshold, the lane slope direction is consistent with the camera's shooting angle, and the process proceeds to Step 6. Otherwise, the perspective is inconsistent, and the process proceeds to Step 7. Step 6: Initialize parameters, two-way lane slope Initialize to 0. Based on the driving direction of each vehicle and the x-coordinate of the center position of each vehicle's detection frame, periodically calculate the x-coordinate of the center position of each vehicle's detection frame and the x-coordinate of the extreme points of the up and down lanes. , absolute value of distance , If a certain upward vehicle Less than Or a certain vehicle going downhill Less than If the vehicle is driving against traffic, it is considered to be driving in the wrong direction; otherwise, it is considered to be driving normally. Step 7: Based on the driving direction of each vehicle and the x-coordinate of the center position of each vehicle's detection frame obtained in Step 5, calculate the slope of the two-way lane, the slope of the projection line, the coordinates of the intersection point of the vehicle detection frame's center position coordinates on the projection line, and the coordinates of the intersection point of the extreme points of the up and down lanes on the projection line. , The absolute value of the distance between the intersection of the coordinates of the center position of the vehicle detection frame on the projection line and the intersection of the coordinates of the maximum and minimum points of the up and down lanes on the projection line is used to comprehensively determine whether the vehicle is traveling in the wrong direction. Step 8: Initialize the two-way lane slope obtained in Step 6. Or the two-way lane slope calculated in Step 7 Compared to the previously recorded two-way lane slope If the absolute value of the change is greater than the preset slope threshold, it indicates that the PTZ camera's shooting angle has changed. Then, jump to Step 4, re-initialize the parameters, and then determine whether the vehicle is driving in the wrong direction according to Steps 5-7.

2. The vehicle reverse driving detection method applicable to PTZ camera with varying viewing angles according to claim 1, characterized in that: In Step 1, the video captured by the PTZ camera on the highway is acquired and segmented into video frames. Training, validation and test sets are created, and network weights are obtained by training a convolutional neural network.

3. The vehicle reverse driving detection method applicable to PTZ camera with varying viewing angles according to claim 1, characterized in that: Step 5 specifically involves: Step 5.1: Based on a multi-target tracking algorithm, record the ID and bounding box coordinates of each vehicle every 1 second. And calculate the coordinate information of the center position of the detection box. The vehicle's direction of travel is determined based on changes in its center position coordinates. If the vertical coordinate of the center position gradually increases, the vehicle is moving downwards; if the vertical coordinate gradually decreases, the vehicle is moving upwards. The number of upward-moving vehicles is counted. The number of vehicles going downhill is ; Step 5.2: Update the coordinates of the upward extreme point every 1 second. and the coordinates of the downtrend extreme point The coordinates are calculated as follows: , , Let these represent the upward and downward extrema of the previous moment, respectively. , They are respectively the corresponding , The median of the vertical coordinate of the detection box; Step 5.3: Calculate the offset of the horizontal coordinate of the vehicles in motion every 1 second, and sum and average the offsets of all vehicles to obtain the average offset. : Step 5.4: Judgment The threshold value is set. If it is less than or equal to the threshold, it is assumed that the road slope direction is consistent with the PTZ camera's viewing angle and there is no angle. Then, proceed to Step 6. Otherwise, proceed to Step 7.

4. The vehicle reverse driving detection method applicable to PTZ camera with varying viewing angles according to claim 1, characterized in that: The multi-target tracking algorithms described in Step 5 include SORT, DeepSORT, and FairMOT.

5. The vehicle reverse driving detection method applicable to PTZ camera with varying viewing angles according to claim 1, characterized in that: Step 7 is as follows: Step 7.1: Obtain the center coordinates of the detection box for each vehicle every 1 second. Every 5 seconds, the trajectory of each vehicle is fitted using the least squares method, and the slope of each vehicle's trajectory is calculated based on the fitting results. Finally, the average of the slopes fitted to the driving trajectories of each vehicle is summed to obtain the slope of the two-way lane. If no vehicle passes through the video frame within 5 seconds, continue to Step 5 until the slope of each vehicle's trajectory is obtained. and the slope of the two-way lane : This represents the average x-coordinate of the center position of the detection frame for each vehicle within 5 seconds. This represents the average ordinate of the center position of the detection frame for each vehicle within 5 seconds. Indicates the number of vehicles traveling in the up direction. Indicates the number of vehicles traveling in the opposite direction; Step 7.2: Calculate the trajectory equation formed by each vehicle's movement, and let the intercept of the projection line on the y-axis be... And perpendicular to the road, meaning the slope of the projected line is... And calculate the equation of the projection line: ; Step 7.3: Calculate the x-coordinate of the intersection point of the driving trajectory and the projection line for each vehicle using the two formulas in Step 7.

2. ; Step 7.4: Based on the coordinates of the upward extreme point in Step 5 and the coordinates of the downtrend extreme point Using the lane slope in Step 7.1 The x-coordinate of the intersection point of the upper and lower extreme point coordinates on the projection line is obtained by calculating the projection line equations in Step 7.

2. , ; Step 7.5: Based on the direction of travel of each vehicle, compare the x-coordinate from Step 7.3 every 1 second. The result obtained in Step 7.4 , The absolute value of the distance on the projection line , , If a certain upward vehicle Less than Or a certain vehicle going downhill Less than If the vehicle is driving against traffic, it is considered to be driving in the wrong direction; otherwise, it is considered to be driving normally.

6. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the vehicle reverse driving detection method applicable to the changing viewing angle of a PTZ camera as described in any one of claims 1-5.

7. A computer-readable storage medium, characterized in that... The computer-readable storage medium stores at least one instruction or at least one program, which, when executed, implements the vehicle reverse driving detection method applicable to the changing viewing angle of a PTZ camera as described in any one of claims 1-5.