Cvpresentation 190812154654

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Master’s EMM – Computer Vision Project

Real Time Facial


👦 Recognition using
Open CV and Python
(using Laptop’s Webcam)
Under guidance of : Prof. Dr. Stefan Elser.

Presented By:
• Akash Satamkar (31672)
• Krupali Rana (31668)
Introduction

• Implementation of Face Detection and Recognition by simply


using Laptop’s Webcam.
• Real Time face detection using Face Detection algorithm to
visualize human faces in Digital image.
• We are using video feed from a webcam which are a sequence of
frames of still images being updated one after the other to
recognize and predict faces.

2
Goals

• To train the image dataset and store them with proper


faceID.
• Passing the frames captured by webcam one by one to
detect faces.
• Depending upon the confidence level, determine
whether to label the predicted face or not.
• Validating the test results with multiple test cases.
• Improving the training data with larger data sets of
images.

3
Software Analysis

• Anaconda IDE
• SpyDer studio with Python 3.7
version
• Open CV libraries

4
Haar Cascade Classifier

▪ Haar feature based classifier is a machine learning


based approach
▪ Detect objects in images
▪ Train a lot of Positive and negative images
▪ The haarcascade_frontalface_default.xml is a haar
cascade designed by OpenCV to detect the frontal
face

5
Positive and Negative images

▪ Positive face example images provide a lot of variations. It


manually crops and normalize each face into a standard
size Positive face set of images

▪ Negative non face examples are images that don’t contain


faces. They are taken from arbitrary images which do not
contain the object you want to detect.

Negative non face set of images

6
detectMultiscale() Module
Computation of Features - To create rectangle around the faces
detected in image.
Parameters :
scaleFactor = Adjust the size of image
minNeighbors = Specify how many
neighbors person can have

Cascade of Classifiers
Features are grouped together into stages
of classifiers.
If a window fails at 1st stage , it is discarded.
Else it is passed to 2nd stage of features.
The window which passes all stages is face
region.
7
• Local Binary Pattern is simple but
efficient texture operator.
LBPH Algorithm • It is combined with HOG (Histogram of
Gradients) to recognize faces in image.

It uses 4 parameters : {Radius, Neighbours, Grid X, Grid Y }

LBP Operation:
It uses sliding window concept based on
parameters Radius and Neighbours.

8
• Extracting a portion of this grayscale image (3 x 3 pixels)
• Represented in a matrix of 3 x 3 of pixel intensities with each pixel intensity in range (0 – 255)
• Using centre value as threshold and perform thresholding. (0 = < threshold, 1 = > threshold)
• Obtain binary values and concatenate in clockwise manner.
• Convert binary value to decimal value and set it to centre value.
• In the end , we have obtained a new image with better characteristics.

9
Image Reference : https://towardsdatascience.com/face-recognition-how-lbph-works-90ec258c3d6b
LBP combined with Histogram to predict faces:

• Now we divide the new image generated into grids with Grid X and Grid Y parameters.
• Obtain the histogram of each grid .
• Now concatenate the individual histograms to obtain a new and bigger histogram.
• The final histogram represents characteristics of original image.

10
Image Reference : https://towardsdatascience.com/face-recognition-how-lbph-works-90ec258c3d6b
• The algorithm is trained and each histogram is used to represent each image of training
dataset.
• We compare the two histograms and return the image with closest histogram.
• The output is the ID with closest match and the calculated Euclidean distance can be a
confidence measurement.

▪ Confidence level :
The lower the value of confidence the better is the match which means the distance
between two histograms is closer.
Then we can use this confidence level to predict the face by defining the threshold.

This method is illumination invariant in nature.


Robust method to represent local features in image

11
Some important OpenCV functions :
1. FaceDetection function

2. Label for training data function

12
3. Draw Rectangle function

4. Put Text function

5. Train Classifier function

13
Our Process is easy

Creating Dataset Training Dataset Predicting Faces in


Real time
Creating two subdirectories Training the dataset
and loading them with set of using LBPH algorithm Loading the trained data
individual images for and save the trained file and predicting faces
training. data into “.yml” file. frame by frame and label
them.

14
Flowchart

15
16
Testing and Results
Case 1: Single face detection and recognition

Place your screenshot here

17
Case 2: Multiple faces

Place your screenshot here

18
Case 3: Multiple faces with unknown labelled person

Place your screenshot here

19
Case 4: Using different props on face

Place your screenshot here

20
Case 4: Using different props on face

Place your screenshot here

21
Case5: Masking certain regions of Face

Place your screenshot here

22
Further Enhancements

• The training dataset can be improved by including


more no. of sample images.

• We can further implement CNN (Convolution Neural


Networks) using TensorFlow for better Face
Recognition.

23
References

▪ Working of LBPH : https://towardsdatascience.com/face-recognition-how-lbph-works-


90ec258c3d6b
▪ Article on face detection basics : https://www.datacamp.com/community/tutorials/face-
detection-python-opencv
▪ Link for downloading Anaconda package - https://www.anaconda.com/distribution/
▪ Link for Basics of Haar Cascade classifier-
https://docs.opencv.org/3.4.1/d7/d8b/tutorial_py_face_detection.html
▪ https://www.learnopencv.com/face-detection-opencv-dlib-and-deep-learning-c-python/

24
😉
THANKS!

Any questions?

25

You might also like