Face Detection (Python)
Face Detection (Python)
[ college logo ]
A STYDY ON
Face Recognition
1
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION, MUMBAI
Certificate
This is to certify that Mr. /Mrs.
in Engineering & Technology at [ your college name ] , has completed the Micro
Head of
Institute
2
INDEX
Abstract
3
The face is one of the easiest ways to distinguish the individual identity of each other. Face
recognition is a personal identification system that uses personal characteristics of a person to
identify the person's identity. Human face recognition procedure basically consists of two phases,
namely face detection, where this process takes place very rapidly in humans, except under
conditions where the object is located at a short distance away, the next is the introduction,
which recognize a face as individuals. Stage is then replicated and developed as a model for
facial image recognition (face recognition) is one of the much-studied biometrics technology and
developed by experts.
There are two kinds of methods that are currently popular in developed face recognition pattern
namely, Eigenface method and Fisherface method. Facial image recognition Eigenface method is
based on the reduction of facedimensional space using Principal Component Analysis (PCA) for
facial features.
The main purpose of the use of PCA on face recognition using Eigen faces was formed (face
space) by finding the eigenvector corresponding to the largest eigenvalue of the face image. The
area of this project face detection system with face recognition is Image processing.
The software requirements for this project is matlab software. Keywords: face detection, Eigen
face, PCA, matlab Extension: There are vast number of applications from this face detection
project, this project can be extended that the various parts in the face can be detect which are in
various directions and shapes.
4
Introduction
Face recognition is the task of identifying an already detected object as a known or unknown
face.Often the problem of face recognition is confused with the problem of face detectionFace
Recognition on the other hand is to decide if the "face" is someone known, or unknown, using
for this purpose a database of faces in order to validate this input face.
1.2 FACE DETECTION: Face detection involves separating image windows into two classes;
one containing faces (tarning the background (clutter). It is difficult because although
5
commonalities exist between faces, they can vary considerably in terms of age, skin colour and
facial expression. The problem is further complicated by differing lighting conditions, image
qualities and geometries, as well as the possibility of partial occlusion and disguise. An ideal
face detector would therefore be able to detect the presence of any face under any set of lighting
conditions, upon any background. The face detection task can be broken down into two steps.
The first step is a classification task that takes some arbitrary image as input and outputs a
binary value of yes or no, indicating whether there are any faces present in the image. The
second step is the face localization task that aims to take an image as input and output the
location of any face or faces within that image as some bounding box with (x, y, width, height).
The face detection system can be divided into the following steps:-
1. Pre-Processing: To reduce the variability in the faces, the images are processed before they
are fed into the network. All positive examples that is the face images are obtained by cropping
images with frontal faces to include only the front view. All the cropped images are then
corrected for lighting through standard algorithms.
2. Classification: Neural networks are implemented to classify the images as faces or nonfaces
by training on these examples. We use both our implementation of the neural network and the
Matlab neural network toolbox for this task. Different network configurations are experimented
with to optimize the results. 3. Localization: The trained neural network is then used to search
for faces in an image and if present localize them in a bounding box. Various Feature of Face on
which the work has done on:- Position Scale Orientation Illumination.
Literature Survey
6
Title of the book Author Publication
William Sanders
Learning PHP Design Paperback
Patterns
7
Interest in digital image processing methods stems from two principal application areas:
In this second application area, interest focuses on procedures for extracting image information
in a form suitable for computer processing.
Examples includes automatic character recognition, industrial machine vision for product
assembly and inspection, military recognizance, automatic processing of fingerprints etc.
Image:
Am image refers a 2D light intensity function f(x, y), where(x, y) denotes spatial coordinates and
the value of f at any point (x, y) is proportional to the brightness or gray levels of the image at
that point. A digital image is an image f(x, y) that has been discretized both in spatial coordinates
and brightness. The elements of such a digital array are called image elements or pixels.
To be suitable for computer processing, an image f(x, y) must be digitalized both spatially and in
amplitude. Digitization of the spatial coordinates (x, y) is called image sampling. Amplitude
digitization is called gray-level quantization.
The storage and processing requirements increase rapidly with the spatial resolution and the
number of gray levels.
Example: A 256 gray-level image of size 256x256 occupies 64k bytes of memory.
FACE DETECTION
The problem of face recognition is all about face detection. This is a fact that seems quite bizarre
8
to new researchers in this area. However, before face recognition is possible, one must be able to
reliably find a face and its landmarks. This is essentially a segmentation problem and in practical
systems, most of the effort goes into solving this task. In fact the actual recognition based on
features extracted from these facial landmarks is only a minor last step.
There are two types of face detection problems:
1) Face detection in images and 2) Real-time face detection
Most face detection systems attempt to extract a fraction of the whole face, thereby eliminating
most of the background and other areas of an individual's head such as hair that are not necessary
for the face recognition task. With static images, this is often done by running a across the
image. The face detection system then judges if a face is present inside the window (Brunelli and
Poggio, 1993). Unfortunately, with static images there is a very large search space of possible
locations of a face in an image
Real-time face detection involves detection of a face from a series of frames from a video
capturing device. While the hardware requirements for such a system are far more stringent,
from a computer vision stand point, real-time face detection is actually a far simpler process than
detecting a face in a static image. This is because unlike most of our surrounding
Department of ECE Page 28 environment, people are continually moving. We walk around,
blink, fidget, wave our hands about, etc.
It is process of identifying different parts of human faces like eyes, nose, mouth, etc… this
9
process can be achieved by using MATLAB code In this project the author will attempt to detect
faces in still images by using image invariants. To do this it would be useful to study the grey
scale intensity distribution of an average human face. The following 'average human face' was
constructed from a sample of 30 frontal view human faces, of which 12 were from females and
18 from males. A suitably scaled color map has been used to highlight grey-scale intensity
differences.
FACE RECOGNITION
Over the last few decades many techniques have been proposed for face recognition. Many of the
techniques proposed during the early stages of computer vision cannot be considered successful,
but almost all of the recent approaches to the face recognition problem have been creditable.
According to the research by Brunelli and Poggio (1993) all approaches to human face
recognition can be divided into two strategies:
(1) Geometrical features and
(2) Template matching.
This technique involves computation of a set of geometrical features such as nose width and
length, mouth position and chin shape, etc. from the picture of the face we want to recognize.
This set of features is then matched with the features of known individuals. A suitable metric
such as Euclidean distance (finding the closest vector) can be used to find the closest match.
Most pioneering work in face recognition was done using geometric features (Kanade, 1973),
although Craw et al. (1987) did relatively recent work in this area.
The advantage of using geometrical features as a basis for face recognition is that recognition is
possible even at very low resolutions and with noisy images (images with many disorderly pixel
intensities). Although the face cannot be viewed in detail its overall geometrical configuration
can be extracted for face recognition. The technique's main disadvantage is that automated
extraction of the facial geometrical features is very hard. Automated geometrical Department of
10
ECE Page 35 feature extraction based recognition is also very sensitive to the scaling and
rotation of a face in the image plane (Brunelli and Poggio, 1993). This is apparent when we
examine Kanade's(1973) results where he reported a recognition rate of between 45-75 % with a
database of only 20 people. However if these features are extracted manually as in Goldstein et
al. (1971), and Kaya and Kobayashi (1972) satisfactory results may be obtained.
This is similar the template matching technique used in face detection, except here we are not
trying to classify an image as a 'face' or 'non-face' but are trying to recognize a face.
Whole face, eyes, nose and mouth regions which could be used in a template matching strategy.
The basis of the template matching strategy is to extract whole facial regions (matrix of pixels)
and compare these with the stored images of known individuals. Once again Euclidean distance
can be used to find the closest match. The simple technique of comparing grey-scale intensity
values for face recognition was used by Baron (1981). However there are far more sophisticated
methods of template matching for face recognition. These involve extensive preprocessing and
transformation of the extracted grey-level intensity values.
Implementation in Python:
Now, let us go through the code to understand how it works:
import os
import face_recognition
These are simply the imports. We will be using the built-in os library to read all the images in
our corpus and we will use face_recognition for the purpose of writing the algorithm.
11
# make a list of all the available images
images = os.listdir('images')
This simple code helps us identify the path of all of the images in the corpus. Once this line is
executed, we will have:
image_to_be_matched = face_recognition.load_image_file('my_image.jpg')
To make sure that the algorithms are able to interpret the image, we convert the image to a
feature vector:
image_to_be_matched_encoded = face_recognition.face_encodings(
image_to_be_matched)[0]
12
# iterate over each image
current_image_encoded = face_recognition.face_encodings(current_image)[0]
result = face_recognition.compare_faces(
[image_to_be_matched_encoded], current_image_encoded)
if result[0] == True:
13
else:
OUTPUT:
Matched: shah_rukh_khan.jpg
14
Not matched: jeff_bezos.jpg
Conclusion
We have concluded that we have successfully developed a PHP based web application for
creating the assignment for students in the easiest way. We have implemented FPDF library and
do a lot of customization so that teachers don’t need to change anything. We have applied a lot
of fonts to this pdf creation. In this project development we have also developed a question bank
15
section through which teachers can get their question from respective department.
References
Books:
16
The Joy of PHP Programming: A Beginner’s Guide – by Alan Forbes
Head First PHP & MySQL – by Lynn Beighley & Michael Morrison
Websites:
https://www.w3schools.com/php/
https://www.tutorialspoint.com/php/index.htm
17