From: http://www.opencv.org.cn/forum/viewtopic.php? F = 1 & t = 9146 # p35176
//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ////////////////////////
How to create training samples
This section analyzes the original author's dataset and describes how to create a training sample based on some online materials.
1. How to generate samples from the original image
Compared with inriaperson \ train \ pos (original image), inriaperson \ train_64x128_h96 \ pos (sample generation), we can find that the author cropped some standing persons from the original image, the left-right reflect of the cropped image is required not to be blocked. Take the first image as an example: crop001001. It cut two unblocked people, added the original photo, a total of three images, plus the left and right images, a total of six images.
2. Cropping
You can crop and save the image per program based on opencv1.0. The file name is automatically generated and saved in the newly generated image per folder in the same path.
3. Change the image size
You can use ACDSee software, tools/open in editor, and then select the resize option. Tools/rotate can also implement left-right reflect.
4. Create the POs. lst list to go To the DOS interface, locate the image folder to be created, and enter DIR/B> pos. lst to generate the file list;
After carefully analyzing the compute function in cvhop. cpp, you can directly call it to obtain the sample hog, and then train it to obtain the detection operator.
1. Create a sample
2. Call each image
Hog. Compute (IMG, descriptors, size (8, 8), size (0, 0 ));
Generate hog descriptors and save it to the file.
For (Int J = 0; j <3780; j ++)
Fprintf (F, "% F,", descriptors [J]);
3. Use SVM for training and classification to obtain the weight coefficient, that is, the detection operator detector called in the getdefapeoppeopledetector () function []