Target Detection program Development (IV.)--Target detection

Source: Internet
Author: User

Met a good "OpenCV introductory tutorial" http://www.opencv.org.cn/forum.php?mod=viewthread&tid=33549

An introduction to the operations that contain the matrix classes and their memory management

And the operation of reading and writing images and videos.


An example

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace CV;
int main () {

	
	cascadeclassifier classifier;//classifier
	classifier.load ("E:\\training\\result\\cascade.xml");// Load classifier

	Mat img = imread ("E:\\training\\result\\1.jpg", 0);//The image to be detected, 0 to convert to grayscale figure
	
	vector<rect> faces;// Save the rectangle of the identified target
	//The last two parameters are the minimum size and maximum size of the scan window
	Classifier.detectmultiscale (IMG, faces, 1.1, 2, 0 | Cv_haar_scale_image, Size (+));
	if (Faces.empty ()) {
		imshow ("Test", IMG);

		Waitkey (0);
		return 0;
	}
	else{
		//mark the Recognized object//
		Compute Center Point
		Center (faces[0].x + FACES[0].WIDTH/2, faces[0].y + FACES[0].HEIGHT/2); c19/>//draws the ellipse
		ellipse (IMG, center, Size (Faces[0].width, faces[0].height),
			0, 255, 0, Scalar (0), 1, 1); c22/>//Display picture
		imshow ("Test", IMG);

		Waitkey (0);
		return 0;
	}
	
}

Detectmultiscale This method is very slow,,, scan again I use 50x50 only scan 1 times have to 1s time, basically not reach the application requirements, should consider the actual situation of the problem, self-rewriting the method of detection, such as more accurately limit the size of the scan window, narrow the scope of the scan, Do parallel scanning and so on optimization measures.

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.