python 人脸检测

import face_recognition
import cv2
image = face_recognition.load_image_file("face2.jpg")
face_locations = face_recognition.face_locations(image)
facenum = len(face_locations)
for i in range(0, facenum):
    top =  face_locations[i][0]
    right =  face_locations[i][1]
    bottom = face_locations[i][2]
    left = face_locations[i][3]
    start = (left, top)
    end = (right, bottom)
    color = (0, 0, 255)
    thickness = 2
    cv2.rectangle(img, start, end, color, thickness)

cv2.namedWindow(u"识别")
cv2.imshow(u"识别", img)

cv2.waitKey(0)
cv2.destroyAllWindows()

猜你喜欢

转载自blog.csdn.net/weixin_41896508/article/details/80902354