Video traffic flow statistical method based on unmanned aerial vehicle and time sequence characteristics
Technical Field
The invention belongs to the technical field of image processing, and particularly relates to a traffic flow statistical method based on unmanned aerial vehicles and time sequence characteristic video processing.
Background
Intelligent transportation has become a future development trend, and how to automatically and efficiently manage a transportation system is also a current hotspot. The traffic flow detection is used as a part of intelligent traffic, and has a very important position in the aspects of traffic monitoring management, urban road construction and the like.
The major traffic flow detection techniques in recent years include: magnetic induction detection technology, wave frequency detection technology, video detection technology and the like. The video detection technology has the advantages of flexible installation, low cost, convenient management and maintenance and the like, and along with the development of image processing technology and computer vision, the traffic flow detection technology based on video images has attracted more and more attention and attention of people.
The current commonly used video-based vehicle detection algorithms mainly include: background subtraction, frame-to-frame subtraction, edge detection, optical flow tracking, and the like. Compared with the traditional method, the method effectively completes the work of monitoring, controlling and managing the road traffic through image processing and machine vision technology. Still have some shortcomings, for example every lane all need install the camera, easily produce lou to examine, the false retrieval scheduling problem.
Disclosure of Invention
The purpose of the invention is as follows: in order to solve the existing defects and problems, the invention provides a flexible, convenient, efficient and accurate traffic flow detection method.
The technical scheme is as follows: in order to achieve the purpose, the invention adopts the technical scheme that:
a video traffic flow statistical method based on unmanned aerial vehicles and time sequence characteristics comprises the following steps:
step 1, vertically shooting and recording downwards above a road intersection through an unmanned aerial vehicle to obtain a traffic flow video of the intersection, and manually inputting the position of a lane needing to count the traffic flow in a video image;
step 2, carrying out video analysis processing on the traffic flow statistical video to obtain a background image without a vehicle;
step 3, extracting a frame of image of the video and preprocessing the frame of image to obtain an image matched with a background image so as to eliminate the influence caused by shaking during shooting;
step 4, extracting characteristic values of the preprocessed image at the positions of lanes needing to be counted, extracting the next frame of the video, and repeating the steps 3 to 4, wherein the characteristic values of all the video frames are put together to form a characteristic time sequence histogram;
and 5, analyzing the characteristic time sequence histogram to obtain the traffic flow number of the lane to be counted in the time period.
Further, the step 2 is realized according to the following method:
step 2-1, taking 30 video images at equal time intervals from the video counting start time to the counting end time, and taking the first image as a calibration image;
2-2, respectively matching the 29 subsequent images with the first calibration image for surf characteristic points to obtain 29 new images, and forming 30 preprocessed images together with the original first calibration image;
and 2-3, traversing the pixels of each position of the 30 images, taking the median of three channel color components of the 30 pixels of each position as the pixel value of the specified channel of the specified position, and obtaining the background image without the vehicle after traversing.
Further, the pretreatment method in step 3 is as follows: and carrying out surf feature point matching on the video frame image and the background image.
Further, the step 4 is realized according to the following method;
step 4-1, respectively traversing all pixels of the manually input lane position area for the background image and the video frame image;
step 4-2, respectively calculating the absolute values of the difference values of the three color components for the pixels at the corresponding positions of each pair of images;
step 4-3, adding the absolute values of the difference values of the three components to obtain a pixel difference value of the pixel position of the two images;
step 4-4, adding the pixel difference values of all pixels in the area to be used as the characteristic value of the lane area;
and 4-5, if the region characteristic value is smaller than a certain threshold value, determining that the characteristic value is caused by noise, and setting the region characteristic value to be 0.
Further, the corresponding threshold selected in the step 4-5 is 100.
Further, the step 5 is realized according to the following method;
step 5-1, selecting a response characteristic threshold according to the time sequence histogram;
step 5-2, recording the time when each pair of response characteristic values of the time sequence histogram exceed the threshold value from left to right and the time when the response characteristic values lower than the threshold value from left to right as possible response time of the vehicle;
step 5-3, if the vehicle driving response time is less than 5 frames, the response is considered as noise interference, and the response is eliminated;
and 5-4, counting the number of all effective responses, namely the number of vehicles passing through the specified lane in the specified time.
Further, the method for selecting the corresponding threshold in the step 5-1 includes: and finding out the maximum response threshold value appearing in all time sequences, and selecting the threshold value as 10% of the maximum response threshold value.
Has the advantages that: the video traffic flow statistical method based on the unmanned aerial vehicle and the time sequence characteristics, provided by the invention, adopts the unmanned aerial vehicle technology which is rapidly developed in recent years to collect traffic flow videos, the collection mode becomes flexible and efficient, the traffic flow conditions of all lanes can be recorded at a traffic intersection at one time, and the complex operation of installing cameras at a plurality of intersections is saved. For the problem of jitter caused by images shot by an unmanned aerial vehicle in the air, surf characteristic transformation in digital image processing is adopted for image matching, and jitter is effectively eliminated. For the statistics of the traffic flow, only manually input lane areas are counted, and the interference error of the area outside the lane is eliminated. And simple and efficient regional characteristic time sequence analysis is adopted, multiple interference error elimination steps are carried out, and the statistics of the traffic flow is more accurate. The method is simple and efficient, high in adaptability and expandability and has wide application prospects.
Drawings
Fig. 1 is an algorithm flow chart of a video traffic flow statistical method based on unmanned aerial vehicles and time sequence characteristics according to the invention.
Fig. 2 is an input video shot by the drone.
Fig. 3 is a schematic diagram of selecting a lane area position.
Fig. 4 is a background image obtained by the median method.
Fig. 5 is a feature timing histogram.
Detailed Description
The present invention will be further described with reference to the accompanying drawings.
The method comprises the steps of firstly, shooting a traffic flow video above a road intersection by an unmanned aerial vehicle, preprocessing the obtained video, and extracting a background image. To eliminate the jitter, for each frame of image of the video, a match is made with the background image. And then, performing feature extraction on the matched image designated area to obtain a feature time sequence histogram. And analyzing the characteristic time sequence histogram to obtain the traffic flow number of the lane. The flow chart is shown in fig. 1.
Examples
Step 1, collecting images and inputting statistical area information.
Step 1-1, vertically shooting and recording downwards above a road intersection through an unmanned aerial vehicle to obtain a traffic flow video of the intersection, as shown in fig. 2;
step 1-2, selecting the position of the lane needing to be counted in the video as an area condition input system needing to be counted, and generally selecting an area with relatively pure color from a white line of the lane to a crosswalk, as shown in fig. 3.
And 2, calculating and extracting a background image by a median method.
Step 2-1, taking 30 video images at equal time intervals from the video counting start time to the counting end time, and taking the first image as a calibration image;
2-2, as the unmanned aerial vehicle inevitably shakes during aerial video shooting, matching transformation is required to eliminate the shaking so as to avoid error interference caused by shaking, and surf characteristic point matching transformation is respectively carried out on the 29 subsequent images and the first calibrated image to obtain new 29 images, and the new 29 images and the original first calibrated image together form 30 images after preprocessing;
and 2-3, traversing the pixels of each position of the 30 images, taking the median of three channel color components of the 30 pixels of each position as the pixel value of the specified channel of the specified position, and obtaining a background image without vehicles after traversing, as shown in fig. 4.
And 3, processing each frame in the video, extracting each frame, and performing surf feature matching on the frame image and the calibration image to achieve the purpose of eliminating the influence caused by shaking.
And 4, comparing the positions of the input regions in the frame image and the background image, extracting the response of the vehicle possibility in the region, and forming a characteristic time sequence histogram by the responses of all the frames together, as shown in fig. 5.
Step 4-1, respectively traversing all pixels of the manually input lane position area for the background image and the video frame image;
step 4-2, respectively calculating the absolute values of the difference values of the three color components for the pixels at the corresponding positions of each pair of images;
step 4-3, adding the absolute values of the difference values of the three components to obtain a pixel difference value of the pixel position of the two images;
step 4-4, adding the pixel difference values of all pixels in the area to be used as the characteristic value of the lane area;
and 4-5, if the region characteristic value is less than 100, determining that the characteristic value is caused by noise, and setting the region characteristic value to be 0, otherwise, keeping the region characteristic value.
And 5, analyzing the characteristic time sequence histogram to obtain the traffic flow number of the lane to be counted in the time period.
Step 5-1, selecting a response characteristic threshold according to the time sequence histogram, and generally selecting 10% of the maximum value;
step 5-2, recording the time when each pair of response characteristic values of the time sequence histogram exceed the threshold value from left to right and the time when the response characteristic values lower than the threshold value from left to right as possible response time of the vehicle;
step 5-3, if the vehicle driving response time is less than 5 frames, the response is considered as noise interference, and the response is eliminated;
and 5-4, counting the number of all effective responses, namely the number of vehicles passing through the specified lane in the specified time.
In conclusion, the unmanned aerial vehicle and the digital image processing technology are combined, and a convenient, efficient and accurate traffic flow detection scheme is realized through methods of background modeling, image jitter elimination, feature extraction and the like.
The accuracy rate of the traffic flow statistics can reach more than 90%, compared with the traditional method, the method can greatly save the cost of statistics, including manpower and material resources, improve the statistics efficiency, and ensure high accuracy rate. Due to the flexibility and convenience of the unmanned aerial vehicle, the method is wide in application range, high in expandability and wide in application prospect.
The above description is only of the preferred embodiments of the present invention, and it should be noted that: it will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the principles of the invention and these are intended to be within the scope of the invention.