几行代码实现人脸定位
import face_recognition
from PIL import Image
image = face_recognition.load_image_file("IMG_20220519_210830.jpg")
face_locations = face_recognition.face_locations(image)
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()
标签:right,代码,locations,几行,face,人脸,image,recognition
From: https://www.cnblogs.com/lwp-nicol/p/18103675