How to train HOG and use my HOGDescriptor?
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:
- Extract HOG features from negative and positive sample images of identical size and type.
- 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).
- The resulting SVM model and support vectors are calculated into a single descriptor vector that can be used with the openCV detector.
Best regards
Admin
Updated on July 26, 2022Comments
-
Admin almost 2 years
I want to training data and use HOG algorithm to detect pedestrian. Now I can use
defaultHog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
inopencv
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, likehaartraing
, we can do it fromopencv
, likehaartraining.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.
-
Jean-François Côté over 10 yearsit seems that your sample code is no longer accessible. It redirect to the opencv.org. Do you know of another way to get there?
-
David Doria over 10 years@DaHoC I can confirm that this link no longer works.
-
nkint over 10 yearsThe github links work. It seems to me really well documented code and a nice tutorial. Personally I would consider this answer as a correct one.
-
DaHoC over 10 yearsThe openCV user tutorials are being converted to a new wiki format and therefore currently not available. The link to github basically provides the same information. Thanks for updating @Benoit Favre
-
ivarec over 9 yearstrainHOG doesn't work fine for me. I've used it with INRIA's dataset and I can only get about 8% of hit rate on pedestrians. There is something missing :(
-
DaHoC over 9 yearsI just updated the code, there was still a bug in it. I also added rudimentary training validation code which you can extend to get more insight whether the training was successful. I do not claim that the provided software works perfectly, there is certainly room for improvement :-)