码迷,mamicode.com
首页 > 其他好文 > 详细

利用face_recognition库裁取人脸

时间:2017-11-28 12:39:10      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:self   ott   技术   format   ace   elf   nbsp   you   alt   

技术分享图片

 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库裁取人脸

标签:self   ott   技术   format   ace   elf   nbsp   you   alt   

原文地址:http://www.cnblogs.com/ansang/p/7909031.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!