我正在尝试使用 OpenCV 的 opencv_traincascade 来生成 Haar Cascade。到目前为止,我有 87 个独特的阳性样本和 39 个阴性样本用于测试目的。我用 opencv_createsamples 生成了 .vec 文件,效果很好。当我运行 opencv_traincascade 时,无论我如何更改参数,它总是在几个阶段后卡住。我的电话看起来像这样:
opencv_traincascade -data /opencvimgs/haarcascades/data/ -vec /opencvimgs/haarcascades/out.vec -bg /opencvimgs/haarcascades/neg.txt -numPos 87 -numNeg 39
我尝试增加和减少 minHitRate 和 maxFalseAlarmRate 以及 numPos 和 numNeg 没有任何成功。它可能会运行几个阶段,但随后它似乎再次陷入无限循环。我该如何解决这个问题?
下面的输出是程序写入控制台的内容:
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