人脸识别python face_recognize_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= face_recognition.compare_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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值