image = face_recognition.load_image_file("/opt/face/unknown_pic/all_star.jpg") # 应用默认的赐与HOG模型查找图像中所有人脸 # 这个办法已经相当精确了,但照样不如CNN模型那么精确,因为没有应用GPU加快 # 另请拜见: find_faces_in_picture_cnn.py face_locations = face_recognition.face_locations(image) # 应用CNN模型 # face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=0, model="cnn") # 打印:我大年夜图片中找到了 若干 张人脸 print("I found {} face(s) in this photograph.".format(len(face_locations))) # 轮回找到的所有人脸 for face_location in face_locations: # 打印每张脸的地位信息 top, right, bottom, left = face_location print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right)) # 指定人脸的地位信息,然后显示人脸图片 face_image = image[top:bottom, left:right] pil_image = Image.fromarray(face_image) pil_image.show() 
用于识其余图片
- # 履行python文件
- $ python find_faces_in_picture.py

大年夜图片中辨认出 7 张人脸,并显示出来
示例三(主动辨认人脸特点):
- # filename : find_facial_features_in_picture.py
- # -*- coding: utf-8 -*-
- # 导入pil模块 ,可用敕令安装 apt-get install python-Imaging
- from PIL import Image, ImageDraw
- # 导入face_recogntion模块,可用敕令安装 pip install face_recognition
- import face_recognition
-
- # 将jpg文件加载到numpy 数组中
- image = face_recognition.load_image_file("biden.jpg")
-
- #查找图像中所有面部的所有面部特点
- face_landmarks_list = face_recognition.face_landmarks(image)
-
- print("I found {} face(s) in this photograph."
推荐阅读
大规模分布式存储-分布式剪枝系统
沙龙晃荡 | 去哪儿、陌陌、ThoughtWorks在主动化运维中的实践!10.28不见不散!
在分布式键值体系中,半构造化>>>详细阅读
本文标题:手把手教你用1行命令实现人脸识别
地址:http://www.17bianji.com/lsqh/38279.html
1/2 1