Awesome Open Source
Awesome Open Source

Vehicle Detection, Tracking and Counting

This project focuses "Vehicle Detection" by Support Vector Machine(SVM) with Histogram Oriented Gradients(HOG) features. OpenCV library (version 3.0) was used for implementation.

Quick Demo

Moreover, this project has vehicle counting system, the accuracy is approximately 80% for now but developing of the accuracy is still in progress and this repository will be updated with higher accuracy rate soon.

Click to see another vehicle counting project which is developed with "Blob Detection" method.


What is SVM?

A Support Vector Machine (SVM) is a discriminative classifier formally defined by a separating hyperplane. In other words, given labeled training data (supervised learning), the algorithm outputs an optimal hyperplane which categorizes new examples.

What is HOG?

In the HOG feature descriptor, the distribution ( histograms ) of directions of gradients ( oriented gradients ) are used as features. Gradients ( x and y derivatives ) of an image are useful because the magnitude of gradients is large around edges and corners ( regions of abrupt intensity changes ) and we know that edges and corners pack in a lot more information about object shape than flat regions.

Project Demo


For Windows Users

  • Please, use CMAKE; Compiling with OpenCV 3.0 and Visual Studio 2013 from CMAKE Dependencies:
  • OpenCV 3.x (tested with OpenCV 3.0)
  • GIT (tested with git version
  • CMAKE for Windows (tested with cmake version 3.1.1).
  • Microsoft Visual Studio (tested with VS2013). Note: the procedure is similar for OpenCV 3.x and Visual Studio 2015.

Please follow the instructions below:

  1. ) Go to Windows console.

  2. ) Clone git repository:

     git clone --recursive
  3. ) Go to vehicle_counting_hog_svm/build folder.

  4. ) Set your OpenCV PATH:

     set OpenCV_DIR=C:\OpenCV3.0\build
  5. ) Launch CMAKE:

     cmake -DOpenCV_DIR=%OpenCV_DIR% -G "Visual Studio 12 Win32" ..
  6. ) Include OpenCV binaries in the system path:

     set PATH=%PATH%;%OpenCV_DIR%\x86\vc12\bin
  7. ) Open the vehicle_counting_hog_svm.sln file in your Visual Studio and switch to 'DEBUG' mode

  8. ) Click on 'ALL_BUILD' project and build!

  9. ) If everything goes well, copy vehicle_counting_hog_svm.exe to vehicle_counting_hog_svm/ and run!

For Linux Users

For Linux and Mac users, a CMakefile is provided to compile the source code.

  • Check out the latest project source code and compile it:

    ~/git clone --recursive
    ~/cd vehicle_counting_hog_svm
    ~/vehicle_counting_hog_svm/cd build
    ~/vehicle_counting_hog_svm/build/ cmake ..
    ~/vehicle_counting_hog_svm/build/ make
  • Run demo:



If you use this code for your publications, please cite it as:

    author = "Ahmet Özlü",
    title  = "Vehicle Detection, Tracking and Counting",
    year   = "2017",
    url    = ""


Ahmet Özlü


This system is available under the MIT license. See the LICENSE file for more info.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c-plus-plus (17,944
opencv (449
svm (57
gradients (20
support-vector-machine (18
vehicle-detection (15

Find Open Source By Browsing 7,000 Topics Across 59 Categories