Giter Club home page Giter Club logo

face_compare_gui_v2's Introduction

python-tkinter系列最终弹之人脸比对

python -使用tkinter编写的人脸比对小工具,face compare, tkinter, face_recognition

Requirements

  • Python3
  • PIL
  • uuid
  • face_recognition
  • cv2

主界面

init_window部分是程序的UI设计部分,然后就是实现图中三个按钮的点击事件,其中“请选择图片”的两个按钮功能一样,都是点击选择文件,并加载到页面上,替换掉首页的图片。

提交按钮实现的就是两张人脸图片比对的逻辑了:

有一个需要注意的地方是:opencv不能加载带中文图片路径,所以程序中用PILImage.open()加载图片,并使用Image.save()重新保存一份到自己定义的文件夹,然后还定义了一个resize_img()函数,对过大的图片进行等比例缩放,并保存下来,提高运算的效率。

人脸比对使用了最简单的人脸识别库:face_recogniton,首先通过face_recognition.load_image_file()加载图片,毕竟用了别人的库,就得按照人家的方式进行加载。

然后通过face_recognition.face_encodings()提取人脸的特征,提取出来的是一个128维的向量,最后使用face_recognition.face_distance()计算两个128向量的欧式距离,计算方式如下

当然这里就不用自己计算了,face_distance()已经帮你实现好了。

人脸比对还有很多其他的方法,比如facenetarcface。这里框架已经搭好了,剩下的你们可以根据需要去替换自己的算法。

好了,我们来运行一下吧。

python main.py

face_compare_gui_v2's People

Contributors

humyue avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.