3

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.

user3883314
  • 63
  • 1
  • 3
  • 11
  • If you're not required to use OpenCV, you might consider Dlib which can even be specifically trained to certain objects fairly easily given examples. http://blog.dlib.net/2014/02/dlib-186-released-make-your-own-object.html – NoBugs Jul 08 '16 at 07:05

2 Answers2

5

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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
marol
  • 4,034
  • 3
  • 22
  • 31
  • What I want here is detecting faces that is only frontal face. And the eyes have to focus on the camera. So I will ignore all faces that isn't frontal faces or the eyes don't focus on the camera. Could you give me any suggestion? Thank for your help. – user3883314 Aug 05 '14 at 02:14
  • Is there any haar cascades files which its angles is 0 degree? That means without any tilt and pan. Because our project is a public project, so the cameras will capture too many faces. So we decided that we just capture the faces which are without any tilt and pan, and by this way we can increase the accuracy of face recognition. – user3883314 Aug 06 '14 at 02:26
  • Head pose estimation is a complicated task. Is there anything like this? Input: a face image. Output: The degree of the face. Very thank for your help. – user3883314 Aug 11 '14 at 08:29
  • @user3883314 The third comment approached. – marol Aug 11 '14 at 15:19
  • Do you have these source code? Could you tell me what is the most general method for Head Pose Estimation? And How long will I can finish this thing? Really thank for your help. – user3883314 Aug 12 '14 at 02:58
  • I have, but I need some time to make it publish. I think I will make my portfolio website soon and I will publish code there. I think this is the last comment, beacuse we go off topic. Feel free to contact me if you have more question (LinkedIn) – marol Aug 12 '14 at 09:49
  • @marol could you check the link to your thesis please? – fvildoso Nov 26 '19 at 04:18
0

On the official opencv github page link is here:

https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml

easy to use and quite accurate.

KhanJr
  • 31
  • 2