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);