1.人脸检测如下
import dlib
from imageio import imread
detector = dlib.get_frontal_face_detector()#检测器
predictor_path = 'shape_predictor_68_face_landmarks.dat'
predictor = dlib.shape_predictor(predictor_path)#预测器
win = dlib.image_window()
path ='111.jpg'
img = imread(path)
win.clear_overlay()
win.set_image(img)
# 1 表示将图片放大一倍,便于检测到更多人脸
dets = detector(img, 1)
print('检测到了 %d 个人脸' % len(dets))
for i, d in enumerate(dets):
print('- %d: Left %d Top %d Right %d Bottom %d' % (i, d.left(), d.top(), d.right(), d.bottom()))
shape = predictor(img, d)
# 第 0 个点和第 1 个点的坐标
print('Part 0: {}, Part 1: {}'.format(shape.part(0), shape.part(1)))
win.add_overlay(shape)
2.生成面部检测器
detector = dlib.get_frontal_face_detector()#检测器
3.生成特征预测器,68维度的
predictor_path &