python dlib人脸识别

本文介绍了如何使用Python结合dlib库实现高效的人脸识别技术,涵盖了从预处理图像到应用深度学习模型的全过程,适合于机器学习和计算机视觉领域的初学者。
摘要由CSDN通过智能技术生成
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&
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值