All Projects → amusi → Opencv Facial Landmark Detection

amusi / Opencv Facial Landmark Detection

使用OpenCV实现人脸关键点检测

Projects that are alternatives of or similar to Opencv Facial Landmark Detection

Facer
Simple (🤞) face averaging (🙂) in Python (🐍)
Stars: ✭ 49 (-67.97%)
Mutual labels:  opencv, face-detection
Flask face detection
Face detection example in Python 3 based on OpenCV and Flask
Stars: ✭ 55 (-64.05%)
Mutual labels:  opencv, face-detection
Opencv Face Filters
Snapchat-like Face Filters in OpenCV
Stars: ✭ 51 (-66.67%)
Mutual labels:  opencv, face-detection
Predict Facial Attractiveness
Using OpenCV and Dlib to predict facial attractiveness.
Stars: ✭ 41 (-73.2%)
Mutual labels:  opencv, face-detection
Awesome Face Detection
Compare with various detectors - s3fd, dlib, ocv, ocv-dnn, mtcnn-pytorch, face_recognition
Stars: ✭ 106 (-30.72%)
Mutual labels:  opencv, face-detection
Realtimefaceapi
This is a demo project showing how to use Face API in Cognitive Services with OpenCV
Stars: ✭ 44 (-71.24%)
Mutual labels:  opencv, face-detection
Idmatch
Match faces on id cards with OCR capabilities.
Stars: ✭ 52 (-66.01%)
Mutual labels:  opencv, face-detection
Mocr
Meaningful Optical Character Recognition from identity cards with Deep Learning.
Stars: ✭ 19 (-87.58%)
Mutual labels:  opencv, face-detection
Agender
Real-time estimation of gender and age
Stars: ✭ 95 (-37.91%)
Mutual labels:  opencv, face-detection
Catt
Detecting the temperature from an infrared image
Stars: ✭ 60 (-60.78%)
Mutual labels:  opencv, face-detection
Ng Open Cv
Angular 6+ & OpenCV.js integration service library
Stars: ✭ 36 (-76.47%)
Mutual labels:  opencv, face-detection
Animoji Animate
Facial-Landmarks Detection based animating application similar to Apple-Animoji™
Stars: ✭ 142 (-7.19%)
Mutual labels:  opencv, face-detection
Fast face detector
A face detector based on the work "Aggregate channel features for multi-view face detection" presented by Bin Yang, Junjie Yan, Zhen Lei and Stan Z. Li.
Stars: ✭ 35 (-77.12%)
Mutual labels:  opencv, face-detection
Android Hpe
Android native application to perform head pose estimation using images coming from the front camera.
Stars: ✭ 46 (-69.93%)
Mutual labels:  opencv, face-detection
Brfv4 mac examples
macOS C++ examples utilizing OpenCV for camera access and drawing the face tracking results.
Stars: ✭ 25 (-83.66%)
Mutual labels:  opencv, face-detection
Facifier
An emotion and gender detector based on facial features, built with Python and OpenCV
Stars: ✭ 52 (-66.01%)
Mutual labels:  opencv, face-detection
Human Detection And Tracking
Human-detection-and-Tracking
Stars: ✭ 753 (+392.16%)
Mutual labels:  opencv, face-detection
Facepixeler
A simple C# program that can automatically detect and blur faces in images. Uses OpenCV and EmguCV.
Stars: ✭ 5 (-96.73%)
Mutual labels:  opencv, face-detection
Opencv Mtcnn
An implementation of MTCNN Face detector using OpenCV's DNN module
Stars: ✭ 59 (-61.44%)
Mutual labels:  opencv, face-detection
Robovision
AI and machine leaning-based computer vision for a robot
Stars: ✭ 126 (-17.65%)
Mutual labels:  opencv, face-detection

opencv-facial-landmark-detection

Summary:利用OpenCV中的LBF算法进行人脸关键点检测(Facial Landmark Detection)

Author: Amusi

Date: 2018-03-20

Note: OpenCV3.4+OpenCV-Contrib以及上支持Facemark

下面是Amusi具体利用OpenCV中的LBF算法进行人脸关键点检测的教程,**大家如果喜欢这个教程,记得给个star!**项目的教程和源码,只需要你在命令行或终端打开git后,输入下述命令即可,或者直接点击Clone or download,并选择Download ZIP下载压缩包即可。

git clone https://github.com/amusi/opencv-facial-landmark-detection.git

测试环境

Note:感谢apple ^(oo)^兰 童鞋的提醒,注意本教程一定需要OpenCV-Contrib的支持。即你的OpenCV环境需要使用CMake对OpenCV和OpenCV-Contrib进行编译,生成动态链接库。版本最好是3.4.1。

引言

人脸一般是有68个关键点,常用的人脸开源库有Dlib,还有很多深度学习的方法。

OpenCV Facemark : Facial Landmark Detection

本教程仅利用OpenCV,不依赖其它第三方库来实现人脸关键点检测,这一特性是之前没有的。因为OpenCV自带的samples中只有常见的人脸检测、眼睛检测和眼镜检测等(方法是harr+cascade或lbp+cascade)。

本教程主要参考Facemark : Facial Landmark Detection using OpenCV

截止到2018-03-20,OpenCV3.4可支持三种人脸关键点检测,但目前只能找到一种已训练好的模型,所以本教程只介绍一种实现人脸关键点检测的算法。而且此类算法还没有Python接口,所以这里只介绍C++的代码实现。

Facemark API

OpenCV官方的人脸关键点检测API称为Facemark。Facemark目前分别基于下述三篇论文,实现了三种人脸关键点检测的方法。

在写这篇文章的时候,FacemarkKazemi类似乎不是从Facemark类派生的,而其他两个类都是。

Facemark训练好的模型

尽管Facemark API包含三种不同的实现,但只有FacemarkLBF(local binary features,LBF)才提供经过训练的模型。 (之后在我们根据公共数据集训练我们自己的模型后,这篇文章将在未来更新)

你可以从中下载已训练好的模型:

利用OpenCV代码进行实时人脸关键点检测

步骤

1. 加载人脸检测器(face detector)

所有的人脸关键点检测算法的输入都是一个截切的人脸图像。因为,我们的第一步就是在图像中检测所有的人脸,并将所有的人脸矩形框输入到人脸关键点检测器中。这里,我们可以使用OpenCV的Haar人脸检测器或者lbp人脸检测器来检测人脸。

2. 创建Facemark对象

创建Facemark类的对象。在OpenCV中,Facemark是使用智能指针(smart pointer,PTR),所以我们不需要考虑内存泄漏问题。

3. 加载landmark检测器

加载关键点检测器(lbfmodel.yaml)。此人脸检测器是在几千幅带有关键点标签的人脸图像上训练得到的。

带有注释/标签关键点的人脸图像公共数据集可以访问这个链接下载:https://ibug.doc.ic.ac.uk/resources/facial-point-annotations/

4.从网络摄像头中捕获帧

捕获视频帧并处理。我们既可以打开一个本地视频(.mp4),也可以打开网络摄像机(如果电脑有的话)来进行人脸关键点检测。

5. 检测人脸

我们对视频的每一帧运行人脸检测器。人脸检测器的输出是一个包含一个或多个矩形(rectangles)的容器(vector),即视频帧中可能有一张或者多张人脸。

6. 运行人脸关键点检测器

我们根据人脸矩形框截取原图中的人脸ROI,再利用人脸关键点检测器(facial landmark detector)对人脸ROI进行检测。

对于每张脸我们获得,我们可以获得68个关键点,并将其存储在点的容器中。因为视频帧中可能有多张脸,所以我们应采用点的容器的容器。

7. 绘制人脸关键点

根据获得关键点,我们可以在视频帧上绘制出来并显示。

代码

本教程的代码一共有两个程序,分别为faceLandmarkDetection.cppdrawLandmarks.hpp

  • faceLandmarkDetection.cpp实现视频帧捕获、人脸检测、人脸关键点检测;

  • drawLandmarks.hpp实现人脸关键点绘制和多边形线绘制。

faceLandmarkDetection.cpp和drawLandmarks.hpp都在src文件夹中

实验结果

检测结果

Reference

[1]Tutorial:https://www.learnopencv.com/facemark-facial-landmark-detection-using-opencv/

[2]Code:https://github.com/spmallick/learnopencv/tree/master/FacialLandmarkDetection

[3]Models:https://github.com/kurnianggoro/GSOC2017

[4]本教程所有文件打包:

链接1(百度云网盘):https://pan.baidu.com/s/16PZ-McVgRwB3bH1Y2fEWBA 密码:x8be

链接2:http://anonfile.com/e9caRad3bf/Facemark_LBF.rar

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].