您的位置:首页 > 大数据 > 人工智能

opencv Haartraining

2016-07-26 11:19 393 查看
如何利用OpenCV自带的haar training程序训练分类器 - 计算机视觉小菜鸟的专栏 - 博客频道 - CSDN.NET  http://blog.csdn.net/carson2005/article/details/8171571

基于opencv的haar算法以人脸识别为例的训练分类器xml的方法 - - 博客频道 - CSDN.NET  http://blog.csdn.net/tender8888/article/details/7278091

opencv haar+adaboost使用心得 . - liulina603的专栏 - 博客频道 - CSDN.NET  http://blog.csdn.net/liulina603/article/details/8197889

参考了以上几篇博客

1、自己编译了opencv application下的opencv_haartraining,勾选了OpenMp选项vs--->project-->properties-->c++-->language-->OpenMp support 

2、提取的正样本样本总共6729,负样本315张图片,参考使用心得这篇文章,输入opencv_haartraining.exe -data xml -vec pos.vec -bg neg\neg.txt -w 20 -h 20 -mem 1024 -npos 6729 -nneg 6729 -nstages 22 出错。OpenCV
Error: Assertion failed (elements_read == 1) in unknown function, file ..\..\..\..\opencv\apps\haartraining\cvhaartraining.cpp, line 1859  

别人也遇到这个问题,c++ - haar training OpenCV assertion failed - Stack Overflow  http://stackoverflow.com/questions/10863560/haar-training-opencv-assertion-failed

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.

所以我的npos 跟 nneg过大,应参考上面这个公式。vec-file has to contain >= (numPos + (numStages-1) * (1 - minHitRate) * numPos)
+ S

重新训练:opencv_haartraining.exe -data xml -vec pos.vec -bg neg\neg.txt -w 20 -h 20 -mem 1024 -npos 3000 -nneg 315 -nstages 22
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: