Step 1: Put positive samples, negative samples, opencv_createsamples,opencv_haartraining into a folder below, to facilitate the operation behind.
Step 2: Generate a profile for positive and negative samples
Positive Sample Description file
Find Positive_boosted-iname "*.bmp"-exec Echo \{\} 1 0 0 20 20 \; > Face.info
Generated
Positive_boosted/face00244.bmp 1 0 0 20 20
Positive_boosted/face00177.bmp 1 0 0 20 20
Positive_boosted/face01533.bmp 1 0 0 20 20
Positive_boosted/face01542.bmp 1 0 0 20 20
Positive_boosted/face00733.bmp 1 0 0 20 20
Positive_boosted/face01708.bmp 1 0 0 20 20
Positive_boosted/face01625.bmp 1 0 0 20 20
The pos_image/is the relative pathname, followed by the file name, 1 for a file, 0 0 24 24 for the file's 2 vertex position coordinates. Save Exit is OK.
Negative Sample Description file
Find Negative_boosted-iname *.bmp > Non_face.txt
Generated
Negative_boosted/face01542.bmp
Negative_boosted/face00733.bmp
Negative_boosted/face01708.bmp
Negative_boosted/face01625.bmp
Step 3: Generate VEC files
Opencv_createsamples-vec face.vec-info face.txt-bg non_face.txt-w 20-h 20-num 2429
The-vec is to specify the file name of the following output VEC file,-info Specify a positive sample description file,-BG Specify a negative sample description file, W and H respectively, the width and height of the sample,-num indicates the number of positive samples. After executing the command, a Face.vec file is produced in the current directory.
Step 4: Start training
Create a new XML folder in the current directory to hold the generated. xml file.
Opencv_haartraining-data Xml-vec face.vec-bg non_face.txt-npos 500-nneg 500-w 20-h 20-nstages 20-nsplits 2-minh Itrate 0.999-maxfalsealarm 0.5
Opencv_traincascade (New command)
which
-data is the location of the output XML intermediate file;
-vec Positive Sample file name
-BG Negative Sample file name
-nsplits 1 means using a simple stump classfier classification.
-mode (Default|all) All means that the type of Haar is used in both vertical and angular rotation of 45 degrees; The default is just vertical.
-npos Number of positive samples
-nneg Negative Sample
-minhitrate minimum hit ratio, which is the accuracy of the training target.
-maxfalsealarm Maximum false alarm (false detection rate), each layer of training to this value less than 0.5 when the end of training, into the next level of training
In the actual training, in order to save time, adjust the small Npos,nneg
Generates a xml.xml file that can be tested using the resulting classifier.
Step 5: Merging the XML files generated by the training
Generate multiple
Training of Opencv-haar facial features