@@ -54,7 +54,7 @@ <h3><a name="Examples"></a> Examples</h3>
5454 < li > < a href ="#haar_setup "> Haar setup</ a > </ li >
5555 < li > < a href ="#hog_setup "> HOG setup</ a > </ li >
5656 < li > < a href ="#dnn_setup "> DNN setup</ a > </ li >
57-
57+ < li > < a href =" #haar_train " > Haar Model Training </ a > </ li >
5858 < p > </ p >
5959 < p > </ p >
6060 </ ul >
@@ -309,6 +309,50 @@ <h3><a name="dnn_setup"></a>DNN setup</h3>
309309
310310 </ ul >
311311
312+ < h3 > < a name ="haar_train "> </ a > Haar Model Training</ h3 >
313+ < ul >
314+ The OpenCV documentation is the definitive source for instructions on how to train
315+ a Haar model. This brief introduction only provides a few scripts that may be
316+ helpful in using MotionPlus to get positive and negative images to feed into the
317+ training process.
318+ < br >
319+ < br > Start with creating positive images movie as input file.
320+ < br > Run with picture_output_motion roi
321+ < br > Remove any pictures that are not desired.
322+ < br > Run the script to create the positive file list
323+ < br > Run while in the directory with the positive images.
324+ < small > < code > < ul >
325+ opencv_createsamples -vec posfiles.vec -info poslist.txt -num 350 -h 96 -w 96
326+ </ ul > </ code > </ small >
327+ Next get a sample file that does not have desired positives.
328+ < br > Change to picture_output on and turn off motion roi
329+ < br > Change threshold to tiny number and run to create negatives
330+ < small > < code > < ul >
331+ opencv_traincascade -data ./model -vec ./pos/posfiles.vec -bg neglist.txt -numPos 350 -numNeg 325
332+ </ ul > </ code > </ small >
333+ The following are the simple scripts to create positive and negative list files for training
334+ < small > < small > < code >
335+ < ul >
336+ !/bin/bash
337+ < br > FILES=./pos/*.jpg
338+ < br > for FULLNAME in $FILES
339+ < br > do
340+ < br > HW=$(identify -format '%w %h' $FULLNAME)
341+ < br > printf "$FULLNAME 1 0 0 $HW \n" > > poslist.txt
342+ < br > done
343+ </ ul >
344+ < ul >
345+ < br > !/bin/bash
346+ < br > FILES=./neg/*.jpg
347+ < br > for FULLNAME in $FILES
348+ < br > do
349+ < br > printf "$FULLNAME \n" > > neglist.txt
350+ < br > done
351+ </ ul >
352+ </ code > </ small > </ small >
353+
354+ </ ul >
355+
312356
313357 </ section >
314358 </ body >
0 commit comments