Facial Landmark Detection

2024-03-16 08:30
文章标签 detection landmark facial

本文主要是介绍Facial Landmark Detection,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

转自:http://www.cnblogs.com/lanye/p/5310090.html


Facial Feature Detection

Facial landmark detection using Dlib (left) and CLM-framework (right).

Who sees the human face correctly: the photographer, the mirror, or the painter? — Pablo Picasso

If Picasso was alive today, he would have definitely added one more professional to that list — a computer vision engineer!

As computer vision engineers and researchers we have been trying to understand the human face since the very early days. The most obvious application of facial analysis is Face Recognition. But to be able to identify a person in an image we first need to find where in the image a face is located. Therefore, face detection — locating a face in an image and returning a bounding rectangle / square that contains the face — was a hot research area. In 2001, Paul Viola and Michael Jones pretty much nailed the problem with their seminal paper titled “Rapid Object Detection using a Boosted Cascade of Simple Features.” In the early days of OpenCV and to some extent even now, the killer application of OpenCV was a good implementation of the Viola and Jones face detector.

Once you have a bounding box around the face, the obvious research problem is to see if you can find the location of different facial features ( e.g. corners of the eyes, eyebrows, and the mouth, the tip of the nose etc ) accurately. Facial feature detection is also referred to as “facial landmark detection”, “facial keypoint detection” and “face alignment” in the literature, and you can use those keywords in Google for finding additional material on the topic.

Applications of Facial Keypoint Detection

There are several interesting applications of keypoint detection in human faces. A few of them are listed below.

Facial feature detection improves face recognition

Facial landmarks can be used to align facial images to a mean face shape, so that after alignment the location of facial landmarks in all images is approximately the same. Intuitively it makes sense that facial recognition algorithms trained with aligned images would perform much better, and this intuition has been confirmed by many research papers.

Head pose estimation

Once you know a few landmark points, you can also estimate the pose of the head. In other words you can figure out how the head is oriented in space, or where the person is looking. E.g. CLM-Framework described in this post also returns the head pose.

Face Morphing

Facial landmarks can be used to align faces that can then be morphed to produce in-between images. An example is shown in Figure 1.

Bush Schwarzenegger Morph

Figure 1. A morph between President Bush and the The Governator!

Want me to write a post on face morphing ? Please write to me in the comments section below!

Virtual Makeover

At my company ( TAAZ.com ) we had written our own facial landmark detector. The detected landmarks were used to the calculate contours of the mouth, eyes etc. to render makeup virtually. An example is shown in Figure 2.

Landmark detection for virtual makeover.

Figure 2. Landmark detection for virtual makeover.

Face Replacement

If you have facial feature points estimated on two faces, you can align one face to the other, and then seamlessly clone one face onto the other. You can also do something goofy like this

https://auduno.github.io/clmtrackr/examples/facesubstitution.html

Want me to write a post on aligning one face to another ? Please leave a comment with a request!

In a previous post, we showed how to use facial features to predict facial attractiveness.

Clearly, the ability to detect facial features in images and videos open up possibilities of a ton of interesting applications. Let us now get our hands dirty with some tools that will allow us to do this.

Facial Feature Detection & Tracking Libraries

There has been a flurry of activity in this area in the last 5 years. Part of the reason for this activity is the availability of large annotated datasets like LFPW and Helen. I have listed a bunch of papers in the next section. However, I do not recommend implementing these papers from scratch because now we have access to high quality open source implementations of some of these papers.

In the video below, you can see two of the libraries, Dlib and CLM-framework in action.

Dlib ( C++ / Python )

Dlib is a collection of miscellaneous algorithms in Machine Learning, Computer Vision, Image Processing, and Linear Algebra. Most of the library is just header files that you can include in your C++ application. Oh you prefer python ? No problem, it has a python API as well.

I personally like Dlib more than any other facial feature detection & tracking library because the code is very clean, well documented, the license permits use in commercial applications, the algorithm they have chosen to implement is very fast and accurate, and you can easily integrate the library in your C++ project by just including the header files.

How to compile Dlib ?
  1. Download a copy from github
    1
    git clone https://github.com/davisking/dlib.git
  2. Build examples ( OSX / Linux )
    1
    2
    3
    4
    5
    cd dlib/examples
    mkdir build
    cd build
    cmake ..
    cmake --build . --config Release

    These examples are a great way to start using dlib. Make a copy of an example cpp file, modify it, modify examples/CMakeLists.txt and compile again using the instructions above. Easy!

  3. Compile dlib python module
    1
    2
    cd dlib/python_examples
    ./compile_dlib_python_module.bat
  4. Set PYTHONPATH environment variable
    1
    2
    # Put the following line in .bashrc or .profile
    export PYTHONPATH=/path/to/dlib/python_examples:$PYTHONPATH
  5. Test python module
    1
    python -c "import dlib"

If the above line does not give an error, you are all set.

In case you run into any compilation issues, there are additional instructions at Dlib.net 

How to run Dlib’s facial landmark detector ?

After you have built the examples, to run the facial landmark detector using a webcam, do the following.

1
2
3
4
5
cd examples/build/
#Download the face landmark model
wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
tar xvjf shape_predictor_68_face_landmarks.dat.bz2
./webcam_face_pose_ex

If you want to run it on a single image, you can try

1
./face_landmark_detection_ex shape_predictor_68_face_landmarks.dat faces/*.jpg

CLM-Framework (C++)

CLM-framework, also known as the Cambridge Face Tracker, is a C++ library for facial keypoint detection and head pose estimation. You can see how well it works in the included video. Compiling this library on OSX was bit of a challenge but it was not too bad. The library depends on OpenCV 3 and requires X11.

There are two important ways in which Dlib beats CLM-Framework. First, DLib is much faster than CLM-Framework. Second, Dlib’s license allows you to use it in commercial applications. If I had to pick, I would use Dlib. Interestingly, CLM-Framework depends on Dlib!

How to compile CLM-Framework ?

Compiling CLM-Framework was a bit involved for OSX. For windows and linux there are detailed instructions here. For compiling version 1.3.0 on OSX, I used the instructions for linux but made the following changes.

Most of the dependencies were installed using brew.

In file CMakeLists.txt ( red text was replaced with green text ).

find_package( OpenCV 3.0 REQUIRED )

find_package( OpenCV 3.0 REQUIRED HINTS /path/to/opencv )
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(/opt/X11/include)

In file exe/SimpleCLM/SimpleCLM.cpp

writerFace = VideoWriter(tracked_videos_output[f_n], CV_FOURCC(‘D’,’I’,’V’,’X’), 30, captured_image.size(), true);
writerFace = VideoWriter(tracked_videos_output[f_n], CV_FOURCC(‘M’,’P’,’4′,’V’), 15, captured_image.size(), true);
How to run CLM-Framework’s Facial Feature Detector ?

After compiling CLM-Framework, the executables are in the bin directory. For the webcam demo shown in this post, you can use

1
bin/SimpleCLM

Face++ ( FacePlusPlus ) : Web API

One of the best implementations of facial landmark detection is by FacePlusPlus. They won the 300 Faces In-the-Wild Landmark Detection Challenge, 2013. They provide an easy to use API. The problem is that you need to upload an image to their servers and that raises a lot of privacy concerns. But if privacy is not an issue, Face++ is very good option. You can see a demo at

http://www.faceplusplus.com/demo-landmark/

Facial Feature Detection Research

Many different approaches have been used to solve this problem and it is difficult to summarize them in a blog post. I am simply linking to some important papers ( with major bias toward recent work ) for people who want to investigate more.

  1. Active Appearance Model (AAM) by T. Cootes, G. Edwards and C. J. Taylor. [1998]
  2. Face Alignment through Subspace Constrained Mean-Shifts by Jason M. Saragih, Simon Lucey and Jeffrey F. Cohn. [2009]
  3. Localizing Parts of Faces Using a Consensus of Exemplars by Peter N. Belhumeur, David W. Jacobs, David J. Kriegman, Neeraj Kumar [ 2011 ]
  4. Face Alignment by Explicit Shape Regression by Xudong Cao Yichen Wei Fang Wen Jian Sun [2012]
  5. Supervised Descent Method and Its Applications to Face Alignment by Xuehan Xiong and Fernando De la Torre [2013]
  6. Constrained Local Neural Fields for robust facial landmark detection in the wild by Tadas Baltrusaitis, Peter Robinson, and Louis-Philippe Morency. [2013]
  7. Extensive Facial Landmark Localization with Coarse-to-fine Convolutional Network Cascade by Erjin Zhou, Haoqiang Fan, Zhimin Cao, Yuning Jiang and Qi Yin. [2013]
  8. Face alignment at 3000 fps via regressing local binary features by S Ren, X Cao, Y Wei, J Sun. [2014]
  9. Facial Landmark Detection by Deep Multi-task Learning by Zhanpeng Zhang, Ping Luo, Chen Change Loy, and Xiaoou Tang. [2014]
  10. One Millisecond Face Alignment with an Ensemble of Regression Trees by Vahid Kazemi and Josephine Sullivan. [2014]

Subscribe

If you liked this article, please subscribe to our newsletter and receive a free
Computer Vision Resource guide. In our newsletter we share OpenCV tutorials and examples written in C++/Python, and Computer Vision and Machine Learning algorithms and news.

Subscribe Now

 

 

 

中文翻译

源地址:http://blog.csdn.net/xiamentingtao/article/details/50908190

 

image

原文地址:http://www.learnopencv.com/facial-landmark-detection/#comment-2471797375

作为计算机视觉研究员,我们很早就开始研究人脸。人脸分析领域最广为人知的就是人脸识别(face recognition).但是为了识别一幅图像中的人脸,我们首先必须要找到图像中人脸的位置。因此人脸检测(face detection)-定位一幅图像中的人脸并且返回一个包围人脸的矩形或者正方形(bounding rectangle/square)是一个热门的研究领域。2001年,Paul Viola 和Michael Jones 发表了史诗级论文<< “Rapid Object Detection using a Boosted Cascade of Simple Features.>>.在OpenCV早期甚至某种程度下在现在,OpenCV的致命武器就是对 
Viola and Jones face detector的一个比较好的实现。

一旦你找到了人脸附近的包围盒,最显然的研究当然是准确识别人脸不同特征的位置(比如,眼角、瞳孔、嘴巴、鼻子等)。人脸特征检测(face feature detection)也称为 “facial landmark detection”, “facial keypoint detection” and “face alignment”,你可以在Google找到类似的文献。

Facial Keypoint Detection

人脸关键点检测有很多应用。如下做了一些列举:

Facial feature detection improves face recognition

人脸特征点可以被用来将人脸对齐到平均人脸(mean face shape),这样在对齐之后所有图像中的人脸特征点的位置几乎是相同的。直观上来看,用对齐后的图像训练的人脸识别算法更加有效,这个直觉已经被很多论文验证。

Head pose estimation

一旦你知道了一些特征点的位置,你也可以估计头部的姿势。换句话说,你可以解决头部在空间中的定向问题,或者通俗的讲就是人朝那里看的问题。

Face Morphing (人脸变形)

人脸特征点可以对齐人脸,这样可以生成两张人脸的中间图像。如下图: 
image

Virtual Makeover(虚拟化妆)

在我的公司 
我们已经写了自己的人脸特征点检测器。检测出的特征点被用来计算嘴的轮廓,眼睛等用来渲染虚拟化妆。Figure2z展示了这一效果: 
image

Face Replacement

如何两张人脸的特征点已经估计出来了,你可以将一张人脸对齐到另一张人脸,并且可以无缝换脸。你也可以做像下面一样傻瓜的事。 
https://auduno.github.io/clmtrackr/examples/facesubstitution.html

先前的报告中,我们展示了如何使用人脸特征点去预测人脸的吸引力。

很明显,在图片和视频上进行人脸特征点检测为许多有趣的应用提供了很多的可能性。下面我们就将介绍一些有用的特征点检测工具。

Facial Feature Detection & Tracking Libraries

过去五年来,这个领域很火,部分原因是大量可以用来训练的数据如LFPW、Helen被提供。我在下一节列了很多论文。但是我不建议胡乱实现这些论文,因为已经有开源的实现。

下面的视频中,你可以看到两个库DlibCLM-framework
http://7xrqgw.com1.z0.glb.clouddn.com/dlib_clm.mp4

Dlib(C++/Python)

Dlib是机器学习,计算机视觉,图像处理,线性代数中众多算法的集合。库中大多数是头文件,你可以直接直接包含在C++应用中。或者你更喜欢Python?没问题,他也有一个Python接口.

我个人更喜欢Dlib因为代码是简洁的,有大量的注释,也可以被用来商用。他们选择实现的算法是非常快的,并且是准确的,你可以很容易集成这个库到你的C++工程中,而你需要做的仅仅是包含头文件.

如何编译Dlib?

  1. 从Github上下载:
<code class="hljs php has-numbering">git <span class="hljs-keyword">clone https:<span class="hljs-comment">//github.com/davisking/dlib.git</span></span></code>
  • 1
  1. 建立Examples(OSX\Linux)
<code class="hljs bash has-numbering"><span class="hljs-built_in">cd dlib/examples
mkdir build
<span class="hljs-built_in">cd build
cmake .. 
cmake --build . --config Release</span></span></code>
  • 1
  • 2
  • 3
  • 4
  • 5

这些例子是一个开始使用Dlib的非常好的方法。拷贝一个例子的cpp文件,修改它,修改examples/CMakeLists.txt 并且像上面一样再一次编译它。很容易吧! 
3. 编译dlib python 模块

<code class="hljs bash has-numbering"><span class="hljs-built_in">cd dlib/python_examples 
./compile_dlib_python_module.bat</span></code>
  • 1
  • 2
  1. 设置 PYTHONPATH 环境变量
<code class="hljs ruby has-numbering"><span class="hljs-comment"># Put the following line in .bashrc or .profile
export <span class="hljs-constant">PYTHONPATH=<span class="hljs-regexp">/path/to<span class="hljs-regexp">/dlib/python<span class="hljs-symbol">_examples:<span class="hljs-variable">$PYTHONPATH
</span></span></span></span></span></span></code>
  • 1
  • 2
  • 3
  1. 测试python模块
<code class="hljs mel has-numbering"><span class="hljs-keyword">python -c <span class="hljs-string">"import dlib"</span></span></code>
  • 1

如果以上都没有问题的话,你就设置好了。

How to run Dlib’s facial landmark detector ?

当你编译好examples后,为了在网络摄像头上运行人脸特征点检测器,可以这样做:

<code class="hljs avrasm has-numbering">cd examples/build/
<span class="hljs-preprocessor">#Download the face landmark model 
wget http://dlib<span class="hljs-preprocessor">.net/files/shape_predictor_68_face_landmarks<span class="hljs-preprocessor">.dat<span class="hljs-preprocessor">.bz2
tar xvjf shape_predictor_68_face_landmarks<span class="hljs-preprocessor">.dat<span class="hljs-preprocessor">.bz2
./webcam_face_pose_ex</span></span></span></span></span></span></code>
  • 1
  • 2
  • 3
  • 4
  • 5

如果你想要在单个图像上运行,你可以这样试试:

<code class="hljs avrasm has-numbering">./face_landmark_detection_ex shape_predictor_68_face_landmarks<span class="hljs-preprocessor">.dat faces<span class="hljs-comment">/*.jpg
</span></span></code>
  • 1
  • 2

CLM-Framework (C++)

CLM-framework,也被称为剑桥人脸跟踪器,是一个用来进行人脸特征点检测和头部姿势估计的C++库。你可以看看他在包含的video文件里工作的多么好啊!在OSX上编译这个库有点儿挑战但是也不太难。库依赖于OpenCV3和X11.

有两个重要的事说明Dlib可以挑战CLM-Framework。首先,Dlib比CLM-Framework更快。其次,Dlib的license允许你商用。如果要挑一个的,我会使用Dlib.有趣的是,CLM-Framework依赖于Dlib.

如何编译CLM-Framework?

编译CLM-Framework在OSX上有点儿复杂。对于Windows和linux,这里有一份详细的说明.为了在OSX上编译version 1.3.0,我使用了linux的指示,但是发生了很多改变。

许多依赖项可以使用brew安装.

在文件CMakeLists.txt(如下划掉的被后面的取代)

find_package( OpenCV 3.0 REQUIRED )

find_package( OpenCV 3.0 REQUIRED HINTS /path/to/opencv )

INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})

INCLUDE_DIRECTORIES(/opt/X11/include)

在文件exe/SimpleCLM/SimpleCLM.cpp中

writerFace = VideoWriter(tracked_videos_output[f_n], CV_FOURCC(‘D’,’I’,’V’,’X’), 30, captured_image.size(), true);

writerFace = VideoWriter(tracked_videos_output[f_n], CV_FOURCC(‘M’,’P’,’4′,’V’), 15, captured_image.size(), true);

如何运行CLM-Framework人脸检测器?

编译后,可执行文件在bin路径中.对于视频中展现的网络摄像头Demo,你可以这样使用:

<code class="hljs  has-numbering">bin/SimpleCLM</code>
  • 1

Face++ ( FacePlusPlus ) : Web API

人脸特征点检测最好的实现之一就是Face++.他们在300 Faces in-the-Wild 
Landmark Detection Challenge,2013取得了冠军。他们提供了一个易用的API。问题是你需要上传一张图片到他们的服务器,这个将带来很多隐私上的担忧。但是如果隐私不是问题的话,Face++是一个好的选择。你可以在 
http://www.faceplusplus.com/demo-landmark/ 
看到一个Demo.

Facial Feature Detection Research

许多不同的方法都可以用来解决这个问题。很难再博客中对其归类。我简单地列出了一些重要论文。 
1. Active Appearance Model (AAM) by T. Cootes, G. Edwards and C. J. Taylor. [1998] 
2. Face Alignment through Subspace Constrained Mean-Shifts by Jason M. Saragih, Simon Lucey and Jeffrey F. Cohn. [2009] 
3. Localizing Parts of Faces Using a Consensus of Exemplars by Peter N. Belhumeur, David W. Jacobs, David J. Kriegman, Neeraj Kumar [ 2011 ] 
4. Face Alignment by Explicit Shape Regression by Xudong Cao Yichen Wei Fang Wen Jian Sun [2012] 
5. Supervised Descent Method and Its Applications to Face Alignment by Xuehan Xiong and Fernando De la Torre [2013] 
6. Constrained Local Neural Fields for robust facial landmark detection in the wild by Tadas Baltrusaitis, Peter Robinson, and Louis-Philippe Morency. [2013] 
7. Extensive Facial Landmark Localization with Coarse-to-fine Convolutional Network Cascade by Erjin Zhou, Haoqiang Fan, Zhimin Cao, Yuning Jiang and Qi Yin. [2013] 
8. Face alignment at 3000 fps via regressing local binary features by S Ren, X Cao, Y Wei, J Sun. [2014] 
9. Facial Landmark Detection by Deep Multi-task Learning by Zhanpeng Zhang, Ping Luo, Chen Change Loy, and Xiaoou Tang. [2014] 
10.One Millisecond Face Alignment with an Ensemble of Regression Trees by Vahid Kazemi and Josephine Sullivan. [2014]


这篇关于Facial Landmark Detection的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/814887

相关文章

时间序列|change point detection

change point detection 被称为变点检测,其基本定义是在一个序列或过程中,当某个统计特性(分布类型、分布参数)在某时间点受系统性因素而非偶然因素影响发生变化,我们就称该时间点为变点。变点识别即利用统计量或统计方法或机器学习方法将该变点位置估计出来。 Change Point Detection的类型 online 指连续观察某一随机过程,监测到变点时停止检验,不运用到

MACS bdgdiff: Differential peak detection based on paired four bedGraph files.

参考原文地址:[http://manpages.ubuntu.com/manpages/xenial/man1/macs2_bdgdiff.1.html](http://manpages.ubuntu.com/manpages/xenial/man1/macs2_bdgdiff.1.html) 文章目录 一、MACS bdgdiff 简介DESCRIPTION 二、用法

Learning Memory-guided Normality for Anomaly Detection——学习记忆引导的常态异常检测

又是一篇在自编码器框架中研究使用记忆模块的论文,可以看做19年的iccv的论文的衍生,在我的博客中对19年iccv这篇论文也做了简单介绍。韩国人写的,应该是吧,这名字听起来就像。 摘要abstract 我们解决异常检测的问题,即检测视频序列中的异常事件。基于卷积神经网络的异常检测方法通常利用代理任务(如重建输入视频帧)来学习描述正常情况的模型,而在训练时看不到异常样本,并在测试时使用重建误

REMEMBERING HISTORY WITH CONVOLUTIONAL LSTM FOR ANOMALY DETECTION——利用卷积LSTM记忆历史进行异常检测

上海科技大学的文章,上海科技大学有个组一直在做这方面的工作,好文章挺多的还有数据集。 ABSTRACT 本文解决了视频中的异常检测问题,由于异常是无界的,所以异常检测是一项极具挑战性的任务。我们通过利用卷积神经网络(CNN或ConvNet)对每一帧进行外观编码,并利用卷积长期记忆(ConvLSTM)来记忆与运动信息相对应的所有过去的帧来完成这项任务。然后将ConvNet和ConvLSTM与

COD论文笔记 ECCV2024 Just a Hint: Point-Supervised Camouflaged Object Detection

这篇论文的主要动机、现有方法的不足、拟解决的问题、主要贡献和创新点: 1. 动机 伪装物体检测(Camouflaged Object Detection, COD)旨在检测隐藏在环境中的伪装物体,这是一个具有挑战性的任务。由于伪装物体与背景的细微差别和模糊的边界,手动标注像素级的物体非常耗时,例如每张图片可能需要 60 分钟来标注。因此,作者希望通过减少标注负担,提出了一种仅依赖“点标注”的弱

COD论文笔记 Adaptive Guidance Learning for Camouflaged Object Detection

论文的主要动机、现有方法的不足、拟解决的问题、主要贡献和创新点如下: 动机: 论文的核心动机是解决伪装目标检测(COD)中的挑战性任务。伪装目标检测旨在识别和分割那些在视觉上与周围环境高度相似的目标,这对于计算机视觉来说是非常困难的任务。尽管深度学习方法在该领域取得了一定进展,但现有方法仍面临有效分离目标和背景的难题,尤其是在伪装目标与背景特征高度相似的情况下。 现有方法的不足之处: 过于

深入RAG优化:BGE词嵌入全解析与Landmark Embedding新突破

前面已经写过一篇关于Embedding选型的文章,《如何高效选择RAG的中文Embedding模型?揭秘最佳实践与关键标准!》,主要介绍通过开源网站的下载量和测评效果选择Embedding模型。 一、Embedding选型建议与结果 选型建议: 1、大部分模型的序列长度是 512 tokens。8192 可尝试 tao-8k,1024 可尝试 stella。 2、在专业数据领域上,嵌入

Detection简记3-Region Proposal by Guided Anchoring

创新点 1.新的anchor 分布策略:Guided Anchoring 2.feature adaption module,根据潜在的anchor精调特征 总结 Guided Anchoring:流程如图所示 特征图F1接两个分支:位置预测分支产生物体可能存在的位置的概率图,形状预测分支预测物体的形状,独立于位置。根据两个分支的输出,得到anchor。 位置预测分支: 1X1的卷积+si

Detection简记2-DAFE-FD: Density Aware Feature Enrichment for Face Detection

创新点 1.使用密度估计模型增强检测中的特征图 总结 整个流程还是很清晰的。 conv1-3的特征图经过密度估计模块由检测器D1进行检测。 D2-4分别是四个检测器。 FFM是特征融合模块,将不同层不同大小的特征融合。 FFM网络结构如下: 首先使用1X1的卷积减少两组特征的厚度到128,然后使用双线性插值统一两组特征图的尺寸,然后相加。类似于cvpr2017的SSH。 多尺度检测器的网

DS简记1-Real-time Joint Object Detection and Semantic Segmentation Network for Automated Driving

创新点 1.更小的网络,更多的类别,更复杂的实验 2. 一体化 总结 终于看到一篇检测跟踪一体化的文章 网络结构如下: ResNet10是共享的Encoder,yolov2 是检测的Deconder,FCN8 是分割的Deconder。 其实很简单,论文作者也指出:Our work is closest to the recent MultiNet. We differ by focus