Skip to content

Detect and recognize faces on images or via your camera with python, woohoo!

Notifications You must be signed in to change notification settings

Dacili/Face-recognition

Repository files navigation

Face detection and face recognition

So what is the difference?
image
Detection only detect faces, while recognition is actually face detection + face identification.

There are two files in this project:

  1. faceDetection.py
  2. faceRecognition.py
    Names are selfexplanatory haha. In order to exit the scripts press Esc.

Face detection

Firstly we have to use some classifier (Github repo for classifiers, used in faceDetection.py: https://github.com/opencv/opencv/tree/4.x/data/haarcascades) in order to train the opencv object. After that we're using the camera, and analyzing the frames in order to find the objects for which we used the classifiers. Once objects are detected on the image, show the image.
face detection

Face recognition demo

Folder faces, acts like a "database" for known faces. There we put images of known faces, where name of the image, is the name of the person. At the beginning of the script we're performing encoding (128-dimension face encoding for each face in the image) for known faces.
After that, we're using the camera, and analyzing the frames, in order to detect faces. Once faces are detected, we're also encoding that image, and after that trying to find a matches with our known faces. If we have more matches with known faces, then we're finding the one that is the most similar to the person. When we choose the most similar person, then the name is shown on the image, otherwise Unknown is shown.
Check the face_recognition pkg documentation (https://face-recognition.readthedocs.io/en/latest/face_recognition.html).

pyhonFaceRecognitionLatestMedi.mp4

Specifications:
Python version: 3.11.1
pip 22.3.1
opencv-python==4.7.0.68
dlib==19.24.99
face-recognition==1.3.0
IDE: Python Charm

In packagesFile.txt there are all packages versions info. To get that I run:

pip freeze > packagesFile.tx

To install these packages when pulling the code run:

pip install -r packagesFile.tx

Note: I had a lot of issues when trying to install dlib (a toolkit for making real world machine learning and data analysis applications) library which was needed for face-recognition pkg.
I succeeded to install it with this stackoverflow answer: https://stackoverflow.com/questions/74476152/error-in-installing-dlib-library-in-python3-11/74573179#74573179


About

Detect and recognize faces on images or via your camera with python, woohoo!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages