SVM classifier based on HOG features for “object detection” in OpenCV

In order to detect arbitrary objects with using opencv HOG descriptors and SVM classifier, you need to first train the classifier. Playing with the parameters will not help here, sorry 🙁 .

In broad terms, you will need to complete the following steps:

Step 1) Prepare some training images of the objects you want to detect (positive samples). Also you will need to prepare some images with no objects of interest (negative samples).

Step 2) Detect HOG features of the training sample and use this features to train an SVM classifier (also provided in OpenCV).

Step 3) Use the coefficients of the trained SVM classifier in HOGDescriptor::setSVMDetector() method.

Only then, you can use the peopledetector.cpp sample code, to detect the objects you want to detect.

Leave a Comment