Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to train HOG and use my HOGDescriptor?

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

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

And I have read some tutorials on the internet, they all so complex, sometimes abstruse. Most of them are analyze the source code and the algorithm of HOG. But with only less examples and simple anylize.

Some instruction show that libsvm\windows\svm-train.exe can be used to training, Can anyone gives an examples according to 1000+ 50*100 positive samples?
For example, like haartraing, we can do it from opencv, like haartraining.exe –a –b with some parameters, and get a *.xml as a result which will be used to people detection?

Or is there any other method to training, and detection?

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

If anyone know about it, please give me some tips.

like image 365
flammxy Avatar asked Mar 29 '13 19:03

flammxy


People also ask

How to extract hog features from positive and negative training set?

Extract HOG features from your positive training set. 2. Compute HOG feature vectors from your negative training set. 3. Train your Linear SVM. 4. Apply hard-negative mining.

What are the 5 steps of the hog feature descriptor?

The 5 steps of the HOG Feature Descriptor are: Preprocessing (Gamma/Color Normalization and Resizing). Computing the Gradients. Spatial / Orientation Binning (Dividing the image into cells). Block Normalization. Get the HOG Feature Vector. All of these steps are as implemented in the original paper.

What is the best image size for hog feature descriptor?

For the HOG feature descriptor, the most common image size is 64×128 (width x height) pixels. The original paper by Dalal and Triggs mainly focused on human recognition and detection. And they found that 64×128 is the ideal image size, although we can use any image size that has the ratio 1:2.

What is histogram for gradients (HOG)?

In today’s blog, we will perform pedestrian detection using HOG short for Histogram for Gradients. HOGs are great feature detectors and can also be used for object detection with SVM but due to many other State of the Art object detection algorithms like YOLO, SSD, present out there, we don’t use HOGs much for object detection. Let’s do it…


1 Answers

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

The algorithm is indeed too complex to provide in short, the basic idea however is to:

  1. Extract HOG features from negative and positive sample images of identical size and type.
  2. Use the extracted feature vectors along with their respective classes to train a SVM classifier, in this step you can use the svm-train.exe with a generated file of the correct format containing the feature vectors and their classes (or directly include and address the libsvm library class in your sources).
  3. The resulting SVM model and support vectors are calculated into a single descriptor vector that can be used with the openCV detector.

Best regards

like image 185
DaHoC Avatar answered Sep 23 '22 04:09

DaHoC