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

初识机器学习-人脸识别

时间:2017-06-08 00:17:07      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:source   file   import   can   actual   图片   ott   cond   mat   

 感谢知乎老狼https://zhuanlan.zhihu.com/p/27275307,点击链接

Anaconda的安装

face_recognition库安装

1.代码

from PIL import Image
import face_recognition

# Load the jpg file into a numpy array
image = face_recognition.load_image_file("wang.jpg")

# Find all the faces in the image
face_locations = face_recognition.face_locations(image)

print("I found {} face(s) in this photograph.".format(len(face_locations)))

for face_location in face_locations:

    # Print the location of each face in this image
    top, right, bottom, left = face_location
    print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))

    # You can access the actual face itself like this:
    face_image = image[top:bottom, left:right]
    pil_image = Image.fromarray(face_image)
    pil_image.show()
image = face_recognition.load_image_file("wang.jpg")读取jpg文件,jpg文件和程序放在同一个文件夹下
face_locations = face_recognition.face_locations(image)
face_recognition详细请参考 http://yongyuan.name/blog/deep-face-recognition-note.html

print("I found {} face(s) in this photograph.".format(len(face_locations)))
打印在改图片发现的人脸数
for face_location in face_locations:

    # Print the location of each face in this image
    top, right, bottom, left = face_location
    print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))
 for循环遍历face_locations,并且逐个打印图片上述属性

 

 

初识机器学习-人脸识别

标签:source   file   import   can   actual   图片   ott   cond   mat   

原文地址:http://www.cnblogs.com/Mathsion811/p/6959517.html

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