【openCV】使用opencv_traincascade.exe 遇到的问题

iwill_chyw 2013-03-11 01:50:01
各位高人

想用opencv_traincascade.exe 训练自己的XML, 简要步骤如下

1, createsamples
其中使用的posNum 5709, negNum 4381, 其中所有的pos, neg的大小都是 20*20
训练出来的vec data大小有 4464 KB

2, 第一次使用 opencv_traincascade.exe -data D:\traincascade -vec D:\data\pos.vec -bg D:\bg.txt -numPos 5709-numNeg 4381 -numStages 22 -precalcValBufSize 200 -precalcIdxBufSize 1000 -featureType LBP -w 20 -h 20, 会有有一个断言失败,opencv_traincascade.exe OpenCV Error: Assertion failed (elements_read == 1)

之后我将相应的numPos 调小至 5000, numNeg 调至4350, 断言消失,很快就会产生7 个parenet Node, 但在第8个stage, 一直就停住了, 跑了2天还是如此

不知道具体的原因是什么? 求解? 多谢各位
或者说createsamples中的numpos, 与negNum 的值与traincascade 中的对应的值有什么关系? 比例是怎么样的
...全文
6004 25 打赏 收藏 举报
写回复
25 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
LHY_045 2015-03-02
楼主您问题解决了吗?我现在一输入opencv_traincascade -data dt -vec train.vec -bg bg.txt -numPos 1500 -numNeg 3000 -w 120 -h 120的语句就报错,不知为何。
  • 打赏
  • 举报
回复
hangzadfg 2014-12-08
-numPos参数指定的是在一个stage中使用的正样本个数,并不是全部正样本个数
  • 打赏
  • 举报
回复
上岸の鱼 2014-11-04
引用 22 楼 a6670369 的回复:
[quote=引用 6 楼 cjnaning 的回复:] 这是我在网上搜到的正解: 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. It worked for me. I also had same problem, I was following the famous tutorial on HAAR training but wanted to try the newer training utility with -npos 7000 -nneg 2973 so i did following calcs: vec-file has to contain >= (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 and used: -npos 3950 -nneg 2973 It works.
这些话是什么意思啊,我看不懂,,,我总是有这个错误Traincascade Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.,知道怎么解决么[/quote] 这句话是说:最可能的原因是你的样本数量不够。
  • 打赏
  • 举报
回复
小ks强 2014-08-29
引用 6 楼 cjnaning 的回复:
这是我在网上搜到的正解: 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. It worked for me. I also had same problem, I was following the famous tutorial on HAAR training but wanted to try the newer training utility with -npos 7000 -nneg 2973 so i did following calcs: vec-file has to contain >= (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 and used: -npos 3950 -nneg 2973 It works.
这些话是什么意思啊,我看不懂,,,我总是有这个错误Traincascade Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.,知道怎么解决么
  • 打赏
  • 举报
回复
小ks强 2014-08-29
引用 20 楼 woaipaoche 的回复:
同志,有没有opencv_traincascade.exe给我一份,发到我邮箱xinxueab@163.com,我的是opencv2.4.6版本怎么安装后找不到呢?跑到哪里去了呢??、、、
我给你发了,记得接收
  • 打赏
  • 举报
回复
天使之一 2014-08-14
同志,有没有opencv_traincascade.exe给我一份,发到我邮箱xinxueab@163.com,我的是opencv2.4.6版本怎么安装后找不到呢?跑到哪里去了呢??、、、
  • 打赏
  • 举报
回复
思飞工作室 2014-08-13
引用 12 楼 a201c501ys 的回复:
opencv_haartraining.exe 训练某一层停住时需要更新负样本,按ctrl+c 输入y停止,换新的相同数量的负样本就行了,已经训练成功几次了。
具体怎么个换法??
  • 打赏
  • 举报
回复
blueink_200451 2014-06-29
  • 打赏
  • 举报
回复
这个当时 我在后面加了 —stages 4,我在第6层卡住了,因此只让前5层生成的强分类器(0,1,2,3,4)生成XML文件,但是对于那种不卡住的,系统自动生成xml的,我也没有弄出来
  • 打赏
  • 举报
回复
既然没有认错的样本了,那为什么卡主,全部分类正确后,应该正常退出啊
  • 打赏
  • 举报
回复
我也遇到了同样的问题,一星期了,有解决的吗?非常感谢
  • 打赏
  • 举报
回复
蓝色的杯子 2014-04-14
楼主没有加源码调么,这些小问题你一调就知道了。停止没反应是木有认错的负本了
  • 打赏
  • 举报
回复
蓝色的杯子 2014-04-08
断言是样本太少了,我们的没有并行,要训练3天
  • 打赏
  • 举报
回复
a201c501ys 2014-04-06
opencv_haartraining.exe 训练某一层停住时需要更新负样本,按ctrl+c 输入y停止,换新的相同数量的负样本就行了,已经训练成功几次了。
  • 打赏
  • 举报
回复
mdq_123 2014-03-13
楼主,负样本是怎么做呢?直接在网上随便找些图片?
  • 打赏
  • 举报
回复
meng1991zhong 2014-02-27
楼主 不好意思打扰了 为什么我找不到opencv_traincascade.exe呢?我用的是OPENCV2.4.3
  • 打赏
  • 举报
回复
andyboliu 2013-09-02
读取或处理到了没有数据的内存,看一下读取或者处理的图像大小,数目设置哪里超出了实际值。
  • 打赏
  • 举报
回复
天使之一 2013-08-20
很遗憾的说我也遇到这个问题,出现了断言失败,错误地点在opencv/modules/core/src/arithm。cpp中 2841行
  • 打赏
  • 举报
回复
heathyhuhu 2013-08-14
为什么我的总是报那个nullpointer 的 Null pointer (NULL filename) in unknown function, file ..\..\..\src persistence 2603 错误,这个命令下的参数是严格按照参考文件来的,为什么会报错???在线急等啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊!
  • 打赏
  • 举报
回复
cjnaning 2013-05-07
这是我在网上搜到的正解: 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. It worked for me. I also had same problem, I was following the famous tutorial on HAAR training but wanted to try the newer training utility with -npos 7000 -nneg 2973 so i did following calcs: vec-file has to contain >= (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 and used: -npos 3950 -nneg 2973 It works.
  • 打赏
  • 举报
回复
加载更多回复(5)
相关推荐
发帖
机器视觉

4308

社区成员

图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
帖子事件
创建了帖子
2013-03-11 01:50
社区公告
暂无公告