This is an application of Object detection using Histogram of Oriented Gradients (HOG) as features and Support Vector Machines (SVM) as the classifier.
This process is implemented in python, the following libraries are required:
- Scikit-learn (For implementing SVM)
- Scikit-image (For HOG feature extraction)
- OpenCV (for testing)
- PIL (Image processing library)
- Numpy (matrix multiplication)
- Imutils for Non-maximum suppression
A training set should comprise of:
- Positive images: these images should contain only the object you are trying to detect
- Negative images: these images can contain anything except for the object you are detecting
Web link for the Inria dataset is shown below - the dataset is for pedestrian detection but this code can be adapted for other datasets too eg. car detection (dataset link: http://cogcomp.org/Data/Car/). Inria dataset link: http://pascal.inrialpes.fr/data/human/
The files are divided into the following: Training & Testing (this is where you evaluate your trained classifier) Visualise Hog: simply allows you to see what the gradients calculated look like on a given image (specified by the user).
The results of the trained person detector on a test image are as follows: Normal (RGB image)> HOG descriptors
After classifying with a trained SVM model and applying NMS the following result is achieved:
Note The results are better when the background is not cluttered (shown below). As seen from the original and the extracted HOG image, majority of the gradients binned come from the background (this could be due to the training set not being robust to more greener/cluttered background as shown in the test)
This method is also robust to different poses and presence of multiple subjects as shown in the figure below where an image from google was shown to the webcam