import matplotlib.pyplot as plt
import dlib
import numpy as np
import glob
import re
#正脸检测器
detector=dlib.get_frontal_face_detector()
#脸部关键形态检测器
sp=dlib.shape_predictor(r"D:\LB\JAVASCRIPT\shape_predictor_68_face_landmarks.dat")
#人脸识别模型
facerec = dlib.face_recognition_model_v1(r"D:\LB\JAVASCRIPT\dlib_face_recognition_resnet_model_v1.dat")
#候选人脸部描述向量集
descriptors=[]
photo_locations=[]
for photo in glob.glob(r'D:\LB\JAVASCRIPT\faces\*.jpg'):
photo_locations.append(photo)
img=plt.imread(photo)
img=np.array(img)
#开始检测人脸
dets=detector(img,1)
for k,d in enumerate(dets):
#检测每张照片中人脸的特征
shape=sp(img,d)
face_descriptor=facerec.compute_face_descriptor(img,shape)
v=np.array(face_descriptor)
descriptors.append(v)
#输入的待识别的人脸处理方法相同
img=plt.imread(r'D:\test_photo10.jpg')
img=np.array(img)
dets&
python dlib人脸识别
最新推荐文章于 2024-09-12 20:05:00 发布
本文介绍了如何使用Python结合dlib库实现高效的人脸识别技术,涵盖了从预处理图像到应用深度学习模型的全过程,适合于机器学习和计算机视觉领域的初学者。
摘要由CSDN通过智能技术生成