简体   繁体   English

检测任何非正面人脸中的面部标志

[英]Detection of facial landmarks in any non frontal face

I have used dlib library for facial landmark detection.我使用 dlib 库进行面部标志检测。 But when the face is non frontal then dlib's "frontal_face_detector" can't detect the face.但是当人脸不是正面时,dlib 的“frontal_face_detector”就无法检测到人脸。

Is there any other way to detect facial landmarks in a profile face?有没有其他方法可以检测侧面人脸中的面部标志?

In my experience, Dlib's default face detector (eg detector = dlib.get_frontal_face_detector() in the Python API) works well on non-frontal faces, and can even detect faces close to profile.根据我的经验,Dlib 的默认人脸检测器(例如 Python API 中的detector = dlib.get_frontal_face_detector()在非正面人脸上运行良好,甚至可以检测接近轮廓的人脸。

According to the source code , that's because it's a HOG based detector which is actually built out of 5 different HOG filters:根据源代码,这是因为它是一个基于 HOG 的检测器,它实际上由 5 个不同的 HOG 过滤器构建而成:

It is built out of 5 HOG filters.它由 5 个 HOG 过滤器构成。 A front looking, left looking, right looking, front looking but rotated left, and finally a front looking but rotated right one.前视,左视,右视,前视但左转,最后是前视右转。

Here's an example detection:这是一个示例检测:

在此处输入图片说明

And here's the Python 3 code I used (uses OpenCV to read/write the image and draw the rectangle):这是我使用的 Python 3 代码(使用 OpenCV 读/写图像并绘制矩形):

import cv2
import dlib

img = cv2.imread('will.jpg')
detector = dlib.get_frontal_face_detector()
dets = detector(img, 1)
face = dets[0]
cv2.rectangle(img, (face.left(), face.top()), (face.right(), face.bottom()), (0, 255, 0), 2)
cv2.imwrite('out.jpg', img)

OpenCV's haar cascade is a legacy method. OpenCV 的 haar 级联是一种传统方法。 You should try deep learning based ones such as ssd or mtcnn.您应该尝试基于深度学习的方法,例如 ssd 或 mtcnn。 Herein, deepface wraps opencv, ssd, dlib and mtcnn to detect and align faces.这里,deepface 封装了 opencv、ssd、dlib 和 mtcnn 来检测和对齐人脸。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM