Opencv _ Pedestrian detection based on Hog features

Source: Internet
Author: User
Tags scalar svm

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.