Ask Your Question

Revision history [back]

training haar cascade with single positive sample

Hi,

I try to train OpenCV to recognize a logo that is flat, so I really only need 1 positive sample.

I used the following command to create 1000 samples with different distortion and store in sample.vec opencv_createsamples -img positive_images\3.jpeg -num 1000 -vec sample.vec

However, I don't know how to use opencv_traincascade command to train it properly. I tried the following command:

opencv_traincascade -data data -vec sample.vec -bg negatives.txt -numPos 1000 -numNeg 3000 -numStages 10 -w 24 -h 24

But it returns the following error, probably because I used only one positive sample although I thought the vec file should contain 1000 samples.

OpenCV Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.

So I changed -numPos value to 1

opencv_traincascade -data data -vec sample.vec -bg negatives.txt -numPos 1 -numNeg 3000 -numStages 10 -w 24 -h 24

The training was complete very quickly and ends in "TRAINING 1-stage" that returns the following message: Required leaf false alarm rate achieved. Branch training terminated.

I know this is not an error, but the output xml file is very simple, only 2kbytes. I think it only trained the model with 1 image in the vec. Can anyone help me on how to use open_traincascade in this case?

Thanks