System Requirement Specification For Face Recognition System
System Requirement Specification For Face Recognition System
The face recognition is a fairly controversial subject right now. A system such as this can
recognize and track dangerous criminals and terrorists in a crowd, but some contend that it is
an extreme invasion of privacy. The proponents of large-scale face recognition feel that it is
a necessary evil to make our country safer. It could benefit the visually impaired and allow
them to interact more easily with the environment. Also, a computer vision-based
authentication system could be put in place to allow computer access or access to a specific
room using face recognition. Another possible application would be to integrate this
technology into an artificial intelligence system for more realistic interaction with humans.
We propose a face recognition method called the PCA (Principal Component Analysis).
Principal Component Analysis (PCA) is a statistical method under the broad title of factor
analysis. The purpose of PCA is to reduce the large dimensionality of the data space
(observed variables) to the smaller intrinsic dimensionality of feature space (independent
variables), which are needed to describe the data economically. This is the case when there is
a strong correlation between observed variables. The jobs which PCA can do are prediction,
redundancy removal, feature extraction, data compression, etc. Because PCA is a known
powerful technique which can do something in the linear domain, applications having linear
models are suitable, such as signal processing, image processing, system and control theory,
communications, etc. The main idea of using PCA for face recognition is to express the large
1-D vector of pixels constructed from 2-D face image into the compact principal components
of the feature space. This is called eigenspace projection. Eigenspace is calculated by
identifying the eigenvectors of the covariance matrix derived from a set of fingerprint images
(vectors).
1|Page
1. INTRODUCTION
1.1. PCA
The Principal Component Analysis (PCA) is one of the most successful techniques that have
been used in image recognition and compression. PCA is a statistical method under the broad
title of factor analysis. The purpose of PCA is to reduce the large dimensionality of the data
space (observed variables) to the smaller intrinsic dimensionality of feature space
(independent variables), which are needed to describe the data economically. This is the case
when there is a strong correlation between observed variables.
The jobs which PCA can do are prediction, redundancy removal, feature extraction,
data compression, etc. Because PCA is a classical technique which can do something in the
linear domain, applications having linear models are suitable, such as signal processing,
image processing, system and control theory, communications, etc.
Face recognition has many applicable areas. Moreover, it can be categorized into face
identification, face classification, or sex determination. The most useful applications contain
crowd surveillance, video content indexing, personal identification (ex. driver’s licence), mug
shots matching, entrance security, etc. The main idea of using PCA for face recognition is to
express the large 1-D vector of pixels constructed from 2-D facial image into the compact
principal components of the feature space. This can be called eigenspace projection.
Eigenspace is calculated by identifying the eigenvectors of the covariance matrix derived
from a set of facial images (vectors).
A 2-D facial image can be represented as 1-D vector by concatenating each row (or column)
into a long thin vector. Let’s suppose we have M vectors of size N (= rows of image £
columns of image) representing a set of sampled images. pj’s represent the pixel values.
x i= [ p 1 … … p N ] T ; i=1 ; … … ; M (1)
The images are mean centred by subtracting the mean image from each image vector. Let m
represent the mean image.
M
m=1/ M ∑ xi (2)
i=1
w i= x i – m (3)
Our goal is to find a set of e i which have the largest possible projection onto each of the w i.
We wish to find a set of M orthonormal vectorse i for which the quantity
M
1
λ i= ∑ (e T w )2
M i =1 i n
(4)
2|Page
is maximized with the orthonormality constraint
e Tl e k =δ lk (5)
e λ
It has been shown that the i and i are given by the eigenvectors and eigenvalues of the
covariance matrix
C = W WT (6)
where W is a matrix composed of the column vectors w i placed side by side. The size of C is
N × N which could be enormous. For example, images of size 64 × 64 create the covariance
matrix of size 4096×4096. It is not practical to solve for the eigenvectors of C directly. A
common theorem in linear algebra states that the vectors e i and scalars λ i can be obtained by
solving for the eigenvectors and eigenvalues of the M ×M matrixW T W . Let d i and μi be the
eigenvectors and eigenvalues of W T W , respectively.
W T W di =μ i di (7)
WW T (W d i ) = μi (Wd i ) (8)
which means that the first M - 1 eigenvectors e i and eigenvalues λ i of W W T are given by Wd i
and μirespectively. Wd ineeds to be normalized in order to be equal to e i Since we only sum up
a finite number of image vectors, M, the rank of the covariance matrix cannot exceed M - 1
(The -1 come from the subtraction of the mean vector m).
Ω=[v 1 v 2 v 3 … … .. v M ]T
1 (9)
where vi =e Ti wi . v i is the i t h coordinate of the facial image in the new space, which came to be
the principal component. The vectors e iare also images, so called, eigenimages, or eigenfaces
in our case. They can be viewed as images and indeed look like faces. So,Ω describes the
contribution of each eigenface in representing the facial image by treating the eigenfaces as a
basis set for facial images. The simplest method for determining which face class provides the
best description of an input facial image is to find the face class k that minimizes the
Euclidean distance
ϵ k=‖Ω−Ωk‖ (10)
3|Page
where Ω k is a vector describing the k t h face class. If ϵ k is less than some predefined threshold
θ ϵ, a face is classified as belonging to the class k.
2. FACE RECOGNITION
Once the eigenfaces have been computed, several types of decision can be made depending
on the application. What we call face recognition is a broad term which may be further
specified to one of following tasks:
PCA computes the basis of a space which is represented by its training vectors. These basis
vectors, actually eigenvectors, computed by PCA are in the direction of the largest variance
of the training vectors. As it has been said earlier, we call them eigenfaces. Each eigenface
can be viewed a feature. When a particular face is projected onto the face space, its vector
into the face space describes the importance of each of those features in the face. The face is
expressed in the face space by its eigenface coefficients (or weights). We can handle a large
input vector,
facial image, only by taking its small weight vector in the face space. This means that we can
reconstruct the original face with some error, since the dimensionality of the image space is
much larger than that of face space.
In this report, let’s consider face identification only. Each face in the training set is
transformed into the face space and its components are stored in memory. The face space has
to be populated with these known faces. An input face is given to the system, and then it is
projected onto the face space. The system computes its distance from all the stored faces.
However, two issues should be carefully considered:
The first defect is easily avoided since the first eigenface is a good face filter which can test
whether each image is highly correlated with itself. The images with a low correlation can be
rejected. Or these two issues are altogether addressed by categorizing following four different
regions:
Since a face is well represented by the face space, its reconstruction should be similar to the
original; hence the reconstruction error will be small. Non-face images will have a large
4|Page
reconstruction error which is larger than some threshold θr . The distance ϵ kdetermines
whether the input face is near a known face.
3. REQUIREMENTS
o Windows OS
o Visual Studio
o Open-CV version 2.10
5|Page
4. UNDERLYING PRINCIPLE
Φ i=Γ i−Ψ
6|Page
Note 3: The M eigenvalues of AT A (along with their corresponding
eigenvectors) correspond to the M largest eigenvalues of A AT (along
with their corresponding eigenvectors).
Step 6.3: compute the M best eigenvectors of A AT : ui=¿A vi
(important: normalize ui such that ||ui || =1)
Step 7: keep only K eigenvectors (corresponding to the K largest eigenvalues)
7|Page
4.3. REPRESENTING FACES ONTO THIS BASIS
- Each face (minus the mean) Φ i in the training set can be represented as a linear
combination of the best K eigenvectors:
K
Φ i−mean=∑ w j u j ,( w j=uTj Φ i)
j=1
(we call the u j ’s eigenfaces)
wi1
Ω i= … . , i=1,,2.......,M
w iK
8|Page
4.4. FACE RECOGNITION USING EIGEN FACES
- Given an unknown face image Γ(centered and of the same size like the training
faces) follow these steps:
w1
Ω= …
wk
Step 4: find e r =minl‖Ω−Ωl‖
Step 5: ife r ,< T r then Γ is recognized as face l from the training set.
- The distance e r , is called distance within the face space (difs)
Comment: we can use the common Euclidean distance to compute er, however, it
has been reported that the Mahalanobis distance performs better:
k
1
‖Ω−Ωk‖=∑ λ ¿
i=1 i
(variations along all axes are treated as equally significant)
9|Page
4.5. FACE DETECTION USING EIGENFACES
- Given an unknown image Γ
Step 1: compute
Φ=Γ −Ψ
Step 2: compute
K
^ ∑ w i u i( wi=u Ti Φ)
Φ=
i=1
Step 3: compute
e d =‖Φ−Φ ^‖
Step 4: if e d < T d, then Γ is a face.
- The distance e d is called distance from face space (dffs)
10 | P a g e
5. TECHONOLOGY USED
5.1. MICROSOFT VISUAL C++
Visual C++ is IDE of Microsoft to develop application using C++ & its STL (Standard
Template Library). Application developed by visual C++ can be of different types such as
MFC application, win console application etc. In our case, we will be developing win console
application using OpenCV.
5.2. OPEN CV
11 | P a g e
5.2.1 OpenCV Structure and Content
OpenCV is broadly structured into fi ve main components, four of which are shown in
Figure. The CV component contains the basic image processing and higher-level computer
vision algorithms; ML is the machine learning library, which includes many statistical
classifiers and clustering tools. HighGUI contains I/O routines and functions for storing and
loading video and images, and CXCore contains the basic data structures and content.
12 | P a g e
6. USER DEFINED FUNCTIONS AND THEIR PURPOSE
6.1. printusage
This function is used to control the program from the command line user
interface. Depending upon the user input it transfers the control of program to either
training phase or testing phase or online recognition of a face from camera.
6.2. learn
This function is used for offline recognition mode where it trains from the data
given in text file and store the trained data into the file ‘facedata.xml ‘.
6.3. doPCA
6.4. StoreTrainingdata
6.5. loadTrainingdata
This function is used to load the training data from the file 'facedata.xml'.
6.6. Findnearestneighbour
This function is used to find the most likely person based on detection. It returns
the index of image, and stores the confidence value into variable pConfidence.
6.7. loadfaceImgArray
This function is used to read the names & image of people from a text file, and
load all those images listed.
6.8. Recognizefilelist
It is used to recognize the face in each of the test images given, and compare
the results with the truth.
6.9. Getcameraframe
It is used to grab the next camera frame. It waits until the next frame is ready,
and provides direct access to it, as a result it do NOT modify the returned image or
free it. It automatically initializes the camera on the first frame.
13 | P a g e
6.10. Convertimageto grayscale
It is used to return a new image that is always greyscale, irrespective of the input
type of image. It free the returned image using cvReleaseImage() when finished.
6.11. cropImage
6.12. resizeImage
It creates a new image copy that is of a desired size. Remember to free the new
image later.
6.13. convertFloatImagetoUcharImage
It gets an 8-bit equivalent of the 32-bit Float image. It returns a new image, so
remember to call cvReleaseImage() on the result.
6.14. SaveFloatImage
6.15. detectFaceInImage
Perform face detection on the input image, using the given Haar cascade
classifier. It returns a rectangle for the detected region in the given image.
6.16. Retrainonline
14 | P a g e
7. Snapshots of project on running mode
Figure : It represents start of the project where user have to enter a command, according to
which it wil run further.
Figure : It represents status of the program when user has entered recognize as its command.
15 | P a g e
Figure : It represents status of the program where the program is trying to recognize a face
Figure: It represents a camera frame which has been captured by camera. After detecting a
face in the frane the program identifies it and returns name of the function and its confidence
level.
16 | P a g e
8. Future Work
There are many interesting problems that remain in the area of face recognition. One problem
is image preprocessing prior to the application of the eigenface method. It may be possible to
gain better accuracy in classification if one segments the spectrum of people into different
spaces. For example, if one was able to determine if an image was of a man or a woman, one
could use this categorization to send an image to one of two classifiers, each specifically
trained with that type of individual in mind. This would mean that there would be a set of
eigenfaces specifically for males and one specifically for females (face spaces with gender, so
to speak). Work in this area has been done by Lizama, Waldoestl and Nickolay [4], however
it would be interesting to extend it to use eigenfaces to act as the gender classifier as well. A
general face-space would be created in addition to the male and female face-spaces, with the
sole purpose of being used to classify an image as male or female.
Another area of future work is improving our neural network classifier. As mentioned in the
previously, it is possible to construct the network to take its input directly from the image
data rather from the vector that results from an images projection into face-space. Perhaps
learning the face projection function could increase the accuracy of the neural network
classifier. Additionally, more experiments are needed to see if there are other ways to tweak
the network configuration to produce better results.
17 | P a g e
9. Reference
Learning OpenCV –Computer Vision with the openCV Library O’Reilly Publication
Gary Bradsk1 and Andrian Kehlar
M.A. Turk and A.P. Pentland, “Face Recognition Using Eigenfaces”, IEEE Conf. on
Computer Vision and Pattern Recognition, pp. 586-591, 1991.
18 | P a g e