哈尔训练OpenCV断言失败 [英] haar training OpenCV assertion failed

查看:541
本文介绍了哈尔训练OpenCV断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在OpenCV中使用3340正图像和1224负像来训练一个类似haar的分类器。 (在.txt文件中我保留负图像名称,即负像(1).bmp,在txt文件中我保留正数,即图片(1).bmp 1 0 0 64 128.
其实积极的例子已经裁剪的行人图像,所以我只需要指定每个图像一个正样本)。



在训练过程中的某一时刻,它停止并说:


Opencv错误:未知函数中的断言失败(elements_read == 1),文件c:\path\cvhaartraining.cpp,第1858行


有关造成这种情况的任何想法?

解决方案

此问题由OpenCV DevZone网站上的实用程序创建者于2012年6月回答。



引用Maria:


问题是你的vec文件有完全相同的样本计数
,您在命令行-numPos 979中传递。培训应用程序使用
来自vec文件的所有样本以训练0阶段,并且不能得到新的
正样本用于下一阶段训练因为vec文件结束了。
traincascade的错误是它在这种情况下有assert(),但它
必须抛出异常与错误消息为用户。它是固定的
在r8913。
-numPose是用于训练每个阶段的样本计数。一些已经使用的样本可以在每个阶段过滤(即
被识别为背景),但不超过(1 - minHitRate)* numPose
。所以vec文件必须包含> =(numPose +(numStages-1)
*(1 - minHitRate)* numPose)+ S,其中S是可以被识别为背景的vec文件马上。我希望它
可以帮助你创建正确大小的vec文件,并选择正确的numPos
值。


它为我工作。我也有同样的问题,我是按照关于HAAR培训的着名教程,但想尝试新的培训实用程序
-npos 7000 -nneg 2973



所以我做了下面的计算:



vec文件包含> =(numPos +(numStages-1)*(1 - minHitRate)* numPos)+ S


7000> = +(20-1)*(1-0.999)* numPos)+ 2973



(7000 - 2973)/(1 + 19 * 0.001)> = numPos

numPos <= 4027 / 1.019



numPos <= 3951〜〜3950


并使用:


-npos 3950 -nneg 2973


它工作。我也注意到,其他人也在减少numPos的成功:这里


I am trying to train a haar-like classifier for pedestrians in OpenCV using 3340 positive images and 1224 negative images. (in a .txt file I keep the negative image names i.e negatives(1).bmp, and in a txt file I keep the positives i.e. picture(1).bmp 1 0 0 64 128. Actually positive examples are already cropped images of pedestrians so I only need specify one positive sample per image).

At some point during the training process it stops and says :

"Opencv Error: Assertion failed (elements_read==1)in unknown function, file c:\path\cvhaartraining.cpp, line 1858"

Any ideas as to what is causing this ?

解决方案

this issue was answered by creater of the utility on the OpenCV DevZone site in June 2012.

To quote Maria:

The problem is that your vec-file has exactly the same samples count that you passed in command line -numPos 979. Training application used all samples from the vec-file to train 0-stage and it can not get new positive samples for the next stage training because vec-file is over. The bug of traincascade is that it had assert() in such cases, but it has to throw an exception with error message for a user. It was fixed in r8913. -numPose is a samples count that is used to train each stage. Some already used samples can be filtered by each previous stage (ie recognized as background), but no more than (1 - minHitRate) * numPose on each stage. So vec-file has to contain >= (numPose + (numStages-1) * (1 - minHitRate) * numPose) + S, where S is a count of samples from vec-file that can be recognized as background right away. I hope it can help you to create vec-file of correct size and chose right numPos value.

It worked for me. I also had same problem, I was following the famous tutorial on HAAR training but wanted to try the newer training utility with -npos 7000 -nneg 2973

so i did following calcs:

vec-file has to contain >= (numPos + (numStages-1) * (1 - minHitRate) * numPos) + S

7000 >= (numPos + (20-1) * (1 - 0.999) * numPos) + 2973

(7000 - 2973)/(1 + 19*0.001) >= numPos

numPos <= 4027/1.019

numPos <= 3951 ~~ 3950

and used:

-npos 3950 -nneg 2973

It works. I also noticed that others have also had success with reducing numPos : here

这篇关于哈尔训练OpenCV断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆