Opencv sample train_hog.cpp not working
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
Are you using the example "as is"? Did you change anything, including the output .yml file for the trained SVM model?
Everything as is didn't change one thing
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?)Yeah that's what I also thought. But I added this:
cerr << "File" << (prefix+line).c_str() << endl;
beforeimread ( (prefix+line).c_str() )
and the path is correct.Actually I have:
%YAML:1.0 opencv_ml_svm:
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.
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.
Same Problem, any soloution guys?