opencv_traincascade总是卡住 [英] opencv_traincascade always gets stuck

查看:652
本文介绍了opencv_traincascade总是卡住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OpenCV的opencv_traincascade生成Haar级联.到目前为止,出于测试目的,我有87个独特的正样本和39个负样本.我使用opencv_createsamples生成了.vec文件,该文件运行良好.当我运行opencv_traincascade时,无论我如何更改参数,它总是在几个阶段后卡住.我的电话看起来像这样:

I am trying to use OpenCV's opencv_traincascade to generate a Haar Cascade. So far I have 87 distinctive positive samples and 39 negative samples for testing purposes. I generated the .vec file with opencv_createsamples, which worked fine. When I'm running opencv_traincascade it always gets stuck after a few stages, no matter how I change the parameters. My call looks like this:

opencv_traincascade -data /opencvimgs/haarcascades/data/ -vec /opencvimgs/haarcascades/out.vec -bg /opencvimgs/haarcascades/neg.txt -numPos 87 -numNeg 39

我尝试增加和减少minHitRate和maxFalseAlarmRate以及numPos和numNeg都没有成功.它可能会运行几个阶段,但随后似乎再次陷入无限循环.我该如何解决?

I tried increasing and decreasing minHitRate and maxFalseAlarmRate as well as numPos and numNeg without any success. It might run for a few more stages but then it seems to hang in an infine loop again. How can I resolve this?

下面的输出是程序写入控制台的内容:

The output below is what the programm writes to the console:

opencv_traincascade -data /opencvimgs/haarcascades/data/ -vec 
/opencvimgs/haarcascades/out.vec -bg /opencvimgs/haarcascades/neg.txt -numPos 87 -numNeg 39
PARAMETERS:
cascadeDirName: /opencvimgs/haarcascades/data/
vecFileName: /opencvimgs/haarcascades/out.vec
bgFileName: /opencvimgs/haarcascades/neg.txt
numPos: 87
numNeg: 39
numStages: 20
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: HAAR
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 1
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 0.0697674
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 0.00945455
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 0.000326907
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 4-stage =====
<BEGIN
POS count : consumed   87 : 87

推荐答案

一个可能的答案是您使用的负样本太少. 阅读OpenCV文档中的说明以及Viola和Jones的参考文件. 他们使用级联分类器,通过每次消除部分负样本来实现高精度和低误报.如果您使用的负样本数量太少,那么它首先会破坏级联分类器的目的. 请注意,对于实际使用,该系统不带脸的图像比带脸的图像要多得多.

A possible answer is that you're using too few negative samples. Read the instruction from OpenCV documents and reference paper from Viola and Jones. They are using cascaded classifier to achieve high accuracy and low false alarms by eliminate part of the negative samples each time. If you are using too few negative samples, it defeat the purpose of the cascaded classifier in the first place. Notice that, for practical use, the system have much much more images without faces than with faces.

这篇关于opencv_traincascade总是卡住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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