利用face_recognition库裁取人脸

Posted ayew

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了利用face_recognition库裁取人脸相关的知识,希望对你有一定的参考价值。

 1 from PIL import Image
 2 import face_recognition
 3 
 4 # Load the jpg file into a numpy array
 5 image = face_recognition.load_image_file(".jpg")
 6 
 7 # Find all the faces in the image
 8 face_locations = face_recognition.face_locations(image)
 9 
10 print("I found {} face(s) in this photograph.".format(len(face_locations)))
11 
12 for face_location in face_locations:
13 
14     # Print the location of each face in this image
15     top, right, bottom, left = face_location
16     print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))
17 
18     # You can access the actual face itself like this:
19     face_image = image[top:bottom, left:right]
20     pil_image = Image.fromarray(face_image)
21     pil_image.show()

 

 

以上是关于利用face_recognition库裁取人脸的主要内容,如果未能解决你的问题,请参考以下文章