The hog and SVM methods are already very classic and widely used in a variety of industries and integrated into hardware. It should be said that as an important method of motion detection, it is still widely used. (Opencv built-in classifier) int main () {mat src = imread ("1.png"); hogdescriptor hog; // hog Feature Detector hog. setsvmdetector (hogdescriptor: getdefaultpeopledetector (); // sets SVM classifier as the default parameter vector <rect> found, found_filtered; // an array of rectangular boxes hog. detectmultiscale (SRC, found, 0, size (8, 8), size (32, 32), 1.05, 2); // perform multi-scale cout detection on the image <"Number of rectangles: "<found. size () <Endl; // locate all rectangle frames without nesting R, and put them in found_filtered. If nested, put the largest rectangle outside into found_filtered. For (INT I = 0; I <found. size (); I ++) {rect r = found [I]; Int J = 0; For (; j <found. size (); j ++) if (J! = I & (R & found [J]) = r) break; If (j = found. size () found_filtered.push_back (r);} cout <"Number of rectangles after filtering:" <found_filtered.size () <Endl; // draws a rectangle, because the rectangular frame detected by hog is slightly larger than the actual body frame, you need to make some adjustments here (INT I = 0; I <found_filtered.size (); I ++) {rect r = found_filtered [I]; R. X + = cvround (R. width * 0.1); R. width = cvround (R. width * 0.8); R. Y + = cvround (R. height * 0.07); R. height = cvround (R. height * 0.8); rectangle (SRC, R. tl (), R.br (), scalar (0,255, 0), 3);} imwrite ("imgprocessed.jpg", Src); namedwindow ("src", 0 ); imshow ("src", Src); waitkey (); // Note: waitkey must be added after imshow; otherwise, the image system ("pause") cannot be displayed ");} what is embodied here is mainly the usage of the classifier that has been successfully used. In this hog & SVM, it is most important to find the correct hog feature and identify the correct SVM. The effect is very general.
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.