Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
So, I wrote this code for face detection in webcam and it works perfectly for me.So, i thought how about i modify the code and use it for static images to detect faces in the image.
But unfortunately its not working for me. So, can anyone correct my mistake. Here is my code.

CascadeClassifier face_cascade;
face_cascade.load("C:/opencv/sources/data/haarcascades/haarcascade_frontalface_alt.xml");
if(!face_cascade.load("C:/opencv/sources/data/haarcascades/haarcascade_frontalface_alt.xml"))

{
return 1;
}

namedWindow("outputimage",1);

asp = imread("leena.JPG");

std::vector<rect> faces;

face_cascade.detectMultiScale(asp,faces,1.1,5,CV_HAAR_FIND_BIGGEST_OBJECT|CV_HAAR_SCALE_IMAGE,Size(30,30));


for(int i = 0 ; i<faces.size();i++)>
{
Point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
Point pt2(faces[i].x, faces[i].y);

rectangle(asp,pt1,pt2,cvScalar(0,255,0,0),1,0,0);
}

imshow("outputimage",asp);
Posted
Comments
KarstenK 15-Jul-14 6:41am    
you wont get an answer. You must figure out what your code does - and what not.

I would call it "debugging" and it is my every day work :-O

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900