Ask Your Question

TranCascade error (bad_alloc)

asked 2012-11-14 10:25:53 -0600

BVasilyev gravatar image

updated 2012-11-14 10:30:54 -0600

Hello everyone.

I've got a problem training the cascade classifier.

First, I create samples using opencv_createsamples:

    ./opencv_createsamples -vec test.vec -img ./positive/speed_50.jpeg 
-bg /home/boris/src/cascade/neg.txt -num 50 -w 150 -h 150

It works nice, and the output is following:

Info file name: (NULL)
Img file name: ./positive/speed_50.jpeg
Vec file name: test.vec
BG  file name: /home/boris/src/cascade/neg.txt
Num: 50
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: 150
Height: 150
Create training samples from single image applying distortions...

Then the cascade trainer:

    ./opencv_traincascade -data /home/boris/src/cascade -vec ./test.vec 
-bg ./neg.txt -numPos 50 -numNeg 2 -w 150 -h 150

And I get the following error:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Emergency stop (core dumped)

neg.txt file:


both files exist in the img directory.

OpenCV version is 2.4.2, OS is Ubuntu 12.04.

Thanks for any help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-11-20 01:28:09 -0600

AtaiV5 gravatar image

-w 150 -h 150 is too big!! Try it with -w 24 -h 24. Cause with -w 24 -h 24, you already have million of features.

edit flag offensive delete link more


I'll try this, thanks.

BVasilyev gravatar imageBVasilyev ( 2012-11-21 05:20:06 -0600 )edit

Question Tools


Asked: 2012-11-14 10:25:53 -0600

Seen: 1,696 times

Last updated: Nov 20 '12