Reputation: 313
we have been stuck on a problem on haar cascade training for a week now. Actually we are following this tutorial http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html for creating cascade xml file. But on the last command
opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt
-numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 45
-numNeg 45 -w 90 -h 100 -mode ALL -precalcValBufSize 1024
-precalcIdxBufSize 1024
we get an error:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std:: bad_alloc
Aborted (core dumped)
Specifications for the images are: 45 positive and 45 negative images(both with dimensions 90 X 100). I have made sure that samples.vec exists in the same folder and have also tried using 2048 for precalcValBufSize parameters. Please help us!
Upvotes: 1
Views: 2019
Reputation: 39389
You've run out of memory. You have several options:
By the way, your negative images should not be the same size as your positive images. Negative images should be large scenes containing backgrounds typically associated with your objects of interest. opencv_traincascade
automatically scans them for useful negative samples.
Upvotes: 5