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.
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.
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.
- The demo is available on Youtube: https://www.youtube.com/watch?v=itmV7druy9Y&feature=youtu.be
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:
-
) Go to Windows console.
-
) Clone git repository:
git clone --recursive https://github.com/ahmetozlu/vehicle_counting_hog_svm.git
-
) Go to vehicle_counting_hog_svm/build folder.
-
) Set your OpenCV PATH:
set OpenCV_DIR=C:\OpenCV3.0\build
-
) Launch CMAKE:
cmake -DOpenCV_DIR=%OpenCV_DIR% -G "Visual Studio 12 Win32" ..
-
) Include OpenCV binaries in the system path:
set PATH=%PATH%;%OpenCV_DIR%\x86\vc12\bin
-
) Open the vehicle_counting_hog_svm.sln file in your Visual Studio and switch to 'DEBUG' mode
-
) Click on 'ALL_BUILD' project and build!
-
) 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
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"
}
Ahmet Özlü
- Please contact for dataset or more info: [email protected]
This system is available under the MIT license. See the LICENSE file for more info.