Python | Face recognition system (face recognition, liveness detection, background blur, key point detection)

This blog is an introduction to the face recognition system project

Project GitHub complete source code address: Su-Face-Recognition: A face recognition for user login

1. Operating environment

        This system can run in the Windows environment based on the PC operating system, and requires the Windows operating system to be installed with Python 3.9 and above, and the MySQL database has been installed.

Python3.9 installation: Python 3.9 installation tutorial

MySQL installation: MySQL 8.0.26 installation tutorial

2. Development environment

1. Development language

        This project uses Python as the main development language.

2. Development tools

        Front end: Qt-Designer

        Backend: PyCharm

        Database: Navicat

        Package management tool: Anacoda

PyCharm installation: PyCharm installation tutorial

Anacoda installation: Anaconda installation tutorial

Qt-Designer installation: Qt Designer installation tutorial

Qt-Designer use: Qt Designer tool use

Navicat installation: Navicat installation tutorial

3. Main development technologies

(1)Dlib

        Dlib is an open source library for machine learning. It contains many algorithms for machine learning. It is very convenient to use, just include the header file directly, and does not depend on other libraries (the source code of the image codec library comes with it). Dlib can help create a lot of complex machine learning software to help solve practical problems. At present, Dlib has been widely used in industry and academic fields, including robotics, embedded devices, mobile phones and large-scale high-performance computing environments.

Install Dlib above Python3.9: [Python] dlib does not need to be compiled and installed dlib-19.23.0-cp39-cp39-win_amd64.whl_dlib cp39-CSDN Blog

(2)OpenCV

        OpenCV is an open source computer vision library that provides many functions that implement computer vision algorithms very efficiently. It is developed in C/C++ and also provides interfaces for other languages ​​such as Python, Java, and MATLAB. OpenCV has a wide range of applications, including image stitching, image noise reduction, product quality inspection, human-computer interaction, face recognition, motion recognition, motion tracking, driverless driving, etc. OpenCV also provides machine learning modules, which can use machine learning algorithms such as normal Bayesian, K nearest neighbors, support vector machines, decision trees, random forests, and artificial neural networks.

OpenCV installation: OpenCV installation tutorial

(3)face_recognition

        face_recognition is a powerful, simple, and easy-to-use face recognition open source project, and it is equipped with complete development documents and application cases, especially compatible with the Raspberry Pi system. The face recognition model in face_recognition comes from the open source machine learning library Dlib, and most of the models are tested with the Labeled Faces in the Wild face dataset, with an accuracy rate as high as 99.38%. However, the recognition accuracy of children and Asian faces needs to be improved.

Installation prerequisites: dlib installed

face_recognition installation: face_recognition installation tutorial

face_recognition Chinese tutorial: face_recognition GitHub

(4)PyQt5

        Qt is a set of C++ libraries and development tools, including platform GUI, networking, threads, regular expressions, SQL database, SVG, OpenGL, XML, user and application settings, location and location services, short-range communication (NFC) and Bluetooth), web browsing, 3D animations, graphs, 3D data visualization and interfacing with app stores.

        PyQt is a GUI widget toolkit, a Python interface to Qt, and one of the most powerful and popular cross-platform GUI libraries. PyQt5 implements more than 1000 classes in Qt as a set of Python modules.

PyQt installation: PyQt5 installation tutorial

PyQt5 official website: QtWidgets — PyQt Documentation v5.15.4

(5) Baidu AI Open Platform

        The Baidu AI open platform provides the world's leading artificial intelligence technologies such as voice, image, and NLP, and opens up the two major industry ecosystems of conversational artificial intelligence systems and intelligent driving systems. Among them, the face recognition technology is based on deep learning, which can accurately identify face information in pictures and video streams, including face detection and attribute analysis, face comparison, face search, liveness detection, face special effects and other capabilities. It can be flexibly applied to industry scenarios such as finance, pan-security defense, and production safety to meet business needs such as identity verification, face-based attendance, gate access, and interactive entertainment.

Baidu AI Open Platform: Face Recognition__Baidu Smart Cloud 

3. Function overview

        This project develops a user login and registration system based on face recognition technology, which can be divided into two parts, namely the client program and the administrator program.

        The functions of the client program include three main functions of user registration, user login, and user logout, and four auxiliary functions of liveness detection, face comparison, fine segmentation, and key point detection.

        The functions of the administrator program include four main functions: administrator login, user logout, user unlock, and history record.

1. Enter the system as a user

(1) User registration

        After the user clicks to register and enters personal information into the system, including account number, password, gender and more information, the system automatically captures and calculates the current user's face information and saves it in the database.

(2) User login

        After the user clicks the login button and enters the account number and password, the system searches the database and returns whether the information is verified. If the information verification is passed, the system will perform liveness detection and face recognition on the user of the current camera to finally determine whether the login is successful. Once a user fails the liveness detection or face recognition more than 3 times during the login operation, the system is required to lock the current user's account and a corresponding warning will pop up. 

(3) User logout

        When the user clicks Logout, the system logs out the currently logged-in user.

(4) Liveness detection

        The user clicks the liveness detection, and the system detects whether the user is cheating by using an electronic screen or photos, and then the system requires the user to follow the system prompts to complete the specified actions, including shaking the head left, shaking the head right, blinking, opening the mouth, etc. The user is prompted to pass the liveness detection after completion. If the user times out, the liveness detection will be terminated, and it will be prompted that the liveness detection has not passed.

(5) Face comparison

        The user clicks Face Comparison and selects any two pictures in jpg or png format with faces. After clicking the compare button, the system confirms whether they are the same person.

(6) Blurred background 

        The user clicks on the background blur, and the system quickly recognizes the user's body part and blurs the background.

(7) Attitude detection

        The user clicks the status detection, and the system quickly recognizes the user's body parts, and marks each key point of the person, including eyes, mouth, torso, limbs, etc.

2. Enter the system as an administrator

(1) Administrator login

        The administrator clicks on the administrator to log in, and after entering the account number and password, the system is required to quickly query the stored data and determine whether the login is successful.

(2) User unlock

        The administrator clicks the user to unlock, and after entering the account number and password of the user to be unlocked, the system is required to quickly query the stored data and determine whether the unlock is successful.

(3) User logout

        The administrator clicks the user to unlock, and after entering the account number and password of the user to be canceled, the system is required to quickly query the stored data and determine whether the cancellation is successful.

(4) History

        The administrator clicks on the history record, and the system automatically opens the Excel sheet, which records the user information that has logged in to the current system in the recent period, including log-in time, log-in camera, user name, etc.

4. Detailed Code Explanation

        1. UI code

        2. Client code

        3. Admin code

        4. Project GitHub source code

GitHub complete source code address: face recognition system GitHub

Project structure:

Guess you like

Origin blog.csdn.net/sun80760/article/details/130230520