Facial Recognition System
Facial Recognition System
PROGRESS REPORT
FACIAL RECOGNITION SYSTEM
Such as light, angle, beauty mode enabled etc. The smart phone industry, uses a pre- trained
model to recognize the gender and age of the person. The pre-trained model uses deep
learning to identify features using which it predicts the gender and age of the person based on
identifying and analyzing facial features.
Problem Statement
The problem statement is to recognize the face that is feeded into the model via webcam. The
image will be feeded to the pre-trained model via a webcam. This venture was finished with
this incredible "Open Source Computer Vision Library", the OpenCV. OpenCV was intended
for computational proficiency and with a solid spotlight on continuous applications. In this
way, it's ideal for ongoing face acknowledgment utilizing a camera.
Overview of the classifier
Thanks to OpenCV, coding facial recognition is now easier than ever. There
are three easy steps to computer coding facial recognition, which are similar
to the steps that our brains use for recognizing faces. These steps are:
1. Haar Classifier
2. LBP Classifier
Each OpenCV face detection classifier has its pros and cons, but the major
differences are in accuracy and speed.
So, in case more accurate detections are required, Haar classifier is the way
to go. This bad boy is more suitable in technology such as security systems or
high-end stalking.
As any other classifier, the Local Binary Patterns, or LBP in short, also needs
to be trained on hundreds of images. LBP is a visual/texture descriptor, and
thankfully, our faces are also composed of micro visual patterns.
So, LBP features are extracted to form a feature vector that classifies a face
from a non-face.
Each training image is divided into some blocks as shown in the picture below.
For each block, LBP looks at 9 pixels (3×3 window) at a time, and with a
particular interest in the pixel located in the center of the window.
Then, it compares the central pixel value with every neighbor's pixel value
under the 3×3 window. For each neighbor pixel that is greater than or equal to
the center pixel, it sets its value to 1, and for the others, it sets them to 0.
After that, it reads the updated pixel values (which can be either 0 or 1) in a
clockwise order and forms a binary number. Next, it converts the binary
number into a decimal number, and that decimal number is the new value of
the center pixel. We do this for every pixel in a block.
Now, after you get a list of local binary patterns, you convert each one into a
decimal number using binary to decimal conversion (as shown in above
image) and then you make a histogram of all of those decimal values. A
sample histogram looks like this:
Histogram Sample.
And this is how our Face Detector will look once we finish coding it:
Coding Face Recognition using Python and OpenCV
We are going to divide the Face Recognition process into three steps:
CODE:
Let's start with a simple task, load our input image, convert it to grayscale
mode and then display it.
For this, we’ll need to keep at arms reach this very handy
function cv2.cvtColor (converting images to grayscale).
Before we can continue with face detection, we have to load our LBP cascade
classifier.
Now that we know a straightforward way to detect faces, we could now find
the face in our test image .
The following code will try to detect a face from the image and, if detected, it
will print the number of faces that it has found, which in our case should be 1.
#let's detect multiscale (some images may be closer to camera than others) images
faces = lpb_face_cascade.detectMultiScale(gray_img, scaleFactor=1.1, minNeighbors=5);
Faces found: 1
Next, let's loop over the list of faces (rectangles) it returned and drew those
rectangles using yet another built-in OpenCV rectangle function on our
original colored image to see if it found the right faces:
#go over list of faces and draw them as rectangles on original colored
img for (x, y, w, h) in faces:
cv2.rectangle(test1, (x, y), (x+w, y+h), (0, 255, 0), 2)
Let’s display the original image to see the rectangles we just drew and verify
that detected faces are real ones and not any false positives.