python+dlib人脸识别
作者:互联网
基础篇:
import dlib import cv2 import numpy as np def main(img_path='./1.jpg'): detector = dlib.get_frontal_face_detector() # 人脸box检测器 image = cv2.imread(img_path) # image = dlib.load_rgb_image(img_path) # image = image[:, :, ::-1] res = detector(image, 2) predictor = dlib.shape_predictor('shape_predictor_68_face_landmarks.dat') # 人脸关键点提取(此处是68点,也可以改为5点) detected_landmarks = predictor(image, res[0]) feature = dlib.face_recognition_model_v1( 'dlib_face_recognition_resnet_model_v1.dat') # 人脸128D特征计算,不同人脸特征间可通过余弦相似度计算 f_128 = feature.compute_face_descriptor(image, detected_landmarks) if __name__ == "__main__": main()
标签:__,人脸识别,predictor,python,image,face,人脸,dlib 来源: https://www.cnblogs.com/niulang/p/15117808.html