Ask Your Question

Crop Face Region from Detected Face

asked 2014-12-28 23:58:15 -0600

orochi gravatar image


I'm currently developing an application for face detection and augmented reality using OpenCV and Java. I need to crop out the face region from detected face. I have done detecting the face using haarcascade.

My problem is, when i cropping the face using submat and assigning the region (Rect ) that i get using haarcascade, it didnt give me the desired result. Using submat i get rectangle area around the face (including some of the background, hair, ears) meanwhile i only want face region (including forehead and chin, without ears and head).

I've tried using suggestion from here and here

but i still didnt get the desired result.

Please suggest me how to get exact face region, any article or tutorial.


edit retag flag offensive close merge delete


I guess this isn't possible out of the box, since the detections aren't perfect. You'll need to fit a face model to it to get only the facial parts.

Guanta gravatar imageGuanta ( 2014-12-29 07:06:19 -0600 )edit

hi @Guanta , thanks for the comment. What you mean by i need to fit a face model to get the facial parts?

orochi gravatar imageorochi ( 2014-12-29 08:59:37 -0600 )edit

I thought of ASM (active shape model), apparently there exist also code using openCV:

Guanta gravatar imageGuanta ( 2014-12-29 09:01:25 -0600 )edit

Thanks @Guanta , i'll take a look something similar with ASM but written in java. But if by any chance you found out something else, pls share it. Thanks again @Guanta, really appreciate it

orochi gravatar imageorochi ( 2014-12-29 09:14:01 -0600 )edit

1 answer

Sort by » oldest newest most voted

answered 2014-12-29 09:43:34 -0600

My suggestion is that:

  • Firstly, detect the face region and then, inside the face region, detect the eyes. This process can be done by using cascade classifier of OpenCV (see more at this link-

  • Based on two eyes’s coordinates, proceed the face cropping algorithm. For this end, you can refer to this link- or this link- for further details.

The downside of this approach is that it is heavily depent on the accuracy of face detection and it may not provide the best aligned and cropped face image but it is simple to implement and yet efficient enough since you just want the face region. Hope this helps.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-12-28 23:58:15 -0600

Seen: 3,908 times

Last updated: Dec 29 '14