python使用opencv+shape_predictor_68_face_landmarks.dat实现人脸68个特征点检测代码

代码语言:python

所属分类:人工智能

代码描述:python使用opencv+shape_predictor_68_face_landmarks.dat实现人脸68个特征点检测代码,可以打印人脸脸廓

代码标签: 人脸 识别

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

# coding:utf-8
'''
脸部68个特征点检测
'''
import sys
import dlib
from skimage import io
import cv2

# 加载并初始化检测器
# 模型下载地址http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor('/data/wwwroot/default/model/shape_predictor_68_face_landmarks.dat')

# camera = cv2.VideoCapture(0)
# if not camera.isOpened():
#     print("cannot open camear")
#     exit(0)

frame = cv2.imread("/data/wwwroot/default/asset/man.png")
    # 检测脸部
dets = detector(frame, 1)
print("Number of faces detected: {}".format(len(dets)))
    # 查找脸部位置
for i, face in enumerate(dets):
    print("Detection {}: Left: {} Top: {} .........完整代码请登录后点击上方下载按钮下载查看

网友评论0