当前位置:网站首页>Face based_ Recognition for face key point detection (1)

Face based_ Recognition for face key point detection (1)

2022-07-08 02:21:00 So come on

1. face_recognition Use the simplest face recognition tool in the world , It USES dlib The most advanced face recognition technology , And it has the function of deep learning .

1Github Address :https://github.com/ageitgey/face_recognition

2) Official Guide :https://face-recognition.readthedocs.io/en/latest/readme.html

3) The source code to achieve :https://face-recognition.readthedocs.io/en/latest/face_recognition.html

# 1  Add to Library 
import face_recognition
import cv2
import matplotlib.pyplot as plt

# 2  Method : display picture 
def show_image(image, title):
    plt.title(title)
    plt.imshow(image)
    plt.axis("off")

# 3  Method : draw Landmars Key points 
def show_landmarks(image, landmarks):
    for landmarks_dict in landmarks: # Take a dictionary from the list 
        for landmarks_key in landmarks_dict.keys(): # Get the key in the dictionary 
            for point in landmarks_dict[landmarks_key]: #  Get the value of each key / spot 
                cv2.circle(image, point, 2, (0,0,255), -1) #  Draw a point 
    return image
# 4  The main function 
def main():
    # 5  Read the picture 
    image = cv2.imread("Tom.jpeg")
    # 6  Image grayscale conversion 
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    # 7  call face_recognition Methods in the library :face_landmarks()   Detect the key points in the face 
    face_marks = face_recognition.face_landmarks(gray, None, "large")
    # none  It means that you are not sure where the face is , Autofind .
    # large Express 68,small Express 5
    print(face_marks) # Output a list , Inside is a dictionary , Each point to describe 
    # 8  Draw key points 
    img_result = show_landmarks(image.copy(), face_marks)
    # 9  Create a canvas 
    plt.figure(figsize=(9,6))
    plt.suptitle("Face Landmarks with face_recognition", fontsize=14, fontweight="bold")
    # 10  Show the overall effect 
    show_image(img_result, "landmarks")

    plt.show()

if __name__ == '__main__':
    main()

2. The installation of the library

          Be sure to ask dlib 19.7.0, Not based on what we have dlib Version to install the corresponding face_recognition. So that you can install face_recognition1.3.0, It's just pycharm Install in .

原网站

版权声明
本文为[So come on]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130539412212.html