当前位置: 首页 > news >正文

python比较两张图片并获取精准度

先安装依赖库dlib、face_recognition、cv2

下载wheel文件:

python3.6:

dlib-19.7.0-cp36-cp36m-win_amd64.whl: https://drfs.ctcontents.com/file/1445568/768652503/68cb5d/Python/dlib-19.7.0-cp36-cp36m-win_amd64.whl

python3.7:

dlib-19.17.99-cp37-cp37m-win_amd64.whl: https://drfs.ctcontents.com/file/1445568/768652504/b726a5/Python/dlib-19.17.99-cp37-cp37m-win_amd64.whl

python3.8:

dlib-19.19.0-cp38-cp38-win_amd64.whl.whl: https://drfs.ctcontents.com/file/1445568/768652508/77e657/Python/dlib-19.19.0-cp38-cp38-win_amd64.whl.whl

再使用pip安装face_recognition、cv2

pip install opencv-python
pip install face-recognition

比较两张图片

import cv2
import face_recognition

def find_face_encodings(image_path):
    # reading image
    image = cv2.imread(image_path)
    
    # get face encodings from the image
    face_enc = face_recognition.face_encodings(image)
    
    # return face encodings
    return face_enc[0]

# getting face encodings for first image
image_1 = find_face_encodings("image_1.png")

# getting face encodings for second image
image_2  = find_face_encodings("image_2.png")

# checking both images are same
is_same = face_recognition.compare_faces([image_1], image_2)[0]
print(f"Is Same: {is_same}")
if is_same:
    # finding the distance level between images
    distance = face_recognition.face_distance([image_1], image_2)
    distance = round(distance[0] * 100)
    
    # calcuating accuracy level between images
    accuracy = 100 - round(distance)
    
    print("The images are same")
    print(f"Accuracy Level: {accuracy}%")
else:
    print("The images are not same")

输出:

Is Same: True

The images are same

Accuracy Level: 70%

相关文章:

  • 旅游网站建设方案书/安徽网络推广和优化
  • 广东门户网站建设/整站优化深圳
  • 网站制作温州/网站创建公司
  • wordpress英文显示改中文/怎样做品牌推广
  • 怎样做运营一个网站/怎么优化电脑系统
  • wordpress目录绑定外部链接/网络推广方案怎么写
  • Best Buy 百思买DROP SHIP EDI需求分析
  • 年度总结-你觉得什么叫生活?
  • <<零入门容器云网络实战>>技术专栏发布介绍
  • “水果零售第二股”百果园上市首日市值近百亿
  • 【OpenShift】项目上OpenShift遇到的问题总结
  • Python采集常用:谷歌浏览器驱动——Chromedriver 插件安装教程
  • WSL子系统环境下连接ssh的坑
  • Git常用命令(全局设置获取仓库)
  • python环境构造
  • 解决ElementUI导航栏重复点菜单报错问题
  • 3422. 左孩子右兄弟
  • 1-Node.js简单介绍