javaweb调用pyhton face_recognition传参和参数的返回(包含第三方库)

from PIL import Image
import face_recognition
import cv2
import matplotlib.pyplot as plt

filename="3.jpg"
# 将jpg文件加载到numpy 数组中
image = face_recognition.load_image_file(filename)
# 使用CNN模型
#face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=0, model="cnn")
face_locations =face_recognition.face_locations(image, number_of_times_to_upsample=1, model="hog")
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)
img =cv2.imread(filename)
for face_location in face_locations:
    top, right, bottom, left = face_loca

你可能感兴趣的:(python)