The road of OPENCV practice--Pedestrian detection

Source: Internet
Author: User

Pedestrian detection is a very hot and useful topic in the field of vision, especially in unmanned driving, the importance of pedestrian detection is self-evident.

After the face detection, pedestrian detection is much simpler. The process is roughly the same as face detection, where the classifier is loaded first and then the multi-scale detection is performed. Just lazy don't repeat it. Interesting to see face detection of this article: OpenCV Practice Road-face Detection (C++/python)

Here we just put the code here, and there are a few lines, and there are comments:

#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/gpu/ gpu.hpp>//#include <stdio.h>using namespace cv;int main (int argc, char** argv) {Mat img;vector<rect> people;img = Imread ("xingren.jpg", 1);//define the Hog object, take the default parameters, or set the Hogdescriptor defaulthog;//(Cv::size (64, 128) in the following format, Cv::size (+), Cv::size (8, 8),//cv::size (8, 8), 9, 1,-1,//cv::hogdescriptor::l2hys, 0.2, True,//cv::hogdescriptor:: Default_nlevels);//Set the SVM classifier with the default classifier Defaulthog.setsvmdetector (Hogdescriptor::getdefaultpeopledetector ());// Multi-scale pedestrian detection of the image, the result is a rectangular box Defaulthog.detectmultiscale (IMG, people,0,size (8,8), Size (0,0), 1.03,2);//Draw Rectangle, Box traveler for (int i = 0; I < people.size (); i++) {Rect r = People[i];rectangle (IMG, r.tl (), R.Br (), Scalar (0, 0, 255), 3);} Namedwindow ("Pedestrian Detection", cv_window_autosize), imshow ("Detection of Pedestrians", IMG), Waitkey (0); return 0;}


As follows:




The road of OPENCV practice--Pedestrian detection

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.