Vehicle Detection, Tracking and Counting
72181
579
28
Published:
  • Add to Collection
  • About

    About

    Basic Vehicle Detection, Counting and Tracking.
    Published:
 
Last update: 30/04/2015
See Vehicle Detection, Tracking and Counting in GitHub
Hi everyone,
 
There are several ways to perform vehicle detection, tracking and counting.
 
An easy way to do vehicle detection is by using Haar Cascades (please, see Vehicle Detection with Haar Cascades section). Currently, I don't have a tutorial about it, but you can get some extra information in the OpenCV homepage, see Cascade Classifier page.
 
Another way to do vehicle detection is by using Background Subtraction (BS). You can try to use a background subtraction library like BGSLibrary (developed by me in my master course). See Vehicle Detection with Background Subtraction section for more details. An example source code for C++ begginers using the BGSLibrary can be seen in Demo.cpp file.
 
If you want to do vehicle tracking, maybe you will need to use a tracking algorithm. The Haar Cascades is not the best choice for vehicle tracking because its large number of false positives. To do this, one suggestion is to use a BS algorithm.  But, only a BS algorithm is insufficient to do vehicle tracking, you will need a blob tracker algorithm or a library like cvBlob or OpenCVBlobsLib. I've another youtube video performing vehicle tracking using the BGSLibrary with the cvBlob library (please, see Vehicle Tracking and Counting section).
 
Here is some tips to do vehicle tracking and counting:
1. First, perform a background subtraction.
2. Send the foreground mask to cvBlob or OpenCVBlobsLib.
3. The cvBlob library provide some methods to get the centroid, the track and the ID of the moving objects. You can also set if you want to draw a bounding box, or the centroid and the angle of the tracked object.
4. Check if the centroid of the moving object has crossed a virtual line (or region) in your video. For more informatio, please see my souce code in the Vehicle Tracking and Counting section.
5. Voilà! enjoy it :)
 
Some traffic video databases:
Vehicle Detection, Tracking and Counting

Tools: Visual Studio C++ 2010, OpenCV, BGSLibrary, cvBlob and Boost.
Vehicle Detection with Haar Cascades
 
The source code can be downloaded here:
 
The haar-cascade cars3.xml was trained using 526 images of cars from the rear (360 x 240 pixels, no scale).
The images were extracted from the Car dataset proposed by Brad Philip and Paul Updike taken of the freeways of southern California.
 
For more information, please see:
 
* Train Your Own OpenCV Haar Classifier 
 
* Related paper:
Oliveira, M.; Santos, V. Automatic Detection of Cars in Real Roads using Haar-like Features (PDF)
 
* Some additional resources:
 
* Related project:
Vehicle Detection with Background Subtraction

OpenCV C++ MFC Application using BGSLibrary (with source code) 
Vehicle Tracking and Counting

Vehicle detection by background subtraction using the BGSLibrary.
The vehicle tracking is performed by cvBlob.

The source code can be downloaded here:
The video below was made by Gigih Forda Nama (University of Lampung, Indonesia)
Vehicle Counting and Speed Estimation

Vehicle speed estimation by background subtraction using the BGSLibrary. The vehicle tracking is performed by cvBlob. The video below was made by Gigih Forda Nama from University of Lampung, Indonesia.
For more information, please contact him at: 
gigih@eng.unila.ac.id