Blurry faces in open CV2 face detection

883 views Asked by At

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.

2

There are 2 answers

1
sefiks On BEST ANSWER

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.

1
Programming Py On

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.....