gpt4 book ai didi

c++ - haar 训练 OpenCV 断言失败

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:14:44 25 4
gpt4 key购买 nike

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

在训练过程中的某个时候它会停下来并说:

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

关于造成这种情况的原因有什么想法吗?

最佳答案

此问题已由 OpenCV DevZone 网站上的实用程序创建者回答in June 2012.

引用玛丽亚的话:

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.

它对我有用。我也有同样的问题,我正在关注 famous tutorial on HAAR training但想尝试使用更新的培训实用程序-npos 7000 -nneg 2973

所以我做了以下计算:

vec 文件必须包含 >= (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

并使用:

-npos 3950 -nneg 2973

它有效。我还注意到其他人在减少 numPos 方面也取得了成功:here

关于c++ - haar 训练 OpenCV 断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10863560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com