Ask Your Question
0

How to use my hog.xml file?

asked 2018-09-25 14:41:21 -0600

updated 2018-09-25 15:16:29 -0600

Hello!

Because i can´t find any solutions to my problem in german forums, I'll try it here in english. I used the cascade-trainer-gui of OpenCV to train my own HOG/HAAR/LBP cascades to find a biro on a video file. HAAR and LBP works very good, but i don´t know how to use my hog.xml file.

I tried this:

HOGDescriptor hog;

hog.load(…/hog.xml);

hog.detectMultiScale(img, features, 0, cv::Size(8, 8), cv::Size(32, 32), 1.05, 2);

But that does not seem to work like HAAR and LBP.

Then I tested the DefaultPeopleDetector:

HOGDescriptor hog

hog.setSVMDetector( HOGDescriptor::getDefaultPeopleDetector() )

hog.detectMultiScale(img, features, 0, cv::Size(8, 8), cv::Size(32, 32), 1.05, 2)

and it worked...but not with my own XML-File... my program can detect People now.

So my Question is how to use .setSVMDetector(const vector<float>& detector)? and what is const vector<float>& detector exactly.

Can sb. give me an example Code how to use my own hog.xml-file instead of getDefaultPeopleDetector??

Thank u very much, i can´t find a solution for days.

greetz Optimus

edit retag flag offensive close merge delete

Comments

What do you mean by But that does not seem to work like HAAR and LBP? Are errors getting thrown? If yes, what are they? What results are you expecting?

eshirima gravatar imageeshirima ( 2018-09-25 15:10:57 -0600 )edit

The error is, that my program can´t read my hog.xml-file correctly i think. It works with my Haar.xml and my LBP.xml.

I expected (like with Haar and LBP) that there ist a circle on my biro, when i hold it in front of my camera. My programm works very good with Haar and LBP and quite fast. But i want to compare it with HOG and use the same training dataset.

to train my my xml files i used this program: link text

OptimusPrein gravatar imageOptimusPrein ( 2018-09-26 07:24:54 -0600 )edit

2 answers

Sort by » oldest newest most voted
0

answered 2018-09-25 16:11:49 -0600

i guess your hog.xml is trained to be used with CascadeClassifier like hogcascade_pedestrians.xml but unfortunately it is no more supported (if you want to use it you should use OpenCV 2.4.x).

you can see here a suitable xml to be used with HOGDescriptor.

edit flag offensive delete link more

Comments

thank you for your quick answer!

I will try it with OpenCV 2.4.x

Do you know why it is not more supported? Can you recommend me a tutorial to train my own xml file with hog and SVM?

Thanks again

OptimusPrein gravatar imageOptimusPrein ( 2018-09-26 05:21:09 -0600 )edit

please upload a sample image of the object you want to detect. let me check if it is suitable to train a HOGDsscriptor detector

sturkmen gravatar imagesturkmen ( 2018-09-26 08:25:31 -0600 )edit
0

answered 2018-09-25 15:30:48 -0600

A couple things to troubleshoot.

  1. Confirm that you are providing the correct path to hog.xml. OpenCV already handles this for you by simply providing HOGDescriptor::getDefaultPeopleDetector().
  2. You are using the same parameters for getDefaultPeopleDetector() in your detectMultiScale() as your hog.xml. Did you train your dataset with the same parameters as getDefaultPeopleDetector? Meaning, was your model trained on 32x32 images? Take a moment to understand detectMultiScale first. Thereafter, this response will be a good guide in helping you determine what values would make sense for your model.
  3. Here's the documentation with regards to .setSVMDetector(const vector<float>& detector) and const vector<float>& detector

Finally, here's a tutorial on how to use Haar Cascades on C++. You can also Google around for more.

Cheers :)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-09-25 14:41:21 -0600

Seen: 1,847 times

Last updated: Sep 25 '18