Ask Your Question
0

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

asked 2017-11-29 10:47:35 -0600

IL416 gravatar image

updated 2017-11-29 13:22:12 -0600

berak gravatar image

I am tying to train my own classifier with the following: positives: 256 Negatives: 493 I created the .vec file from the postives with the following annotation. All of my images are in png formate are 50x50

opencv_createsamples -info annotations.txt -vec /home/coffeecam/Documents/training/samples5.vec -w 50 -h 50
**Output of createsamples:** 
Info file name: annotations.txt
Img file name: (NULL)
Vec file name: /home/coffeecam/Documents/training/samples5.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
Original image will be scaled to:
    Width: $backgroundWidth / 50
    Height: $backgroundHeight / 50
Create training samples from images collection...
annotations.txt(257) : parse errorDone. Created 256 samples

I trained with following command

opencv_traincascade -data /home/coffeecam/Documents/training/hc8 -vec /home/coffeecam/Documents/training/samples5.vec -bg /home/coffeecam/Documents/training/nag.txt -precalcValBufSize 2500 -precalcIdxBufSize 2500 -numPos 256 -numNeg 493 -numStages 15 -minhitrate 0.999 -maxfalsealarm 0.5 -w 50 -h 50

After my training starts it errors out after first stage with the following error:

POOpenCV Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
) in get, file /home/coffeecam/Documents/finalBuild/opencv-2.4.13/apps/traincascade/imagestorage.cpp, line 154
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/coffeecam/Documents/finalBuild/opencv-2.4.13/apps/traincascade/imagestorage.cpp:154: error: (-5) Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
 in function get

I might be doing something wrong. Please if you can take a look and assist me with this. I am using Java build on Ubuntu. Thanks

edit retag flag offensive close merge delete

Comments

please replace the screenshots with a text version, thank you !

berak gravatar imageberak ( 2017-11-29 11:35:51 -0600 )edit
1

Sorry about that, I updated my question.Thanks

IL416 gravatar imageIL416 ( 2017-11-29 13:13:48 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-04 15:24:05 -0600

IL416 gravatar image

I was able to train with decreasing the numPos argument value. I set the with this formula numPos = 0.9 * number_of_positive_samples and 0.99 as a minHitRate. This time i was able to complete the training however my results are terrible which i will continue to work.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-11-29 10:47:35 -0600

Seen: 997 times

Last updated: Dec 04 '17