简体   繁体   English

OpenCV-TranCascade错误(bad_alloc)

[英]OpenCV - TranCascade error (bad_alloc)

I've got a problem training the cascade classifier. 训练级联分类器时遇到问题。

First, I create samples using opencv_createsamples: 首先,我使用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...
Done

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: neg.txt文件:

img/img1.jpeg  
img/img2.jpeg

both files exist in the img directory. 这两个文件都存在于img目录中。

OpenCV version is 2.4.2, OS is Ubuntu 12.04. OpenCV版本是2.4.2,操作系统是Ubuntu 12.04。

Thanks for any help. 谢谢你的帮助。

you need to set w and h to the same size than the sample generated, 150 in your case. 您需要将w和h设置为与生成的样本相同的大小(在您的情况下为150)。 I am having he same problem for any sample size too big. 任何样本量太大,我都会遇到相同的问题。 It works for 48x48 not for 96x96. 它适用于48x48而不适用于96x96。 Let me know if you sloved the problem with bigger samples. 让我知道您是否喜欢使用更大的样本来解决这个问题。

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM