Vehicle overspeed detection method
Technical Field
The invention relates to a speed measurement method, in particular to a vehicle overspeed detection method based on deep learning, and belongs to the technical field of artificial intelligence.
Background
With the continuous development of the automobile industry in China, the extension of the road mileage and the improvement of the road condition environment in China, the quantity of motor vehicles kept in China is increased year by year. With this, there is a dramatic increase in the rate of traffic accidents, and in many types of traffic death accidents, speeding accounts for a significant proportion.
Under the existing technical conditions, all-weather and all-directional management on all road sections and intersections cannot be realized by traffic management departments simply depending on manpower, so the departments also put forward the concept of 'requiring police and safety to science and technology', and hope to utilize modern scientific and technical means to manage traffic. In a set of complete intelligent traffic system, automatic monitoring of overspeed vehicles is an important technical basis for collecting vehicle information, and plays an important role in traffic investigation, traffic management and vehicle management.
At present, in various illegal overspeed snapshot systems, the overspeed detection technology for vehicles mainly comprises a plurality of technologies such as a ring coil, microwave, radar, infrared, ultrasonic wave, laser and the like.
The loop coil detection mainly detects the vehicle by using the inductance change of an induction coil when the vehicle passes through a magnetic field. The detection mode has stable and reliable performance, is not influenced by conditions such as weather visibility and light, is widely applied, but has some fatal defects. For example, the induction coil cannot detect a stationary vehicle, the embedding method has a great influence on the reliability and service life of the equipment, and the induction coil is easily crushed by a heavy vehicle and easily damaged when a road surface is cracked, deformed and maintained. And the road surface needs to be laid again in installation and use, the operation is inconvenient, the flexibility is poor, the road surface is easy to vibrate and corrode, the maintenance is not facilitated, and the universal service life is only 2-5 years.
The radar speed measuring system mainly adopts a Doppler radar system, namely when relative radial motion exists between a transmitting source and a receiver, the frequency of a received signal changes, and a moving vehicle is judged according to the change. When the system is just opposite to the moving direction of the moving object and the measurement deviation is less than 10 degrees, the measurement precision is very high, but the system is not suitable for detecting a static vehicle. In addition, the defects include that one radar speed measurement system can only measure the speed of one vehicle in one lane at a time, and the two vehicles cannot be distinguished when being too close. When a radar speed measuring system is used for measuring speed, because the shapes of vehicles are different, the radial speed component and the actual speed component form an uncertain angle, and therefore, the accurate speed side beam is difficult to realize.
The microwave or infrared detector generally does not need road surface construction, is maintenance-free, is convenient and flexible to adjust, has strong adaptability to complex road surface conditions, has short service life, is easily influenced by the environment, and is difficult to obtain accurate traffic data for traffic detection in cities with large traffic flow.
In general, the deficiencies of the above conventional methods are mainly focused on three aspects, first, susceptibility to interference and influence by other factors; secondly, the false detection rate is high; thirdly, the detection precision is low. Therefore, how to provide a brand-new vehicle overspeed detection method based on the prior art to overcome various deficiencies in the prior art becomes a problem to be solved by the technical staff in the field.
Disclosure of Invention
In view of the above-mentioned drawbacks of the prior art, an object of the present invention is to provide a method for detecting vehicle overspeed based on deep learning, which is as follows.
A vehicle overspeed detection method comprises the following steps:
s1, detecting and tracking the vehicle, acquiring video data, extracting vehicle information from the video data, detecting the vehicle by adopting a YOLOv3 detection mode, and selecting a tracking target according to a detection result;
and S2, calculating the vehicle speed, and detecting the speed of the vehicle in the dynamic video based on OpenCV to obtain the moving speed of the moving vehicle in the video data.
Preferably, the vehicle detecting and tracking of S1 includes the following steps:
s11, acquiring video data from the fixed camera, detecting an image sequence of the video data, labeling detected vehicle information, and generating a K-field search graph;
s12, detecting by using YOLOv3 in the generated K field search graph to obtain a detection result;
and S13, filtering the detection result according to the category label to finish the selection of the tracking target.
Preferably, S11 includes the steps of:
acquiring video data from a fixed camera, detecting an image sequence of the video data, marking detected vehicle information as a tracking target, taking the marked image as a frame of image, and extracting HSV (hue saturation value) histogram feature vectors and LBP (local binary pattern) histogram feature vectors of a vehicle in the marked image;
and then generating a K-field search map according to the coordinate position of the tracking target in the previous frame, wherein K is 3.
Preferably, the generating the K-domain search map according to the vehicle coordinate position in the previous frame includes the following steps:
and manually selecting a matrix area as a basic matrix by taking the first frame image as a basis, wherein a search matrix area in the next frame image is located on the periphery of the basic matrix, and the center point coordinate of the search matrix area is coincided with the center point coordinate of the basic matrix.
Preferably, S13 includes the steps of:
filtering the detection result according to the category label to obtain target candidate frames of the same category;
if the similar candidate target does not exist, the tracking target coordinate in the previous frame image is used as the tracking target of the current frame;
if the similar candidate targets exist, extracting HSV (hue saturation value) histogram feature vectors and LBP (local binary pattern) histogram feature vectors of the candidate targets in sequence, calculating the similarity and similarity score of the two histograms, and selecting the candidate target with the highest score as the tracking target.
Preferably, the vehicle speed calculation of S2 includes the following steps:
obtaining frame rate in video data
In the video data
The coordinate position of the lower left corner of the target at the frame time is recorded as
The first in the video data
The position mark of the tracking target moving to the corresponding lower left corner coordinate at the frame time is
;
Obtaining a speed value at a certain moment in the video data according to the position information and the time information of the target object, and calculating to obtain a target speed;
and then obtaining the moving speed of the moving vehicle in the video data according to the position information of the target object in the video data and a speed calculation formula of the target object.
Preferably, the velocity of the target is calculated by the formula:
the speed unit of the target object is pixel/s.
The advantages of the invention are mainly embodied in the following aspects:
according to the vehicle overspeed detection method provided by the invention, the speed calibration and calculation of the vehicle in the real environment are realized by combining the video detection technology and the deep learning technology. The method has short processing time, can obviously improve the accuracy of the detection result and reduce the false detection rate.
In addition, the method has very wide application prospect. In the application and implementation process of the invention, the practical application of the basic theory is embodied, and a sufficient reference basis is provided for the research directions of machine vision, artificial intelligence and the like. Researchers can expand and extend the technical scheme of the invention, apply similar technologies to other technical schemes in the same field, and realize the popularization and application of the technology.
The following detailed description of the embodiments of the present invention is provided in connection with the accompanying drawings for the purpose of facilitating understanding and understanding of the technical solutions of the present invention.
Drawings
FIG. 1 is a schematic flow diagram of the process of the present invention;
FIG. 2 is a schematic diagram of a K-domain search method according to the present invention;
fig. 3 is a schematic diagram of a tracking target labeling result in the present invention.
Detailed Description
The invention provides a vehicle overspeed detection method based on deep learning, which considers the continuous development of machine learning and visual detection technology. The method comprises the steps of analyzing and calculating vehicle information in video data acquired by a fixed camera, analyzing dynamic target objects and vehicle information based on the video data, selecting a detection model YOLOv3 based on deep learning to detect and track the video data information, and calibrating and calculating a detected vehicle by using an OpenCV built-in function to obtain the actual speed of the detected vehicle. The specific scheme is as follows.
As shown in fig. 1, a vehicle overspeed detecting method includes the following steps:
and S1, detecting and tracking the vehicle. The method comprises the steps of acquiring video data, extracting vehicle information from the video data, detecting a vehicle by adopting a YOLOv3 detection mode, and selecting a tracking target according to a detection result.
Further, the step S1 further includes:
and S11, since the method mainly detects the speed of the vehicle, the corresponding target object is the vehicle. Detecting an image sequence of video data, marking detected vehicle information as a tracking target, taking the marked image as a frame of image, and extracting HSV (hue saturation value) histogram feature vectors and LBP (length saturation value) histogram feature vectors of the vehicle in the marked image;
then, a K-domain search graph is generated according to the coordinate position of the tracking target in the previous frame (that is, a matrix area is manually selected as a basic matrix based on the first frame image, a search matrix area in the next frame image falls on the periphery of the basic matrix, and the coordinate of the center point of the search matrix area coincides with the coordinate of the center point of the basic matrix), a result schematic diagram of the K-domain search method is shown in fig. 2, in the graph, an ellipse is a target object, an inner frame is a target frame obtained from the first frame, and a middle frame is a search matrix frame of the K domain of the current frame, where K = 3.
And S12, adopting YOLOv3 detection in the generated K field search map to obtain a detection result. Here, YOLOv3 is used to detect an automobile target, and then a moving vehicle in a dynamic video is labeled after the detection, the labeling process is also convenient for the automobile to be more easily tracked and the moving target object to be extracted, the automobile in the video is detected based on the video information, and the detection result is shown in fig. 3.
And S13, filtering the detection result according to the category label to obtain the target candidate frame of the same category.
If the similar candidate target does not exist, the tracking target coordinate in the previous frame image is used as the tracking target of the current frame;
if the similar candidate targets exist, extracting HSV (hue saturation value) histogram feature vectors and LBP (local binary pattern) histogram feature vectors of the candidate targets in sequence, calculating the similarity and similarity score of the two histograms, and selecting the candidate target with the highest score as the tracking target.
And S2, calculating the vehicle speed. Since the vehicle speed calculation is mainly directed to the speed calculation of the target vehicle in the video data, there is no significant difference in this process from the conventional speed concept. Only a fixed data value is used to measure the speed information of the vehicle during running. It is assumed here that the displacement is represented by s, the velocity is represented by v, and the time information measure is represented by t, where the calculation formula of the vehicle running velocity among physics is:
in the method, the speed of the vehicle in the dynamic video is detected based on the OpenCV, and the data information and the calculation target which are aimed at the time are completed based on the dynamic video.
Obtaining frame rate in video data
In the video data
The coordinate position of the lower left corner of the target at the frame time is recorded as
The first in the video data
The position mark of the tracking target moving to the corresponding lower left corner coordinate at the frame time is
。
And obtaining a speed value at a certain moment in the video data according to the position information and the time information of the target object, and calculating to obtain the target speed.
The velocity of the target is calculated by the formula:
wherein the speed unit of the target object is pixel/s.
And then obtaining the moving speed of the moving vehicle in the video data according to the position information of the target object in the video data and a speed calculation formula of the target object. The core idea in the process of calculating the vehicle speed is to detect the dynamic vehicle in the video and then process the dynamic vehicle into an image form for speed calculation; the actual speed of the target object is obtained by mapping the pixel distance of the vehicle and the actual distance, so that the actual moving speed of the vehicle in the video can be obtained through the mapping result. For example, a common theory is a camera calibration technology under computer vision, and the theoretical process is a reduction process of shooting an object by using a video camera, wherein the shot image is used for reducing a target object between spaces, and a mapping relation between an image pixel and an actual distance in the space can be obtained based on camera calibration calculation parameters.
The invention extracts corresponding vehicle characteristic information from a video image based on a deep learning framework, detects and tracks the vehicle characteristic information, determines time and position information according to a traditional speed calculation formula, and can calculate an approximate value of the vehicle movement speed according to the mapping relation between the pixel distance and the space distance, wherein the main detection is to analyze dynamic video data.
In order to verify the reliability of the method, an operator randomly selects ten groups of marking points in the road area of the actual scene to respectively perform pixel and distance mapping calculation and actual marking distance measurement, and the test results are shown in the following table.
TABLE 1 test results
Name (R)
|
Pixel distance
|
Mapping results
|
On-site distance measurement
|
Absolute value of error
|
First group
|
24
|
0.732
|
0.784
|
0.052
|
Second group
|
50
|
1.525
|
1.632
|
0.107
|
Third group
|
116
|
3.538
|
3.729
|
0.191
|
Fourth group
|
140
|
4.270
|
4.493
|
0.223
|
Fifth group
|
167
|
5.090
|
5.023
|
0.067
|
Sixth group
|
230
|
7.015
|
7.168
|
0.153
|
Seventh group
|
290
|
8.845
|
8.686
|
0.159
|
Eighth group
|
370
|
11.285
|
11.260
|
0.015
|
Ninth group
|
480
|
14.640
|
14.634
|
0.006
|
Tenth group
|
560
|
17.080
|
17.078
|
0.002
|
Mean error
|
|
|
|
0.097 |
As can be seen from table 1, the average error is 0.097, and the error exhibited when the pixel distance is large is smaller.
After the vehicle target detection is completed, labeling is carried out on vehicle information in a video, pixel coordinates of the left lower corner in a frame are labeled, position coordinates of an 87 th frame are arbitrarily extracted to be (366.31, 217.03), a coordinate position of a labeling frame of an 88 th frame is seen in the label to be (354.86, 215.93), the instantaneous speed of the moving vehicle is 32.3094m/s through calculation, the speed is 116.3139km/h through conversion, and the actual vehicle speed of the vehicle is 116.28 km/h.
In summary, the vehicle overspeed detection method provided by the invention realizes speed calibration and calculation of the vehicle in the real environment by combining the video detection technology and the deep learning technology. The method has short processing time, can obviously improve the accuracy of the detection result and reduce the false detection rate.
In addition, the method has very wide application prospect. In the application and implementation process of the invention, the practical application of the basic theory is embodied, and a sufficient reference basis is provided for the research directions of machine vision, artificial intelligence and the like. Researchers can expand and extend the technical scheme of the invention, apply similar technologies to other technical schemes in the same field, and realize the popularization and application of the technology.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein, and any reference signs in the claims are not intended to be construed as limiting the claim concerned.
Furthermore, it should be understood that although the present description refers to embodiments, not every embodiment may contain only a single embodiment, and such description is for clarity only, and those skilled in the art should integrate the description, and the embodiments may be combined as appropriate to form other embodiments understood by those skilled in the art.