Real-Time Vehicle Tracking & Analytics using Traffic Videos

By Team Algo
Reading Time: 3 minutes

By Nikhil Saoji, Associate Data Scientist at AlgoAnalytics

Traditional traffic monitoring systems usually include a setup based on inductive loops, RADARs, or LIDARs. However, with the increase in the number of traffic video cameras, there is a significant opportunity for Real-Time Analytics for these videos. It can provide actionable insights about traffic flow characteristics such as the location of vehicles, their tracks, and the speeds of individual vehicles. This system can further be coupled with the Automatic Number Plate Recognition (ANPR) system to find over-speeding vehicles, and automatically generate speeding tickets. It can also be coupled with the anomaly detection system to identify crashes, stalled vehicles, etc. These insights will benefit a wide variety of agencies such as the traffic control department and insurance companies.

The below section describes the AI techniques behind vehicle speed estimation and automatic traffic ticket generation. This system works as a 2-step process, as described below.

1. Vehicle Speed Estimation:

Using the formula (speed = Distance/Time), we calculate the speed of individual vehicles. Time can be calculated with the help of FPS of recorded video and the number of frames for which a vehicle appeared in that video. However, for distance measurement, we track the position of individual vehicles in subsequent frames.

At AlgoAnalytics, we have designed a solution for vehicle speed estimation that consists of 3 stages:


Figure 1 Overview of AlgoAnalytics’ Vehicle Speed Estimation System

1.1. Vehicle object detection:

To know the precise location of vehicles on the road, we use the YOLO object detection model trained on the COCO dataset. Hence it can detect vehicles of various categories such as motorcycle, car, bus, truck.


Figure 2 Vehicle object detection output

Other techniques for vehicle detection range from traditional methods such as background subtraction to Deep Learning object detectors such as Faster RCNN, Mask R-CNN, etc. Some researchers have even used CNN-based detectors along contour generation models to fit 3D bounding boxes around vehicles [1].

1.2. Vehicle tracking system:

To find the distance travelled by a vehicle, we need to find the difference in the position of a point on the vehicle in adjacent frames. That point usually should lie on the road plane. We select the center point of the bottom side of the vehicle bounding box as tracking point and used Kalman Filters for tracking.


Figure 3 Vehicle tracking output by Kalman Filters

Other techniques for tracking include feature point extractors with KLT feature trackers [2] or optical flow trackers [3]

1.3. Pixel to real-world mapping:

Now that we have pixel shift of tracked points in adjacent frames, we need to map pixel distances to real-world distances. For this purpose, we use the homography technique for image rectification. Using this, we transform the perspective view of the road to get a planar top view. And with the help of real-world measurements for top view, we can find the distances travelled by vehicles.


Figure 4 Perspective view and corresponding top view of the road using the Homography Technique

Other techniques include camera calibration which can be either manual or automatic. Manual calibration depends on some real-world measurements similar to our solution, while automatic calibration relies on vanishing point calculations and the average size of vehicles/lane markings [4].

Once the time and distance parameters are obtained as mentioned above, speeds are calculated for individual vehicles. Check out the results of our system here: Youtube Video

2. ANPR and Traffic Ticket Generation:

Whenever the system detects an over-speeding vehicle, it can run the object detector and OCR tools for Number Plate Detection and Recognition.

For demo visit our link  https://algoanalytics.com/demoapp

For further information, please contact: info@algoanalytics.com

References:

[1] Automatic camera calibration for traffic understanding. URL: http://www.bmva.org/bmvc/2014/files/paper013.pdf

[2] A video-based system for vehicle speed measurement in urban roadways. URL:http://www.dainf.ct.utfpr.edu.br/~rminetto/projects/vehicle-speed/Paper_ITS_final.pdf

[3] Geometry-aware Traffic Flow Analysis by Detection and Tracking. URL:https://openaccess.thecvf.com/content_cvpr_2018_workshops/papers/w3/Shi_Geometry-Aware_Traffic_Flow_CVPR_2018_paper.pdf

[4] Comprehensive Dataset for Automatic Single Camera Visual Speed Measurement. URL: https://arxiv.org/pdf/1702.06441.pdf