-
List positive and negative image in text file
- Linux
find ./positive_images -iname "*.jpg" > positives.txt find ./negative_images -iname "*.jpg" > negatives.txt
- Windows
forfiles /s /m *.jpg /c "cmd /c echo @relpath" > positives.txt forfiles /s /m *.jpg /c "cmd /c echo @relpath" > negatives.txt
** Remove quotes in the files.**
** Replace .\ -> ./positive_images/ **
-
Create samples
perl ML/tools/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 50 -h 70"
- Create .vec files from samples
python ML/tools/mergevec.py -v samples/ -o samples.vec
- Train
opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 1000 -numNeg 5 -w 50 -h 70 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024
More information here :