200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > python模块cv2人脸识别_python face_recognition模块实现人脸识别

python模块cv2人脸识别_python face_recognition模块实现人脸识别

时间:2024-06-22 05:06:05

相关推荐

python模块cv2人脸识别_python face_recognition模块实现人脸识别

import face_recognition #人脸识别库 pip cmake dlib

import cv2

#读取图像

face_image1 = face_recognition.load_image_file("1.jpg")

face_image2 = face_recognition.load_image_file("2.jpg")

# print(face_image)

face_encoding1 = face_recognition.face_encodings(face_image1)

face_encoding2 = face_recognition.face_encodings(face_image2)

face_location1 = face_recognition.face_locations(face_image1)

face_location2 = face_recognition.face_locations(face_image2)

# print(face_encoding1,face_encoding2)

results= pare_faces([face_encoding1[0]],face_encoding2[0],tolerance=0.5)

# print(results)

top,right,bottom,left = face_location2[0]

cv2.rectangle(face_image2,(left,top),(right,bottom),(0,255,0),2)

cv2.putText(face_image2,"xinyuuliu",(left-10,top-10),cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,0,0),2)

#绘图

face_image_rgb = cv2.cvtColor(face_image2,cv2.COLOR_BGR2RGB)

cv2.imshow("Output",face_image_rgb)

cv2.imwrite("result.jpg",face_image_rgb,[int(cv2.IMWRITE_JPEG_QUALITY),100])

cv2.waitKey(0)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。