Where can i find the best haar cascades xml for detecting frontal face?

user3883314 picture user3883314 · Aug 4, 2014 · Viewed 14.5k times · Source

I'm using OpenCV to detect face in the pictures that are captured by cameras. But I realized that there are some faces that are no frontal and the eyes don't focus on the camera. Where can i find the haar cascades xml file that just using for frontal face without any leanness and the eyes have to focus on the camera. Does anyone have the xml file like this? Please help me.

Maybe my English is not good. So if you don't understand what i mentioned here. Please let me know, I will changed it to make it more clearly to understand. Hope you help me. Thank you so much.

Answer

marol picture marol · Aug 4, 2014

So my answer is like this: by default OpenCV provides two classifiers for detecting face: frontal and profile one. So if I understood you correctly, you would like to detect face that:

  1. is not necessarily frontal and
  2. eyes does not focus on the camera.

Condition 2 is easily fulfilled with frontal face haar classifier, what means you can just use one that is provided in opencv by default. For condition 1, you can try with profile detector.

Other possibility is to use detectors for other parts of face like ear detector. If you detect an ear, you can imply with good probability that this ear belongs to a profile face you would like to detect.

And my last (but bot least) advice is that when all solutions you try fail, you can try to learn your own haar classifier. That's not a hard task, you can find online (especially here on stackoverflow) much information about it e.g. there

EDIT: (after comment clarifying question):

First let me state your requirements more in numbers, because I don't know what frontal face mean for you in terms of head pose. If you mean frontal as let's say tilt and pan angles belongs in interval [-15; 15] degrees so this resolve the opencv frontal face classificator (those numbers are given approximately by all empirical tests I've done so far). I mean if the face is not frontal, (ie the both eyes or mouth is not visible/partially visible), the classificator will not detect it. In other words, if those angles I've given are okay for you, just use default classificator. If not, see paragraph below.

About second requirement that you demand person to look at camera. Thats's something default classificator is not able to distinguish - it had been learned on various people faces, not only with that ones you would like to achieve. And I'm pretty sure you can hardly find such classificator in the Internet because it's so specific task. But I can assure you that you can try to learn your own face classificator, it might work pretty well. Please let us know if you achieve good results.

EDIT2: (about classificator that detects head only and only if tilt and pan are zero degrees)

I don't think such classificator exists. From my experience, even if it exists, somebody who definitively prepared such classificator for one's purposes did not share it with everyone because it is so specific requirement. And it takes some time to prepare good haar classificator (you need a few hundreds positive examples with faces with pan and tilt zeros cropped manually) so I think that's one way to solve you problem, train your own detector.

Let me suggest another approach and it's about head pose estimation. It's a method to determine all pose angles from face image. There exists many algorithms suitable for your requirements - runtime, person independent which can answer the question whether tilt and pan angles are close to 0. They don't need any kind of learning and can be straight coded from the algorithm description. However, you need some kind of research willing to get into the article, yet I think it might be better idea to implement head pose estimation rather than learning your own haar classifier.

EDIT3: (about head pose estimation)

It's not so complicated task. In my master thesis here I proved one can build real time head pose estimation tracker which is person invariant and robust using only geometric assumptions about position of facial landmarks (both eyes, mouth and nose tip). That gives a head pose estimation immediately. You can also start with this article and there's a summary of the article.