0

I am using Open CV2 face detection in Python. It works very well, but often finds faces that, although they really are faces, are so blurry as to be useless. It succeeds in finding faces that can't be recognized as male or female, adult or child, but still clearly human faces.

Detecting a face that can't be recognized is not a useful result, but I don't know how to programmatically block these results, or determine that they should be ignored.

The only approach I currently have is to ignore any face smaller than a certain threshold, but I still get some large blurry faces.

Any suggestions? I am using the haarcascade_frontalface_alt_tree.xml for detection.

Wasabe
  • 77
  • 1
  • 1
  • 7
  • So you’re not happy that your code is far too good at detecting faces? How is opencv supposed to know the face is useless to you? Seems to me that’s not unlike saying that the face detection should reject faces of people you don’t know - i.e. it up to your code to implement it. Maybe try https://www.pyimagesearch.com/2015/09/07/blur-detection-with-opencv/ on the face region? – DisappointedByUnaccountableMod Sep 06 '20 at 07:30
  • I don't find your comment very useful. Detecting a face with so little detail it looks like it was drawn by a 5 year old is successful face detection, but useless towards the goal of facial recognition. What I had hoped to find was a score that would measure the level of detail in a face, to indicate the possibility of eventually recognizing it. – Wasabe Sep 06 '20 at 14:20

2 Answers2

1

deep learning based facial detectors such as ssd or mtcnn return confidence score as well.

deepface wraps these state-of-the-art face detectors.

#!pip install deepface
from deepface import DeepFace
backends = ['ssd', 'mtcnn']
detected_face = DeepFace.detectFace("img.jpg", detector_backend = backends[0])

Herein, ssd expexts 90% confidence score. That would solve your problem.

johncasey
  • 1,250
  • 8
  • 14
0

If your problem is to detect faces of Male , female or child you need to feed the images of the genders and train your program . It involves a lot of programming , but can be solved easily with opencv. You need to train your model(project) with thousands of images for accuracy.

If you want to detect certain faces only, you need to do the same but train your model with the images of faces you want to detect.....

  • Perhaps my point was not clear. It isn't that I have any interest in determining if a face is male or female, adult or child. I was trying to make the point that DETECTING a face that has so little detail that a human couldn't even tell if it were male/female/adult/child is not useful (to me, at least), since face detection is not the goal - it is just a step towards face recognition. I am looking for a score that would indicate the face has sufficient detail to be recognized. – Wasabe Sep 06 '20 at 14:17