Opencv provides the pedestrain detection class.
CV: definitions of parameters of the hogdescriptor class constructor:
Cv_wrap hogdescriptor (): winsize (64,128), // detect window blocksize (16, 16), // block size blockstride (8, 8), // Slide Step cellsize (8, 8) of overlap block ), // cell size nbins (9), // Number of bin in the histogram derivaperture (1), // winsigma (-1 ), // perform Gaussian weighted histogramnormtype (hogdescriptor: l2hys) on the window, // histogram normalization type l2hysthreshold (0.2 ), // L2-norm followed by clipping (limiting the maximum values of V to 0.2) and renormalising gammacorrection (true), // Gamma Correction, removing illumination effects nlevels (hogdescriptor: default_nlevels) // number of layers
The following two sections of code use the hog Pedestrian detection class in opencv to detect pedestrians in static images.
1) The detect window is 64*128 (in pixels ).
// Hog-based Pedestrian detection // Author: www.icvpr.com // blog: http://blog.csdn.net/icvpr # include <iostream> # include <opencv2/opencv. HPP> int main (INT argc, char ** argv) {CV: mat image = CV: imread ("test.bmp"); If (image. empty () {STD: cout <"read image failed" <STD: Endl;} // 1. define the hog object CV: hogdescriptor hog; // use the default parameter // 2. set SVM classifier hog. setsvmdetector (CV: hogdescriptor: getdefaultpeopledetector (); // uses a trained Pedestrian detection classifier. // 3. test the pedestrian area STD: vector <CV: rect> regions; hog. detectmultiscale (image, regions, 0, CV: size (8, 8), CV: size (32, 32), 1.05, 1); // display for (size_t I = 0; I <regions. size (); I ++) {CV: rectangle (image, regions [I], CV: Scalar (0, 0, 255), 2);} CV :: imshow ("Hog", image); CV: waitkey (0); Return 0 ;}
Pedestrian detection experiment results:
2) The detect window is 48*96 (in pixels ).
// Hog-based Pedestrian detection // Author: http://blog.csdn.net/icvpr # include <iostream> # include <opencv2/opencv. HPP> int main (INT argc, char ** argv) {CV: mat image = CV: imread ("test.bmp"); If (image. empty () {STD: cout <"read image failed" <STD: Endl;} // 1. defines the hog object CV: hogdescriptor hog (CV: size (48, 96), CV: size (16, 16), CV: size (8, 8 ), CV: size (8, 8), 9, 1,-1, CV: hogdescriptor: l2hys, 0.2, true, CV: hogdescriptor: default_nlevels ); // 2. set SVM classifier hog. setsvmdetector (CV: hogdescriptor: getdaimler1_ledetector (); // uses a trained Pedestrian detection classifier. // 3. test the pedestrian area STD: vector <CV: rect> regions; hog. detectmultiscale (image, regions, 0, CV: size (8, 8), CV: size (32, 32), 1.05, 1); // display for (size_t I = 0; I <regions. size (); I ++) {CV: rectangle (image, regions [I], CV: Scalar (0, 0, 255), 2);} CV :: imshow ("Hog", image); CV: waitkey (0); Return 0 ;}
Pedestrian detection experiment results:
Related content: www.icvpr.com
--------------------------------------------------------
<Reprint Please note: http://blog.csdn.net/icvpr>