基础篇:

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()

 GitHub传送门

 

相关文章:

  • 2021-12-29
  • 2021-11-21
  • 2021-08-15
  • 2022-01-15
  • 2021-08-06
  • 2021-07-14
  • 2021-12-31
  • 2022-01-08
猜你喜欢
  • 2021-11-21
  • 2021-06-05
  • 2021-12-04
  • 2021-11-21
  • 2021-07-08
  • 2021-11-21
  • 2021-09-08
相关资源
相似解决方案