c++ - 运行 TrainCascade.exe 时出错

标签 c++ opencv

当我尝试使用 opencv 的 traincascade.exe 时遇到一个问题,我有 20 个正样本和 100 个负样本。也许,它的样本很少,但我只想测试如何使用 opencv 的 traincascade.exe。

我使用 opencv_createsamples.exe 通过命令创建 vector 文件。

D:\Project_Android\Classifier\bin\opencv_createsamples.exe -info positive.txt -vec vector.vec -num 442 -w 24 -h 24 PAUSE

完成了,我有一个 vector.vec,我也有带绝对方向的 negative.txt。

但是现在,当我将 traincascade.exe 与命令一起使用时

D:\Project_Android\Classifier\bin\opencv_traincascade.exe -data HaarTraining -vec vector.vec -bg negative.txt -npos 10 -nneg 10 -numStages 3 -nsplits 2 -nonsym -minhitrate 0.95 -maxfalsealarm 0.4 -mem 1024 -mode ALL -w 24 -h 24 PAUSE 

它说错误如下图。

enter image description here

所以我决定用命令将 opencv_traincascade.exe 替换为 opencv_haartraining.exe

D:\Project_Android\Classifier\bin\opencv_haartraining.exe -data HaarTraining -vec vector.vec -bg negative.txt -npos 10 -nneg 10 -numStages 3 -nsplits 2 -nonsym -minhitrate 0.95 -maxfalsealarm 0.4 -mem 1024 -mode ALL -w 24 -h 24 PAUSE 

现在它运行了几分钟。

完成后,我在 HaarTraining 文件夹中只看到 8 个文件夹(0,1,2,...),我试图找到 xml 文件但没有看到它,似乎没有生成 xml 文件 enter image description here

所以,请告诉我它有什么问题,我不知道为什么它说 opencv_traincascade.exe 错误并使用 opencv_haartraining.exe 运行但不生成 xml 文件。我确信 positive.txt 和 negative.txt 具有正确的图像绝对方向。

非常感谢你的帮助

最佳答案

首先,不要使用 opencv_haartraining.exe .它现在已被弃用。

要回答您的问题,您的参数应如下所示:

opencv_traincascade.exe -data HaarTraining -vec vector.vec -bg negative.txt -numPos 10 -numNeg 10 -numStages 3 -minHitRate 0.95 -maxFalseAlarmRate 0.4 -mode ALL -w 24 -h 24

至于你的-mem 1024 , -nsplits 2 , 和 -nonsym标志,它们不是 opencv_traincascade.exe 使用的实际参数.最接近你的东西-mem标志可能是 -precalcValBufSize-precalcIdxBufSize .

有关更全面的参数列表,您可以查看 the official documentation .

关于c++ - 运行 TrainCascade.exe 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37903482/

相关文章:

c++ - 如何编写在函数执行过程中收集垃圾的测试用例?

c++ - 如何创建一个用户可以在菜单更改之间不断添加值的 vector ?

android - 从照片opencv中去除眩光

OpenCV Haar 分类器被杀死

opencv - 使用OpenCV进行形状检测

c++ - 在 openCV 中查看 8 位 RAW 图像文件

c++ - "No viable overloaded ' = ' "为什么?

c++ - 在类内部不相关/声明的静态成员函数有什么用?

Android NDK 如何将收到的 DatagramPacket 作为参数传递给 C 函数?

android - opencv和安卓opencv的区别