许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  人脸关键点检测:主流算法与开源工具汇总

人脸关键点检测:主流算法与开源工具汇总

阅读数 19
点赞 0
article_banner

开源库有dlib

安装:https://pypi.org/simple/dlib/ 下载  后pip安装

模型下载:Index of /files

1、dlib5点

左右眼角及人中5点。

import dlibimport numpy as npimport cv2import time predictor_path = '../model/shape_predictor_5_face_landmarks.dat'detector = dlib.get_frontal_face_detector()predictor = dlib.shape_predictor(predictor_path) start_time = time.time() frame = cv2.imread("../image/ab.jpg")img = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)dets = detector(img, 1) print(dets) for index, det in enumerate(dets):    right_top = (det.right(), det.top())    left_bottom = (det.left(), det.bottom())    # 画面部检测框    # cv2.rectangle(frame, right_top, left_bottom, (255, 0, 0), 2)    print(right_top,left_bottom)     # 面部特征点检测    shape = predictor(img, det)    landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])    for idx, point in enumerate(landmarks):        # 68点的坐标        pos = (point[0, 0], point[0, 1])        cv2.circle(frame, pos, 5, (0, 0, 255), -1)        cv2.putText(frame,str(idx),pos,cv2.FONT_HERSHEY_COMPLEX,0.6,(0,0,255),1) cv2.imwrite('kp2.jpg',frame)cv2.imshow('res',frame)cv2.waitKey()



2、dlib68点

基本包含脸部区域关键点,但是额头区域没有关键点以及只有眉毛的上 边缘点

import dlibimport numpy as npimport cv2import time predictor_path = '../model/shape_predictor_68_face_landmarks.dat'detector = dlib.get_frontal_face_detector()predictor = dlib.shape_predictor(predictor_path) start_time = time.time() frame = cv2.imread("../image/ab.jpg")img = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)dets = detector(img, 1) print(dets) for index, det in enumerate(dets):    right_top = (det.right(), det.top())    left_bottom = (det.left(), det.bottom())    # 画面部检测框    # cv2.rectangle(frame, right_top, left_bottom, (255, 0, 0), 2)    print(right_top,left_bottom)     # 面部特征点检测    shape = predictor(img, det)    landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])    for idx, point in enumerate(landmarks):        # 68点的坐标        pos = (point[0, 0], point[0, 1])        cv2.circle(frame, pos, 5, (0, 0, 255), -1)        cv2.putText(frame,str(idx),pos,cv2.FONT_HERSHEY_COMPLEX,0.6,(0,0,255),1) cv2.imwrite('kp2.jpg',frame)cv2.imshow('res',frame)cv2.waitKey()

3、 dlib81点

相比较68点,多出13点分布在额头区域,但是点的精度不是太高。

import dlibimport numpy as npimport cv2import time predictor_path = '../model/shape_predictor_81_face_landmarks.dat'detector = dlib.get_frontal_face_detector()predictor = dlib.shape_predictor(predictor_path) start_time = time.time() frame = cv2.imread("../image/ab.jpg")img = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)dets = detector(img, 1) print(dets) for index, det in enumerate(dets):    right_top = (det.right(), det.top())    left_bottom = (det.left(), det.bottom())    # 画面部检测框    # cv2.rectangle(frame, right_top, left_bottom, (255, 0, 0), 2)    print(right_top,left_bottom)     # 面部特征点检测    shape = predictor(img, det)    landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])    for idx, point in enumerate(landmarks):        # 68点的坐标        pos = (point[0, 0], point[0, 1])        cv2.circle(frame, pos, 5, (0, 0, 255), -1)        cv2.putText(frame,str(idx),pos,cv2.FONT_HERSHEY_COMPLEX,0.6,(0,0,255),1) cv2.imwrite('kp2.jpg',frame)cv2.imshow('res',frame)cv2.waitKey()


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


相关文章
技术文档
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
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空