许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  81个人脸关键点检测算法与实现

81个人脸关键点检测算法与实现

阅读数 6
点赞 0
article_banner

之前运行过Dlib,主要是做了68个人脸关键点的检测,其对应的68个人脸关键点如下图:

https://i-blog.csdnimg.cn/blog_migrate/b36fe0edd781dcdd2e718e2fe1a8d7af.png

其中关于dlib的68个点的使用可参考:https://blog.csdn.net/xingchenbingbuyu/article/details/51116354

本文讲的demo是在dlib基础上的扩展;

项目地址:https://github.com/codeniko/shape_predictor_81_face_landmarks

该项目实现对于给的的图像(pic或者视频流的帧)做81个人脸特征点检测,训练过程类似dlib的68个点,作者加了前额部分的13个点。对于头部检测或者针对那个区域做图像处理来说精度提高了。如作者在额头添了个帽子的操作~

placing a hat on someone's head.

这13个点的提取,作者是参考了patrikhuber的eos项目: https://github.com/codeniko/eos.

作者并使用了Surrey Face Model

以下是作者原话:

“I made the modifications here, then ran it on the entire ibug large database   of images to overwrite each image's 68 landmark coordinates with my 81 landmark coordinates. From here, the training for the shape predictor model can   proceed using http://dlib.net/train_shape_predictor.py.html  ”

可翻墙看下作者运行了该项目的demo视频  https://www.youtube.com/watch?v=mDJrASIB1T0

以下是81个特征点的分布,其中0~67是dlib的68个点,68~80是作者后加的13个点;

https://i-blog.csdnimg.cn/blog_migrate/ac7104f2a603a9259a12c70445180189.png



下载了项目代码后,切到项目路径下,我用的是anaconda 环境,运行其中的webcam_record.py脚本,指令如下:

python webcam_record.py

https://i-blog.csdnimg.cn/blog_migrate/620b1bc73e336bab991228c8c0cd433b.png

运行如上代码,会实时捕获摄像头,并做人脸关键点检测,结果如下:

https://i-blog.csdnimg.cn/blog_migrate/6f4e7c644ef1d9393de1ae0e6c44c530.png

检测实时性是真的很好,完全cpu运行的,对于小的图像人脸检测也是不错的,不过在人脸侧向角度稍大一些就会检不出了~

猜猜我手机中的女明星是谁~~~

其中脚本源码内容如下(跟dlib基础一样):

webcam_record.py

import sysimport osimport dlibimport globfrom skimage import ioimport numpy as npimport cv2  cap = cv2.VideoCapture(0)    #读取摄像头fourcc = cv2.VideoWriter_fourcc(*'XVID')   #生成视频文件的编码形式 out = cv2.VideoWriter('output.avi',fourcc, 20.0, (1280, 720)) #输出视频的参数信息 predictor_path = 'shape_predictor_81_face_landmarks.dat'   #官方训练好的模型文件 detector = dlib.get_frontal_face_detector()  #使用dlib自带的frontal_face_detector作为我们的人脸提取器predictor = dlib.shape_predictor(predictor_path) #2.使用官方提供的模型构建特征提取器 while(cap.isOpened()):    ret, frame = cap.read()    frame = cv2.flip(frame, 1)  #图像水平翻转    dets = detector(frame, 0) #3.使用detector进行人脸检测 dets为返回的结果    for k, d in enumerate(dets):        shape = predictor(frame, d) #5.使用predictor进行人脸关键点识别        landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])        for num in range(shape.num_parts):            cv2.circle(frame, (shape.parts()[num].x, shape.parts()[num].y), 3, (0,255,0), -1)  #6.绘制特征点    cv2.imshow('frame', frame)    out.write(frame)    if cv2.waitKey(1) & 0xFF == ord('q'):        print("q pressed")        break  cap.release()out.release() cv2.destroyAllWindows()  

你事先需要安装一些库,使用pip

pip cmake,opencv-python, dlib

cmake是用于编译dlib库的~

enjoy !


免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
技术文档
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空