Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Face & Facial Features cropping using openCV in IOS

Hello ,

I am developing the project where I am detecting Face and facial features and crop the features and Overlap on to the object.

Heretofore i have done detecting the Face,eyes and Mouth , My next step is to crop the face,eyes and Mouth.

Problem: While cropping the Face, I am assigning the region (Rect ) from where i get using haarcascade. I will then draw the rectangle on to the real image, till here everything goes fine . but during the cropping when i assign same region , I won't get the exact Face region .

Here is the code for detecting and getting sub image.

 for (int i = 0; i < faces.size(); i++)
    {
        cv::Point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
        cv::Point pt2(faces[i].x, faces[i].y);
        cv::rectangle(image, pt1, pt2, cvScalar(0, 255, 0, 0), 1, 8 ,0);
        cv::Rect myROI(faces[i].x, faces[i].y, faces[i].width,  faces[i].height );
        Mat subImage(grayscaleFrame, myROI);

       if(!subImage.empty()){
       UIImage * image1=  [self UIImageFromCVMat:subImage];

  }

Here you can see the image : http://i.stack.imgur.com/YkaQK.png

Please suggest me where i am going wrong in the code .

Thanks

Face & Facial Features cropping using openCV in IOS

Hello ,

I am developing the project where I am detecting Face and facial features and crop the features and Overlap on to the object.

Heretofore i have done detecting the Face,eyes and Mouth , My next step is to crop the face,eyes and Mouth.

Problem: While cropping the Face, I am assigning the region (Rect ) from where i get using haarcascade. I will then draw the rectangle on to the real image, till here everything goes fine . but during the cropping when i assign same region , I won't get the exact Face region .

Here is the code for detecting and getting sub image.

 for (int i = 0; i < faces.size(); i++)
    {
        cv::Point pt1(faces[i].x + faces[i].width, faces[i].y + faces[i].height);
        cv::Point pt2(faces[i].x, faces[i].y);
        cv::rectangle(image, pt1, pt2, cvScalar(0, 255, 0, 0), 1, 8 ,0);
        cv::Rect myROI(faces[i].x, faces[i].y, faces[i].width,  faces[i].height );
        Mat subImage(grayscaleFrame, myROI);

       if(!subImage.empty()){
       UIImage * image1=  [self UIImageFromCVMat:subImage];

  }

Here you can see the image : http://i.stack.imgur.com/YkaQK.png

Please suggest me where i am going wrong in the code .

Thanks