c++ - traincascade 训练面部痣检测器

标签 c++ opencv

我正在使用 createsamples.exe 和 traincascade.exe 来训练面部痣检测器。

我使用了 150 张正面图像(人脸图像),其中每张图像包含几颗痣,总共(所有 150 张图像)包含 1452 颗痣;此信息妥善保存在 positive.txt 文件中。我还使用了 1015 张没有痣的皮肤区域负片,这些信息被妥善保存在 negative.txt 文件中。

为了创建正样本,我执行了以下命令行:

createsamples.exe -info positive.txt -vec positive.vec -w 3 -h 7

成功创建了 1000 个样本的正 vector ;我使用 w = 3 和 h = 7,因为正图像中标记的痣和负图像中的皮肤区域非常小。

然后,执行此命令行以最终训练检测器:

traincascade.exe -data result\-vec positive.vec -bg negative.txt -numStages 20 -nsplits 1 -minhitrate 0.998 -maxfalsealarm 0.5 -numPos 150 -numNeg 1015 -w 3 -h 7

我得到了这个:

PARAMETERS:
cascadeDirName: result\
vecFileName: positive.vec
bgFileName: negative.txt
numPos: 150
numStages: 20
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: HAAR
sampleWidth: 3
sampleHeight: 7
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   150 : 150
Train dataset for temp stage can not be filled. Branch training terminated.
Cascade classifier can't be trained. Check the used training parameters.

我不知道会发生什么。请帮助我...

最佳答案

您需要减少-numPos 参数。 -numPos 参数应小于 .vec 文件中的阳性总数。尝试将其设置为 130。

您可能还需要考虑您的 -numStages 参数。你会过度训练你的分类器,因为你只有 150 个阳性。检查这个link有关 traincascade 参数的更多详细信息。

另外,通过运行命令“createsamples.exe -info positive.txt -vec positive.vec -w 3 -h 7”,你会得到一个包含 150 个样本而不是 1000 个样本的 vector 。

关于c++ - traincascade 训练面部痣检测器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29681374/

相关文章:

c++ - PCL 1.8.0 项目的链接器错误

c++ - 在 luabind::object 中存储一个带有父类的 lua 类

c++ - 使用 C++ 解析 robots.txt 文件

algorithm - SURF vs SIFT,SURF 真的更快吗?

python - 错误:调用cv.ShowImage时发生mat.isContinuous()

c++ - cv::add 在 openCV 中不起作用

c++ - while(cin >> x),这里的 bool 值是多少?

java - 降低双线性插值的时间复杂度

java - OpenCV HoughLines 只返回一行

c++ - 校验数字的递归函数