Professional Documents
Culture Documents
HITEC UNIVERSITY
6th SEMESTER
GROUP MEMBERS:
Name: Registration No.
1. Kamran Ahmad 15-EE-155
2. Malik Ali Hassan 15-EE-031
3. Mohsin Khan 15-EE-171
Real time Face
Detection and
Recognition
2
Abstract:
Face detection is an automated process being used in a variety of
applications that identifies human faces in digital images. Face detection
also refers to the psychological process by which humans locate and attend
to faces in a visual scene.Face-detection algorithms focus on the detection of
frontal human faces. It is analogous to image detection in which the image
of a person is matched bit by bit. Image matches with the image stores in
database. Any facial feature changes in the database will invalidate the
matching process.
3
Table of Contents
5. 2. Design ...................................................................................... 5
2.1 The structure for this project ................................................................................. 5
4
1. Project Description
1.1. Goal
Our goal is to find the fundamentals for face recognition. We want to find a way to
build a real-time face recognition system. We want to combine what we have learned in
1.2. Platform/software
The chosen programming platform is Matlab2017a. Facilitate capture of streaming
video using the MATLAB Webcam interface. Which involve the installation of MATLAB
Support Package for USB Webcams, using the Support Package Installer.
Note that USB webcams are supported in core MATLAB. Other cameras are supported
2. Design
three components are to read image from webcam, face detection,and then lastly face
recognition. Those components will be described in detail in the next few sub topics, but
5
Detect
Read Imge Recognize
Existance of
File through Detected
Face in
Webcam Face
Image
the further process of detection .For face detection, it is quite obvious, because if you
cannot detect a face, how can you do recognition on it? (Usingproof by contradiction).
The only problem here is what way is more accurate on finding face. For face detection,
For face recognition, it is required because the goal of the project is recognizing the face.
By comparing the key elements of the face to the faces stored in the database, we will be
able to recognize one person, and the difficulty here is still, which method should we
6
2.3.2. Important code details
7
Instantiate a feature detector, and detect, extract, and store features from each
montage. we tried many different detectors and extractors, with many different input
parameters, before settling on FAST features, and a SURF extractor:
clc;
cam=webcam(1);
load classifier;
faceDetector = vision.CascadeObjectDetector();
Run=1;
while(Run)
img = snapshot(cam);
img=imresize(img,[480 640]);
bbox = step(faceDetector,img);
if(~isempty(bbox))
for i=1:size(bbox,1)
crop=imcrop(img,bbox(i,:));
crop=rgb2gray(crop);
crop=histeq(crop);
crop = medfilt2(crop);
sizeNormalizedImage = imresize(crop,[150 150]);
testimage=extractHOGFeatures(sizeNormalizedImage);
[prediction ,scores] = predict(faceClassifier,testimage);
disp(scores);
img = insertObjectAnnotation(img,'rectangle',bbox(i,:),prediction);
end
end
figure(1),imshow(img);
if get(gcf, 'CurrentCharacter')
disp('Key press')
8
key = get(gcf,'CurrentCharacter');
if(key=='q')
Run=0;
end
end
end
We now have a set of features (sceneFeatures) calculated for each face. This set of features can now be
used as a classifier! (If all went well, the feature extraction should have taken only a few seconds!)
9
temp_img=imread(temp_name);
temp_img=rgb2gray(temp_img);
temp_img=histeq(temp_img);
temp_img = medfilt2(temp_img);
Train_faces{temp}=temp_img;
temp_label=strsplit(temp_name);
Train_labels{temp}=char(temp_label(1));
temp=temp+1;
end
end
disp('Extracting Features');
%%Extracting Features
for i=1:size(Train_faces,2)
sizeNormalizedImage = imresize(Train_faces{i},[150 150]);
Training_features(i,:)=extractHOGFeatures(sizeNormalizedImage);
end
disp('Training Model');
%%Training Classifier
faceClassifier = fitcecoc(Training_features,Train_labels);
save('classifier.mat','faceClassifier');
10
2.5. Result of Recognition
clc;
cam=webcam(1);
load classifier;
faceDetector = vision.CascadeObjectDetector();
Run=1;
while(Run)
img = snapshot(cam);
img=imresize(img,[480 640]);
bbox = step(faceDetector,img);
if(~isempty(bbox))
for i=1:size(bbox,1)
crop=imcrop(img,bbox(i,:));
crop=rgb2gray(crop);
crop=histeq(crop);
crop = medfilt2(crop);
sizeNormalizedImage = imresize(crop,[150 150]);
testimage=extractHOGFeatures(sizeNormalizedImage);
[prediction ,scores] = predict(faceClassifier,testimage);
disp(scores);
img = insertObjectAnnotation(img,'rectangle',bbox(i,:),prediction);
end
end
figure(1),imshow(img);
if get(gcf, 'CurrentCharacter')
disp('Key press')
key = get(gcf,'CurrentCharacter');
if(key=='q')
Run=0;
11
end
end
end
The recognition rate of our program is about 80% due to the glasses because without
glasses change my identity. Note, this recognition rate does not include the rate of failing
the face detection. Therefore, the total success rate for our program is lower.
12
4. Remarks and Future Work
This is a really interesting project to work on. After this project is completed we are
suddenly realized that now we have the ability to create such tools ourselves. This feeling
is great.
differences (some people like to make up/cover up their true self) all made things a lot
Up to this point, face recognition systems are functioning in a normal way, but in
order to make it detect faces better, we need future work to be done. If you paint your
face so the dark/light pattern becomes less recognizable, the algorithm fails. This is
understandable because even for our human, it is hard to recognize someone with their
face painted.
Future work
tone mapping together to make better classifiers. Viola-Johns algorithm will only ensure
we have the object with the correct shading, but it does not necessarily be human.
For those human skin tone classifiers, we need sample collected from all over the
13
What to improve on feature detection
Right now we are only using corner detection from the area that we are interested in.
This is not entirely accurate due to different lighting conditions and different scales of the
faces. In the future, if we have a programmable camera, we will program the camera to
get the database sample with the same scale as the real test objects.
line under development mode. This is required for commercial use, because people are
dumb.
14