0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

这就是你需要的人脸特征点检测方法

DPVg_AI_era 来源:lp 2019-03-19 09:35 次阅读

人脸特征点检测是人脸检测过程中的一个重要环节。以往我们采用的方法是OpenCV或者Dlib,虽然Dlib优于OpenCV,但是检测出的68个点并没有覆盖额头区域。Reddit一位网友便在此基础上做了进一步研究,能够检测出81个面部特征点,使得准确度有所提高。

或许,这就是你需要的人脸特征点检测方法。

人脸特征点检测(Facial landmark detection)是人脸检测过程中的一个重要环节。是在人脸检测的基础上进行的,对人脸上的特征点例如嘴角、眼角等进行定位。

近日,Reddit一位网友po出一个帖子,表示想与社区同胞们分享自己的一点研究成果:

其主要的工作就是在人脸检测Dlib库68个特征点的基础上,增加了13个特征点(共81个),使得头部检测和图像操作更加精确。

现在来看一下demo:

demo视频链接:

https://www.youtube.com/watch?v=mDJrASIB1T0

81个特征点,人脸特征点检测更加精准

以往我们在做人脸特征点检测的时候,通常会用OpenCV来进行操作。

但自从人脸检测Dlib库问世,网友们纷纷表示:好用!Dlib≥OpenCV!Dlib具有更多的人脸识别模型,可以检测脸部68甚至更多的特征点。

我们来看一下Dlib的效果:

Dlib人脸特征点检测效果图

那么这68个特征点又是如何分布的呢?请看下面这张“面相图”:

人脸68个特征点分布

但无论是效果图和“面相图”,我们都可以发现在额头区域是没有分布特征点的。

于是,网友便提出了一个特征点能够覆盖额头区域的模型。

该模型是一个自定义形状预测模型,在经过训练后,可以找到任何给定图像中的81个面部特征点。

它的训练方法类似于Dlib的68个面部特征点形状预测器。只是在原有的68个特征点的基础上,在额头区域增加了13个点。这就使得头部的检测,以及用于需要沿着头部顶部的点的图像操作更加精准。

81个特征点效果图

这13个额外的特征点提取的方法,是根据该博主之前的工作完成的。

GitHub地址:

https://github.com/codeniko/eos

该博主继续使用Surrey Face Model,并记下了他认为适合他工作的13个点,并做了一些细节的修改。

当然,博主还慷慨的分享了训练的代码:

1#!/usr/bin/python 2#Thecontentsofthisfileareinthepublicdomain.SeeLICENSE_FOR_EXAMPLE_PROGRAMS.txt 3# 4#Thisexampleprogramshowshowtousedlib'simplementationofthepaper: 5#OneMillisecondFaceAlignmentwithanEnsembleofRegressionTreesby 6#VahidKazemiandJosephineSullivan,CVPR2014 7# 8#Inparticular,wewilltrainafacelandmarkingmodelbasedonasmall 9#datasetandthenevaluateit.Ifyouwanttovisualizetheoutputofthe 10#trainedmodelonsomeimagesthenyoucanrunthe 11#face_landmark_detection.pyexampleprogramwithpredictor.datastheinput 12#model. 13# 14#Itshouldalsobenotedthatthiskindofmodel,whileoftenusedforface 15#landmarking,isquitegeneralandcanbeusedforavarietyofshape 16#predictiontasks.Butherewedemonstrateitonlyonasimpleface 17#landmarkingtask. 18# 19#COMPILING/INSTALLINGTHEDLIBPYTHONINTERFACE 20#Youcaninstalldlibusingthecommand: 21#pipinstalldlib 22# 23#Alternatively,ifyouwanttocompiledlibyourselfthengointothedlib 24#rootfolderandrun: 25#pythonsetup.pyinstall 26# 27#Compilingdlibshouldworkonanyoperatingsystemsolongasyouhave 28#CMakeinstalled.OnUbuntu,thiscanbedoneeasilybyrunningthe 29#command: 30#sudoapt-getinstallcmake 31# 32#AlsonotethatthisexamplerequiresNumpywhichcanbeinstalled 33#viathecommand: 34#pipinstallnumpy 35 36importos 37importsys 38importglob 39 40importdlib 41 42#Inthisexamplewearegoingtotrainafacedetectorbasedonthesmall 43#facesdatasetintheexamples/facesdirectory.Thismeansyouneedtosupply 44#thepathtothisfacesfolderasacommandlineargumentsowewillknow 45#whereitis. 46iflen(sys.argv)!=2: 47print( 48"Givethepathtotheexamples/facesdirectoryastheargumenttothis" 49"program.Forexample,ifyouareinthepython_examplesfolderthen" 50"executethisprogrambyrunning: " 51"./train_shape_predictor.py../examples/faces") 52exit() 53faces_folder=sys.argv[1] 54 55options=dlib.shape_predictor_training_options() 56#Nowmaketheobjectresponsiblefortrainingthemodel. 57#Thisalgorithmhasabunchofparametersyoucanmesswith.The 58#documentationfortheshape_predictor_trainerexplainsallofthem. 59#YoushouldalsoreadKazemi'spaperwhichexplainsalltheparameters 60#ingreatdetail.However,hereI'mjustsettingthreeofthem 61#differentlythantheirdefaultvalues.I'mdoingthisbecausewe 62#haveaverysmalldataset.Inparticular,settingtheoversampling 63#toahighamount(300)effectivelybooststhetrainingsetsize,so 64#thathelpsthisexample. 65options.oversampling_amount=300 66#I'malsoreducingthecapacityofthemodelbyexplicitlyincreasing 67#theregularization(makingnusmaller)andbyusingtreeswith 68#smallerdepths. 69options.nu=0.05 70options.tree_depth=2 71options.be_verbose=True 72 73#dlib.train_shape_predictor()doestheactualtraining.Itwillsavethe 74#finalpredictortopredictor.dat.TheinputisanXMLfilethatliststhe 75#imagesinthetrainingdatasetandalsocontainsthepositionsoftheface 76#parts. 77training_xml_path=os.path.join(faces_folder,"training_with_face_landmarks.xml") 78dlib.train_shape_predictor(training_xml_path,"predictor.dat",options) 79 80#Nowthatwehaveamodelwecantestit.dlib.test_shape_predictor() 81#measurestheaveragedistancebetweenafacelandmarkoutputbythe 82#shape_predictorandwhereitshouldbeaccordingtothetruthdata. 83print(" Trainingaccuracy:{}".format( 84dlib.test_shape_predictor(training_xml_path,"predictor.dat"))) 85#Therealtestistoseehowwellitdoesondataitwasn'ttrainedon.We 86#traineditonaverysmalldatasetsotheaccuracyisnotextremelyhigh,but 87#it'sstilldoingquitegood.Moreover,ifyoutrainitononeofthelarge 88#facelandmarkingdatasetsyouwillobtainstate-of-the-artresults,asshown 89#intheKazemipaper. 90testing_xml_path=os.path.join(faces_folder,"testing_with_face_landmarks.xml") 91print("Testingaccuracy:{}".format( 92dlib.test_shape_predictor(testing_xml_path,"predictor.dat"))) 93 94#Nowlet'suseitasyouwouldinanormalapplication.Firstwewillloadit 95#fromdisk.Wealsoneedtoloadafacedetectortoprovidetheinitial 96#estimateofthefaciallocation. 97predictor=dlib.shape_predictor("predictor.dat") 98detector=dlib.get_frontal_face_detector() 99100#Nowlet'srunthedetectorandshape_predictorovertheimagesinthefaces101#folderanddisplaytheresults.102print("Showingdetectionsandpredictionsontheimagesinthefacesfolder...")103win=dlib.image_window()104forfinglob.glob(os.path.join(faces_folder,"*.jpg")):105print("Processingfile:{}".format(f))106img=dlib.load_rgb_image(f)107108win.clear_overlay()109win.set_image(img)110111#Askthedetectortofindtheboundingboxesofeachface.The1inthe112#secondargumentindicatesthatweshouldupsampletheimage1time.This113#willmakeeverythingbiggerandallowustodetectmorefaces.114dets=detector(img,1)115print("Numberoffacesdetected:{}".format(len(dets)))116fork,dinenumerate(dets):117print("Detection{}:Left:{}Top:{}Right:{}Bottom:{}".format(118k,d.left(),d.top(),d.right(),d.bottom()))119#Getthelandmarks/partsforthefaceinboxd.120shape=predictor(img,d)121print("Part0:{},Part1:{}...".format(shape.part(0),122shape.part(1)))123#Drawthefacelandmarksonthescreen.124win.add_overlay(shape)125126win.add_overlay(dets)127dlib.hit_enter_to_continue()

有需要的小伙伴们,快来试试这个模型吧!

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 人脸识别
    +关注

    关注

    76

    文章

    3955

    浏览量

    80562
  • 人脸特征
    +关注

    关注

    0

    文章

    2

    浏览量

    1274
  • dlib
    +关注

    关注

    0

    文章

    3

    浏览量

    2589

原文标题:超越Dlib!81个特征点覆盖全脸,面部特征点检测更精准(附代码)

文章出处:【微信号:AI_era,微信公众号:新智元】欢迎添加关注!文章转载请注明出处。

收藏 人收藏

    评论

    相关推荐

    基于matlab的人脸检测K-L的人脸识别(肤色分割和特征提取)

    基于matlab的人脸检测K-L的人脸识别(肤色分割和特征提取)[hide] [/hide]《labview人脸识别》课程链接:http:/
    发表于 02-22 16:45

    matlab毕业论文-快速人脸特征定位

    的完成涉及从复杂的背景中分割、抽取、验证人脸区域和可能用到的人脸特征(如眼睛、唇色等)。成功的人脸检测系统应能处理实际存在的光线、
    发表于 03-07 10:22

    基于openCV的人脸检测系统的设计

    通过对基于Adaboost人脸检测算法的研究,利用该算法与计算机视觉类库openCV进行人脸检测系统的设计,实现了对出现在视频或图像中的人脸
    发表于 12-23 14:19

    【Z-turn Board试用体验】+ Z-Turn的人脸识别门禁系统项目开发(二)

    ;5,人脸表示(特征提取),比如gabor特征和上述的lbp特征,常常会对多种特征进行融合;6,鉴别特征
    发表于 06-30 17:31

    基于直方图统计学习的人脸检测方法

    提出一种基于直方图统计学习的人脸检测方法,对人脸样本和非人脸样本进行小波变换,运用一组小波系数来表征各种
    发表于 04-15 08:45 11次下载

    基于肤色模型和区域特征的人脸检测方法

    精度和速度是人脸检测系统的两个衡量标准。针对传统人脸检测方法两者不能兼优的问题,该文提出一种结合颜色空间和
    发表于 04-15 08:55 25次下载

    基于DCT和KDA的人脸特征提取新方法

    提出了一种新的人脸特征提取方法,该方法采用DCT对人脸图像进行降维和去噪,并通过KDA提取人脸
    发表于 05-25 22:04 15次下载

    基于姿态校正的人脸检测方法

    本人提出了一种基于姿态校正的人脸检测方法,在此基础上,提出姿态角度估计目标函数,并讨论了2种寻优方法,该方法在自拍的视频序列中进行姿态估计和
    发表于 04-13 17:24 30次下载
    基于姿态校正<b class='flag-5'>的人脸</b><b class='flag-5'>检测</b><b class='flag-5'>方法</b>

    基于肤色检测和人眼定位的人脸检测方法

    提出了一种基于肤色检测和人眼定位的人脸检测方法。使用基于“基准白色”的色彩平衡方法归一化彩色图像,将图像在HSV 空间进行肤色分割,确定候选
    发表于 10-08 09:21 3599次阅读
    基于肤色<b class='flag-5'>检测</b>和人眼定位<b class='flag-5'>的人脸</b><b class='flag-5'>检测</b><b class='flag-5'>方法</b>

    基于几何特征与新Haar特征的人脸检测算法_糜元根

    基于几何特征与新Haar特征的人脸检测算法_糜元根
    发表于 03-19 19:25 2次下载

    FAST特征点检测features2D

    特征点检测和匹配是计算机视觉中一个很有用的技术。在物体检测,视觉跟踪,三维常年关键等领域都有很广泛的应用。这一次先介绍特征点检测的一种
    发表于 11-29 09:10 3329次阅读
    FAST<b class='flag-5'>特征</b><b class='flag-5'>点检测</b>features2D

    一种基于Mask R-CNN的人脸检测及分割方法

    针对现有主流的人脸检测算法不具备像素级分割,从而存在人脸特征具有噪声及检测精度不理想的问题提出了一种基于 Mask r-CNN
    发表于 04-01 10:42 5次下载
    一种基于Mask R-CNN<b class='flag-5'>的人脸</b><b class='flag-5'>检测</b>及分割<b class='flag-5'>方法</b>

    基于特征图融合的小尺寸人脸检测方法

    特征图,使用不同的特征检测不同大小的人脸。然后,通过将较深的特征图和较浅的特征图进行融合,合理
    发表于 05-29 14:17 10次下载

    PFLD:一个实用的人脸关键点检测

    人脸关键点检测是一个非常核心的算法业务,其在许多场景中都有应用。比如我们常用的换脸、换妆、人脸识别等2C APP中的功能,都需要先进...
    发表于 02-07 12:33 3次下载
    PFLD:一个实用<b class='flag-5'>的人脸</b>关键<b class='flag-5'>点检测</b>器

    DCNN网络结构 DCNN的人脸特征点检测

    问题的方法。通过添加更多的卷积层稳定地增加网络的深度,并且在所有层中使用3×3的卷积滤波器,有效减小参数,更好地解决了人脸特征点检测问题。然后计算双眼角与嘴角所成平面与正视时此平面的单
    发表于 07-20 14:30 0次下载