Skip to content

imehar/face-recognition

Repository files navigation

Face Recognition

Authorization of Person identity using Computer Vision

This python script will take name of image as input (in the same directory) and find if the face of person is in our database (the image folder), which has the faces of known person who are authorized to enter the premises.

Concept

There will be a camera at the entry-point of area. On detecting a vechicle or person trying to enter, the image (frame from the video feed) will be passed to this srcipt, which will identify the person.

Working

It is working on the deep learning model for face recognition, which on detection of face creates 128 embeddings, which are unique for unique (actually they are similar i.e. embeddings for same face have less euclidian distance). The model creates these embeddings, which are used to identify if the person is in our database or not. If the embeddings for a face in our database and the face detected in image are similar, then person is recognised, else unauthorized person. In this, I've used a pre-trained model by dlib. It detects faces, using 68 points in the eyebrows, eyes, nose, lips, chin area.

Requirements

-dlib

  pip install dlib

-opencv

 pip install opencv-python

-face_recognition

 pip install face_recognition

-numpy

 pip install numpy

Run

Run the script by typing following command in the command prompt or terminal of current directory.

python loadimages.py

This will create embeddings for all the images in the images folder (i.e. images in our database from which we will identify the faces) and store it in encodings.npy

This might take some time, depending on the number of images in folder, so be patient.

If you've already ran the loadimages.py script previously and have the encodings.npy file, the run the addimages.py script , this will only find embeddings of new faces images in image folder, instead of all the faces.

Now, to recognise a person in an image run..

python faceDetection.py , in the command prompt or terminal of the current directory. then enter the name of image from which you want to identify a face.

Note:- This image folder and the image in input should be in the same directory of python script.