简体   繁体   English

OpenCV 2.4.9-层叠问题

[英]OpenCV 2.4.9 - Traincascade problems

I use OSX 10.11. 我使用OSX 10.11。 I'm new to opencv and I'm trying to train a simple (and surely weak) cascade classifier to detect an object. 我是opencv的新手,我正在尝试训练一个简单的(肯定是弱的)级联分类器来检测对象。 I have already read several answers, posts, guide, docs and tutorials about cascade classifier but I have some problems. 我已经阅读了有关级联分类器的几个答案,帖子,指南,文档和教程,但是我有一些问题。 I referred to this guide: 我参考了本指南:

guide 指南

That follow opencv doc. 遵循opencv doc。 Now I have 8 jpg with my interest object and 249 background images (I know that it's a poor dataset but it's only an attempt). 现在,我的兴趣对象有8个jpg图像和249个背景图像(我知道这是一个糟糕的数据集,但这只是一次尝试)。

When I call opencv_createsamples I noticed the author of guide generate 1500 samples and also I do it. 当我调用opencv_createsamples时,我注意到指南的作者生成了1500个样本,并且我也这样做了。 It means that generate 1500 samples from my 8 positive images? 这意味着可以从我的8张正像中生成1500个样本?

perl bin/createsamples.pl positives.txt negatives.txt samples 1500 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

Note that in sample folder I have only 7 img*.jpg.vec file. 请注意,在示例文件夹中,我只有7 img * .jpg.vec文件。 They would not be 1500? 他们不会是1500吗? After when I call: 当我打电话后:

g++ `pkg-config --libs --cflags opencv` -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp cvhaartraining.cpp -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

I have some errors because missing "OpenCL" "AppKit" "QuartzCore" "QTKit" "Cocoa". 我有一些错误,因为缺少“ OpenCL”,“ AppKit”,“ QuartzCore”,“ QTKit”,“ Cocoa”。 Where I can retrieve these? 我在哪里可以找到这些? However I'm tried to continue and I generate samples.vec file. 但是,我尝试继续操作,并生成了samples.vec文件。

find ./samples -name '*.vec' > samples.txt ./mergevec samples.txt samples.vec

Finally I train my classifier with this code: 最后,我用以下代码训练分类器:

opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 1000 -numNeg 249 -featureType LBP -w 80 -h 40 -precalcValBufSize 2048 -precalcIdxBufSize 4096

After read some posts I've choosen -numPos smaller than 1500 samples previously generated (but where are they?). 阅读一些帖子后,我选择了-numPos小于以前生成的1500个样本(但是它们在哪里?)。 When I start the training, the one stuck in this situation: 当我开始训练时,一个人陷入了这种情况:

终奌站

What I learnt when I tried to follow the same (and other) tutorial: 当我尝试遵循相同(和其他)教程时所学的内容:

  • Yes, createsamples turns a single positive into many. 是的,createsamples将一个正数变成许多正数。 The *.vec file contains many of them in one file. * .vec文件在一个文件中包含许多文件。 If you display the *.vec file using opencv_createsamples, you can page through them with arrow keys (I think). 如果使用opencv_createsamples显示* .vec文件,则可以使用箭头键在它们之间进行分页(我认为)。

  • You need the mergevec program, it combines all *.vec files into one, which is needed for training. 您需要mergevec程序,它将所有* .vec文件合并为一个文件,这是培训所必需的。 I'm using Windows, so I have no idea how to get the mac stuff. 我正在使用Windows,所以我不知道如何获取Mac资料。

  • The output of the opencv_traincascade seems to indicate it found a thousand images in samples.vec. opencv_traincascade的输出似乎表明它在samples.vec中找到了一千个图像。 If you don't have mergevec, I assume you are using a prebuild samples.vec file. 如果您没有mergevec,我假设您使用的是prebuild samples.vec文件。

  • What do you mean by "stuck in this situation"? “卡在这种情况下”是什么意思? No more output, but no crash? 没有更多的输出,但是没有崩溃? Sometimes, training takes hours. 有时,培训需要几个小时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM