opencv中人眼中心的检测(C++)

#include 
#include 
#include 
#include 

using namespace std;
using namespace cv;


int main(int argc, char** argv)
{

	CascadeClassifier stFaceCascade;
	IplImage *pstImage = NULL;
	std::vector faceRects;

	if( !stFaceCascade.load("D:\\softwares\\opencv\\sources\\data\\haarcascades\\haarcascade_eye_tree_eyeglasses.xml") )
	{
		printf("Loading cascade error\n");
		return -1;
	}

	pstImage = cvLoadImage("C:\\Users\\TheOne\\Documents\\mianbubiaoqig\\jaffeimages\\jaffe\\KA.AN1.39.tiff", CV_LOAD_IMAGE_COLOR);

	stFaceCascade.detectMultiScale(pstImage,
		faceRects,            //检出结果
		1.1,                  //缩放步长
		2,                    //框融合时的最小检出个数
		0|CV_HAAR_SCALE_IMAGE,//标志 |CV_HAAR_FIND_BIGGEST_OBJECT|CV_HAAR_DO_ROUGH_SEARCH|CV_HAAR_DO_CANNY_PRUNING
		Size(30, 30),         //最小人脸尺寸
		Size(300, 300) );     //最大人脸尺寸
	printf("Face Num[%d]\n", faceRects.size());

	for( unsigned int j = 0; j < faceRects.size(); j++ )
	{
		cvLine(pstImage,
			cvPoint(faceRects[j].x + faceRects[j].width/2, faceRects[j].y + faceRects[j].height/2),
			cvPoint(faceRects[j].x + faceRects[j].width/2, faceRects[j].y + faceRects[j].height/2),
			cvScalar(255,0,0),
			2,8,0);
	}
	cvShowImage("FDWin", pstImage);
	cvWaitKey(0);


	cvReleaseImage(&pstImage);
	return 0;
}

你可能感兴趣的:(opencv)