I use 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. I have already read several answers, posts, guide, docs and tutorials about cascade classifier but I have some problems. I referred to this guide:
That follow 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).
When I call opencv_createsamples I noticed the author of guide generate 1500 samples and also I do it. It means that generate 1500 samples from my 8 positive images?
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. They would not be 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". Where I can retrieve these? However I'm tried to continue and I generate samples.vec file.
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?). 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. The *.vec file contains many of them in one file. If you display the *.vec file using opencv_createsamples, you can page through them with arrow keys (I think).
You need the mergevec program, it combines all *.vec files into one, which is needed for training. I'm using Windows, so I have no idea how to get the mac stuff.
The output of the opencv_traincascade seems to indicate it found a thousand images in samples.vec. If you don't have mergevec, I assume you are using a prebuild samples.vec file.
What do you mean by "stuck in this situation"? No more output, but no crash? Sometimes, training takes hours.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.