2

I want to use opencv and haartraining in order to train a new haarcascade with new samples. I have created positives.dat and negative.dat which contains list with positive and negative images. Next step to train haarcascade using opencv_haartraining.exe. However I am confused with documentation here. Any idea how can I use haartraining.exe? I have create a list of positives and negative files. Both file list contain folders with 19x19 positive images containing only the object and 19x19 negative images. I want to create the right files with opencv_createsamples in order to train a classifier using opencv_traincascade.exe or opencv_haartraining.exe. I am trying to follow the instructions from here:

opencv_createsamples -info positives.dat -w 19 -h 19 -vec pos-samples.vec

I am trying to use them without giving any information. The object contains the whole image. I am getting:

Info file name: pos-samples.dat
Img file name: (NULL)
Vec file name: samples.vec
BG  file name: (NULL)
Num: 1000
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 19
Height: 19
Create training samples from images collection...
pos-samples.dat(1) : parse errorDone. Created 0 samples
Jose Ramon
  • 5,572
  • 25
  • 76
  • 152
  • opencv_createsamples needs in each line the format: `imagepath #n x y width height` so for your kind of data you would have to reformat the whole file by `imagepath 1 0 0 19 19` in each line – Micka Jun 13 '16 at 12:53

1 Answers1

2

$ pos-samples.dat(1) : parse error

This line suggests, that that your positive samples file is formatted in wrong way.

It is also suggested ( http://docs.opencv.org/doc/user_guide/ug_traincascade.html ) to use opencv_traincascade instead of opencv_haartraining (it is deprecated).

I've used tutorial mentioned in link above in training cascade and it works as charm - it's official openCV documentation, so you won't find better tutorial.