Mashiro1218 / vehicle_counting_hog_svm

Vehicle Detection, Tracking and Counting by SVM with HOG Features with OpenCV

Home Page:https://www.youtube.com/watch?v=itmV7druy9Y&feature=youtu.be

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Theory

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

Installation

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 2.7.2.windows.1).
  • 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 https://github.com/ahmetozlu/vehicle_counting_hog_svm.git
    
  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 https://github.com/ahmetozlu/vehicle_counting_hog_svm.git
    ~/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:

    ~/vehicle_counting_hog_svm/run_vehicle_counting_hog_svm.sh
    

Citation

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

@ONLINE{vdtc,
    author = "Ahmet Özlü",
    title  = "Vehicle Detection, Tracking and Counting",
    year   = "2017",
    url    = "https://github.com/ahmetozlu/vehicle_counting_hog_svm"
}

Author

Ahmet Özlü

License

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

About

Vehicle Detection, Tracking and Counting by SVM with HOG Features with OpenCV

https://www.youtube.com/watch?v=itmV7druy9Y&feature=youtu.be

License:MIT License


Languages

Language:C++ 100.0%