How to train HOG and use my HOGDescriptor?

I want to prepare the data and use the HOG algorithm to detect the pedestrian. Now I can use defaultHog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); in opencv for detection, but the result is not very good for my test video. Therefore, I want training to use my database.

I prepared 1000+ positive samples and 1000+ negative samples. They are cropped to size 50 * 100, and I have a list file.

And I read several guides on the Internet, they are all so complicated, sometimes abstruse. Most of them analyze the source code and the HOG algorithm. But only with less examples and simple animations.

Some instructions show that libsvm\windows\svm-train.exe can be used for training, can anyone give examples in accordance with 1000+ 50 * 100 positive samples?
For example, like haartraing , we can do this from opencv , for example haartraining.exe โ€“a โ€“b with some parameters, and get the *.xml that will be used to detect people?

Or is there another way to learn and discover?

I prefer to know how to use it and the detailed procedures. As a detail algorithm, this is not important to me. I just want to implement it.

If anyone knows about this, please give me some tips.

+7
source share
1 answer

I have provided some code examples and instructions to start learning your own HOG descriptor using openCV: See https://github.com/DaHoC/trainHOG/wiki/trainHOG-Tutorial .

The algorithm is really too complex to be brief, the main idea is as follows:

  • Extract HOG functions from negative and positive samples of the same size and type.
  • Use the selected functional vectors together with your respective classes to train the SVM classifier, in this step you can use svm-train.exe with the generated file of the desired format containing the feature vectors and their classes (or directly include and refer to the libsvm library class in your sources .)
  • The resulting SVM model and supporting vectors are computed into a single descriptor vector, which can be used with the openCV detector.

Best wishes

+7
source

All Articles