Opencv sample train_hog.cpp not working

asked 2016-04-16 11:54:28 -0600

Hi, just started with opencv and I was trying out the train_hog sample but it's not working.

I used this example. Compiled while following this tutorial. For the training i'm using the INRIA dataset. This is the error I'm getting

./train --pd=/home/user/Documents/train/INRIA_dataset/ -p=pos.lst --nd=/home/user/Documents/train/INRIA_dataset/ -n=neg.lst
Start training......[done]
OpenCV Error: Parsing error (SVM model data is invalid, check sv_count, var_* and class_count tags) in write, file /home/user/OpenCV/opencv-3.1.0/modules/ml/src/svm.cpp, line 2038
terminate called after throwing an instance of 'cv::Exception'
what():  /home/user/OpenCV/opencv-3.1.0/modules/ml/src/svm.cpp:2038: error: (-212) SVM model data is invalid, check sv_count, var_* and class_count tags in function write

Aborted (core dumped)

I'm using ubuntu 15.10 64 bit

edit retag flag offensive close merge delete

Comments

Are you using the example "as is"? Did you change anything, including the output .yml file for the trained SVM model?

LorenaGdL gravatar imageLorenaGdL ( 2016-04-16 12:52:08 -0600 )edit

Everything as is didn't change one thing

blublubber gravatar imageblublubber ( 2016-04-16 12:53:57 -0600 )edit

Ok, I had my doubts about you changing filename while training, but not on the test_it() function. It seems that the training does run but the generated .yml is invalid. Have you double-checked you're providing the right paths? (are pos.lst and neg.lst right below INRIA_DATASET folder?)

LorenaGdL gravatar imageLorenaGdL ( 2016-04-16 12:59:43 -0600 )edit

Yeah that's what I also thought. But I added this: cerr << "File" << (prefix+line).c_str() << endl; before imread ( (prefix+line).c_str() ) and the path is correct.

blublubber gravatar imageblublubber ( 2016-04-16 13:10:09 -0600 )edit

Actually I have: %YAML:1.0 opencv_ml_svm:

blublubber gravatar imageblublubber ( 2016-04-16 13:20:05 -0600 )edit
1

Looking at the code, the exception is thrown because it identifies the SVM as not trained. Betting again it is not properly reading the images. Could you please run the code in debug mode? There are some regions in debug code that should be showing you the read pos and neg images.

LorenaGdL gravatar imageLorenaGdL ( 2016-04-16 13:24:45 -0600 )edit

Yep did that just now. And it all looks fine. it shows me a popup with the image. And another with hog descriptors it gets from the images. but still the same error.

blublubber gravatar imageblublubber ( 2016-04-16 13:32:24 -0600 )edit

Same Problem, any soloution guys?

sadransh gravatar imagesadransh ( 2016-08-28 06:29:35 -0600 )edit