Method for judging whether nearby vehicle moves or not in vehicle moving inspection
By training the vehicle detection model and using the target tracking algorithm, combined with the historical frame position coordinate queue, the false alarm problem of judging whether the vehicle is moving in the vehicle dynamic detection in the prior art is solved, and a more accurate vehicle movement judgment is achieved.
Patent Information
- Application Number
- CN202311395076.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-25
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art method of judging whether a vehicle is moving during dynamic inspection of a vehicle has a false alarm, especially when a person walks by the vehicle, the vehicle may be misjudged as moving.
Training a vehicle detection model, combining the target tracking algorithm, determine whether the vehicle is moving through the historical frame position coordinate queue. Specific steps include training the vehicle detection model, adding target tracking, obtaining historical frame position coordinates, and determining whether the vehicle is moving.
It effectively reduces false alarms, can accurately judge whether the nearest vehicle is moving, and improves the accuracy and reliability of the judgment.
Smart Images

Figure CN119888638A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent video processing, and in particular relates to a method for judging whether a nearby vehicle is moving during vehicle motion detection. Background Art
[0002] In the prior art, with the development of computer technology and the widespread application of computer vision principles, the use of computer image processing technology to detect and track targets in real time has become increasingly popular. Dynamic real-time tracking and positioning of targets are used in intelligent transportation systems, intelligent monitoring systems, and military target detection, and positioning surgical instruments in medical navigation surgery has a wide range of application value. The task of target detection is to find all targets of interest in the image and determine their position and size, which is one of the core issues in the field of machine vision. Due to the different appearances, shapes, and postures of various objects, coupled with the interference of factors such as illumination and occlusion during imaging, target detection has always been the most challenging problem in the field of machine vision.
[0003] At the same time, target detection learning algorithms are moving from academia to industry, and there are many difficulties in this process. Although the data imbalance problem is not the most difficult, it is definitely one of the most important problems.
[0004] Existing methods for determining whether a vehicle is moving during vehicle dynamic inspection:
[0005] 1. Adopt the method of adding motion detection: motion detection can determine the position of the change in the two frames of pictures. According to the intersection of the motion detection result and the vehicle detection result, it is judged that the vehicle has moved; 2. Determine whether the vehicle has moved according to the number of vehicles: if the number of vehicles changes, the vehicle has moved. An increase in the number of vehicles indicates that the vehicle has entered the camera, and a decrease in the number of vehicles indicates that the vehicle has left the camera. If the number of vehicles remains unchanged, determine the intersection of the result of the current frame and the result of the previous frame. If there are few or no vehicles with intersection, the vehicle has moved.
[0006] However, the defects of the prior art are:
[0007] There are many methods for judging whether a vehicle is moving in the existing vehicle motion detection. By adding motion detection, the vehicle will be judged as moving when a person walks by the vehicle; judging whether a vehicle is moving based on the number of vehicles will cause many false alarms.
[0008] In addition, terms commonly used in the prior art include:
[0009] Vehicle motion detection: monitor moving vehicles, that is, alarm when the vehicle moves. Summary of the invention
[0010] In order to solve the above problems, the purpose of this application is to solve the problem of determining whether a nearby vehicle is moving during vehicle dynamic inspection.
[0011] Specifically, the present invention provides a method for determining whether a nearby vehicle is moving during vehicle dynamic inspection, wherein the nearby vehicle refers to a vehicle whose size occupies more than 1 / 2 of the image; the method comprises the following steps:
[0012] S1. Train the vehicle detection model:
[0013] First, train a vehicle detection model. The vehicle detection model does not distinguish between far and near, that is, it includes the detection of distant and near vehicles. The vehicle detection here uses the yolov5 target detection framework, the network uses yolov5s, and the data uses the vehicle data in the open source coco dataset and the object365 dataset, which includes car, bus and truck categories.
[0014] After the model is trained, it is used to detect vehicles. That is, the detection result of the model is to output the location information of the vehicle, that is, the upper left coordinate (x1, y1) and lower right coordinate (x2, y2) of the vehicle. Since the vehicle detection model only outputs the location information of the vehicle in each frame of the real-time stream, it is not possible to determine whether the vehicle is moving at this time.
[0015] S2. Add target tracking:
[0016] To determine whether a vehicle is moving, we first need to find the same vehicle in consecutive frames; this is accomplished through target tracking.
[0017] S3. Get the historical frame position coordinates of the same vehicle:
[0018] Create a history queue to save the historical information of vehicles. Assume that it can hold the historical information of 10 vehicles. When the queue is full and new data is added, the first data put in is deleted first, and then the new data is inserted at the end of the queue, that is, first in, first out. In addition, each vehicle also has position coordinate information and trackID. The history array stores the position coordinates of vehicles with the same trackID in the historical frame, that is, the upper left coordinates (x1, y1) and the lower right coordinates (x2, y2). The trackID of the vehicle can be obtained through step S2. The position information of vehicles with the same trackID can be put into a queue. S4. Determine whether the vehicle has moved:
[0019] According to the history queue information in step S3, it can be determined whether the vehicle is moving. The condition is that the same vehicle moves in one direction in the x or y direction for 4 frames, and the vehicle is moving. Here, 4 frames are the values obtained by counting the nearby vehicle movement video. Otherwise, the vehicle is stationary.
[0020] In step S2, the target tracking task is to predict the size and position of the target in the subsequent frames given the target size and position of the initial frame of a video sequence. When the predicted vehicle position overlaps with the detected vehicle position, the trackID can be obtained. The tracking algorithm used here is the KCF tracking algorithm: the full name is the Kernel Correlation Filter kernel correlation filter algorithm, which is a tracking algorithm; the purpose of target tracking here is to obtain the vehicle's trackID, that is, the tracking ID. If the trackID of a vehicle in the previous and next frames is the same, it is regarded as the same vehicle.
[0021] The 4 frames in step S4 can be adjusted according to actual conditions, including 3 frames or 5 frames.
[0022] The specific steps in step S4 are as follows:
[0023] S4.1, when the queue has 5 data, first obtain the center coordinates of all vehicles in the history queue. The center coordinates of the head data (x, y) = ((x1+x2) / 2, (y1+y2) / 2), (x1, y1) is the upper left coordinate of the vehicle, and (x2, y2) is the lower right coordinate of the vehicle;
[0024] S4.2, obtaining the difference between the center points of adjacent vehicles in the queue on the x-axis and the y-axis, diff_x = x'-x, diff_y = y'-y, (x, y) is the coordinate of the center point of the first vehicle in the queue, (x', y') is the coordinate of the center point of all vehicles in the queue except the second vehicle;
[0025] S4.3, add two variables pos_x and pos_y to record the number of positive and negative values of diff_x and diff_y. pos_x represents the number of diff_x greater than 0, and pos_y represents the number of diff_y greater than 0. Since the queue size is 5, the number of diff_x is 4, and the number of diff_y is also 4.
[0026] S4.4, when the queue is full of 4, when pos_x is 4, which means that diff_x is all positive numbers, or pos_x is 0, which means that diff_x is all negative numbers, it means that the vehicle moves 4 times in one direction in the x direction, and it can be judged that the vehicle has moved. Similarly, when pos_y is 4 or pos_y is 0, it means that the vehicle moves 4 times in one direction in the y direction, and it can be judged that the vehicle has moved, otherwise the vehicle has not moved.
[0027] Therefore, the advantage of the present application is that the method for nearby vehicles is simple and is an effective method for determining whether a nearby vehicle is moving during vehicle dynamic inspection. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0029] Figure 1 is a schematic diagram of the process of this method. DETAILED DESCRIPTION
[0030] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.
[0031] This application proposes a method for determining whether a nearby vehicle is moving during vehicle dynamic detection. This technical training method originates from vehicle detection and can be extended to all target detections. Figure 1 As shown:
[0032] Step S1. Train the vehicle detection model:
[0033] The premise of vehicle dynamic inspection is to detect the vehicle, so we first train a vehicle detection model. The vehicle detection here uses the yolov5 target detection framework, the network uses yolov5s, and the data uses the vehicle data in the open source coco dataset and object365 dataset, which contains car, bus and truck categories.
[0034] After the model is trained, it is used to detect vehicles and output the vehicle's location information, i.e., the upper left and lower right coordinates. Since vehicle detection only outputs the vehicle's location information in each frame of the real-time stream, it is not possible to determine whether the vehicle is moving.
[0035] Step S2. Add target tracking:
[0036] To determine whether a vehicle is moving, we should first find the same vehicle in consecutive frames. Object tracking can accomplish this task. The object tracking task is to predict the size and position of the object in subsequent frames given the size and position of the object in the initial frame of a video sequence. When the predicted vehicle position overlaps with the detected vehicle position, the trackID can be obtained. The purpose of object tracking here is to obtain the vehicle's trackID, or tracking ID. If the trackID of a vehicle in the previous and next frames is the same, it is considered to be the same vehicle.
[0037] Step S3. Get the historical frame position coordinates of the same vehicle:
[0038] Create a history queue as a vehicle attribute, with a size of 10. When the queue is full and new data is added, the first data put in is deleted first, and then the new data is inserted at the end of the queue, that is, first in, first out. In addition, each vehicle has position coordinate information and trackID. The history array stores the position coordinates of vehicles with the same trackID in the historical frame, that is, the upper left coordinates (x1, y1) and the lower right coordinates (x2, y2). The trackID of the vehicle can be obtained through step S2. The position information of vehicles with the same trackID can be put into a queue.
[0039] Step S4. Determine whether the vehicle is moving
[0040] According to the history queue information in step S3, it can be determined whether the vehicle is moving. If the same vehicle moves in one direction of x or y for 4 frames, it can be determined that the vehicle is moving. Otherwise, the vehicle is stationary. The specific steps are as follows:
[0041] S4.1, when the queue has 5 data, first obtain the center coordinates of all vehicles in the history queue. The center coordinates of the head data (x, y) = ((x1+x2) / 2, (y1+y2) / 2), (x1, y1) is the upper left coordinate of the vehicle, and (x2, y2) is the lower right coordinate of the vehicle.
[0042] S4.2, obtain the difference between the center points of adjacent vehicles in the queue on the x-axis and y-axis, diff_x = x'-x, diff_y = y'-y, (x, y) is the coordinate of the center point of the first vehicle in the queue, (x', y') is the coordinate of the center point of all vehicles in the queue except the second vehicle.
[0043] S4.3, add two variables pos_x and pos_y to record the number of positive and negative values of diff_x and diff_y. pos_x represents the number of diff_x greater than 0, and pos_y represents the number of diff_y greater than 0. Since the queue size is 5, the number of diff_x is 4, and the number of diff_y is also 4.
[0044] S4.4, when the queue is full of 4, when pos_x is 4 (indicating that diff_x is all positive) or pos_x is 0 (indicating that diff_x is all negative), it means that the vehicle has moved 4 times in the x direction, and it can be judged that the vehicle has moved. Similarly, when pos_y is 4 or pos_y is 0, it means that the vehicle has moved 4 times in the y direction, and it can be judged that the vehicle has moved, otherwise the vehicle has not moved.
[0045] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for determining whether a nearby vehicle is moving during vehicle dynamic inspection, characterized in that: The nearby vehicle refers to a vehicle whose size occupies more than 1 / 2 of the image; the method comprises the following steps: S1. Train the vehicle detection model: First, train a vehicle detection model; the vehicle detection here uses the yolov5 target detection framework, the network uses yolov5s, and the data uses the vehicle data in the open source coco dataset and the object365 dataset, which includes car, bus and truck categories; After the model is trained, it is used to detect vehicles. That is, the detection result of the model is to output the location information of the vehicle, that is, the upper left coordinate (x1, y1) and lower right coordinate (x2, y2) of the vehicle. Since the vehicle detection model only outputs the location information of the vehicle in each frame of the real-time stream, it is not possible to determine whether the vehicle is moving at this time. S2. Add target tracking: To determine whether a vehicle is moving, we first need to find the same vehicle in consecutive frames; this is accomplished through target tracking. S3. Get the historical frame position coordinates of the same vehicle: Create a history queue to save the historical information of vehicles. Assume that it can hold the historical information of 10 vehicles. When the queue is full and new data is added, the first data put in is deleted first, and then the new data is inserted at the end of the queue, that is, first in, first out. In addition, each vehicle also has position coordinate information and trackID. The history array stores the position coordinates of vehicles with the same trackID in the historical frame, that is, the upper left coordinates (x1, y1) and the lower right coordinates (x2, y2). The trackID of the vehicle can be obtained through step S2. The position information of vehicles with the same trackID can be put into a queue. S4. Determine whether the vehicle is moving: According to the history queue information in step S3, it can be determined whether the vehicle is moving. The condition is that the same vehicle moves in one direction in the x or y direction for 4 frames, and the vehicle is moving. Here, 4 frames are the values obtained by counting the nearby vehicle movement video. Otherwise, the vehicle is stationary.
2. A method for determining whether a nearby vehicle is moving during vehicle dynamic detection according to claim 1, characterized in that: In step S2, the target tracking task is to predict the size and position of the target in the subsequent frames given the target size and position of the initial frame of a video sequence. When the predicted vehicle position overlaps with the detected vehicle position, the trackID can be obtained. The tracking algorithm used here is the KCF tracking algorithm. The purpose of target tracking here is to obtain the vehicle's trackID, that is, the tracking ID. If the trackID of a vehicle in the previous and next frames is the same, it is regarded as the same vehicle.
3. A method for determining whether a nearby vehicle is moving during vehicle dynamic detection according to claim 1, characterized in that: The 4 frames in step S4 can be adjusted according to actual conditions, including 3 frames or 5 frames.
4. The method for determining whether a nearby vehicle is moving during vehicle dynamic detection according to claim 1, characterized in that: The specific steps in step S4 are as follows: S4.1, when the queue has 5 data, first obtain the center coordinates of all vehicles in the history queue. The center coordinates of the head data (x, y) = ((x1+x2) / 2, (y1+y2) / 2), (x1, y1) is the upper left coordinate of the vehicle, and (x2, y2) is the lower right coordinate of the vehicle; S4.2, obtaining the difference between the center points of adjacent vehicles in the queue on the x-axis and the y-axis, diff_x = x'-x, diff_y = y'-y, (x, y) is the coordinate of the center point of the first vehicle in the queue, (x', y') is the coordinate of the center point of all vehicles in the queue except the second vehicle; S4.3, add two variables pos_x and pos_y to record the number of positive and negative values of diff_x and diff_y. pos_x represents the number of diff_x greater than 0, and pos_y represents the number of diff_y greater than 0. Since the queue size is 5, the number of diff_x is 4, and the number of diff_y is also 4. S4.4, when the queue is full of 4, when pos_x is 4, which means that diff_x is all positive numbers, or pos_x is 0, which means that diff_x is all negative numbers, it means that the vehicle moves 4 times in one direction in the x direction, and it can be judged that the vehicle has moved. Similarly, when pos_y is 4 or pos_y is 0, it means that the vehicle moves 4 times in one direction in the y direction, and it can be judged that the vehicle has moved, otherwise the vehicle has not moved.
Citation Information
Patent Citations
Method for conducting real-time image recognition on mobile terminal and mobile terminal
CN104144345A
Vehicle dynamic detection method and device, computer equipment and storage medium
CN111126286A
Motor vehicle illegal parking intelligent identification method and system based on deep learning
CN114648748A
Vehicle tracking method and system
CN115797410A
Vehicle target motion state estimation method based on video analysis
CN116797994A