I am currently working on a python implementation of Adrian Rosebrock's video blink detector with dlib blog post:
https://www.pyimagesearch.com/author/adrian/
Basically, I am using dlib's frontal face detector and passing the bounding box around the face to dlib's landmark detector as seen in this picture:
https://imgur.com/xvkfNeG
Sometimes dlib's frontal face detector doesn't find a face, but other face detectors like OpenCV's do. Adrian's blog made it sound like I could use openCV's frontal face detector and pass the bounding box along instead.
However when I do this the landmark detector can't find the eyes of the person correctly as seen in this photo:
https://imgur.com/3eAFFsQ
Is there way I could use an alternative face detector with dlib's landmark detector? Or am I stuck using dlib's frontal face detector because the bounding box passed by a different face detector will be ever so slightly incorrect for the dlib landmark detector?
Thank you for your time!
Checking the images you are providing it just look like you are not passing the correct parameters to the plotting method. The results look correct, just upside-down.
You can use your own face detector. You just have to use dlib.rectangle() function. First, find the bounding boxes from your face detector and after that map them to dlib.rectangle(x,y,w,h).
Then you can pass the bounding boxes from this list to predictor(img, rect).
Related
I'm using dlib and mediapipe to get facial landmarks arround a face image. My question is about the jittering. In Mediapipe, the researchers advise us to use temporal filter like the one euro filter to reduce the jittering. But I noticed that, in two consecutives frames that are similar, without mouvement, the facial landmarks is not stable. So I observe the detected bounding box arround the face, and it is not stable too. Is it a common solution to stabilized the detected bounding box before the estimation of the facial landmarks?
I do not get perfect accuracy while detecting a face using opencv.
Here is my code:
import cv2
#create a cascadeclassifier object
face_cascade = cv2.CascadeClassifier("C:/Users/yash/AppData/Local/Programs/Python/Python35/Lib/site-packages/cv2/data/haarcascade_frontalface_default.xml")
#create a cascade classifier.it will contain the features of the face
#reading the image as it is
img = cv2.imread("profile.JPG")
#reading the image as gray_scale image
gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #converting colored image to gray scale
#search the co-ordinates of the image
faces = face_cascade.detectMultiScale(gray_img,scaleFactor = 1.05,minNeighbors=5)
#scaleFactor = decreases the shape value by 5%,until the face is found .smaller this value , the greater is the accuracy.
#detectMultiScale = method to search for the face rectangle co-ordinates
#print(type(faces))
#print(faces)
for x,y,w,h in faces:
img = cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),3)
resized_img = cv2.resize(img,(int(img.shape[1]/2) , int(img.shape[0]/2)))
cv2.imshow("face detection",resized_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Here there is the image I am trying to get perfect accuracy on.
For one face use flag CV_HAAR_FIND_BIGGEST_OBJECT as last parameter in detectMultiScale.
But Haar cascades now are not the best choice for face detection. In OpenCV 4.0 developers remove code for Haar cascades training - they recommend to use DNN. For example here.
And second: OpenCV developers created an open source framework for DNN inference - OpenVINO and a lot of pretrained models (for face detection too). If you want to have the fastest face detector on CPU than you need to use OpenVINO.
In addition to #Nuzhny's recommendation, you should use Non Maximum Suppression algorithm to solve the problem of multiple detections.
Pyimagesearch has a very good article along with code on this topic which will help you.
I'm going to use CNNs for face landmark detection.(python and tensorflow)
The problem is images in Helen database have different scales.
I think I cannot just resize or crop images because the data is the positions of images.((x,y) coordinates)
however, I found a lot of papers(CNNs) tested their model with Helen dataset.
Does anyone have idea how to deal with helen dataset?
I really appreciate it.
What I would suggest to do:
detect faces with open-cv (here)
crop bounding box for every face
resize the cropped images to the resolution which is needed for the cnn
I want to detect face from image with low brightness. I'm using dlib for detecting the face from image. But the dlib detector is detecting no face at all. I've the following code to detect faces from image.
detector=dlib.get_frontal_face_detector()
faces=detector(image)
when i try to print the length of the faces it displays zero.
Can anybody help me, what shall I do? Is there other way to detect images from low brightness images? thanks.
Dlib face detector is a very precise one. But as a cost it has low recall, especially when images are bad and/or faces are small.
Try another face detector, like
Seeta https://github.com/seetaface/SeetaFaceEngine
Pico https://github.com/nenadmarkus/pico
or OpenCV
Those may provide detections. But false detections as well.
I have a not-so-simple question.
The Situation:
I'm working on robust facial detection API in python written on top of OpenCV (cv not cv2).
I am using Haar Cascades for face detection specially
front - haarcascade_frontalface_default.xml
profile - haarcascade_profileface.xml
Each worker is using different harr classifier (front/profile) and produce the set of ROI (Region of Interests) then do a uion on them and merge all overlaping bouding boxes.
The result is "your casual red square" around a face with 70% accuracy and not so may phantom faces.
The problem:
Simply tilting the face. My algorithm cannot detect a tilted face.
For profile detection I did a simple flip of a image to detect both left and right profile.
I was thinking there "should" be a better way to detect a tilted face than to call algorithm multiple times for multiple slightly rotated images. (This is a only solution that came to my mind).
The question:
Is there a approach or a way or a specific harr classifier for detection of tilted faces?
Thank you :)