1. 1
A
PROJECT REPORT
on
FACE DETECTION AND TRACKING
Submitted in partial fulfilment of the requirements for the degree of
BACHELOR OF TECHNOLOGY
Batch: - 2014-18
Submitted by
Narayan Lal Menariya (14ETCEC015)
Varun Bhatnagar (14ETCEC030)
8Th Semester, ECE
Under Guidance of
Isha Purbia
Assistant Professor
ECE, Techno India NJR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
TECHNO INDIA NJR INSTITUTE OF TECHNOLOGY, UDAIPUR-313003
2. 2
TECHNO INDIA NJR INSTITUTE OF TECHNOLOGY, UDAIPUR
ELECTRONICS & COMMUNICATION ENGINEERING
DEPARTMENT
CERTIFICATE
This is to certify that the Project Report titled 8Th Semester Project was prepared and presented by
NARAYAN LAL MENARIYA of Techno India NJR Institute of Technology, Udaipur in partial
fulfillment of the requirement as a subject under the Rajasthan Technical University during the B.Tech
Final Year VIIIth Semester.
Dr. Vivek Jain Assistant Prof. Nitin Kothari
( Guide ) (Head Of Department)
3. 3
Preface
Digital image processing is the use of computer algorithms to perform image processing on digital
images. As a subcategory or field of digital signal processing, digital image processing has many
advantages over analog image processing. It allows a much wider range of algorithms to be applied to
the input data and can avoid problems such as the build-up of noise and signal distortion during
processing. Since images are defined over two dimensions (perhaps more) digital image processing
may be modeled in the form of multidimensional systems.
In Chapter 1, Introduction to Matlab, Basics of Matlab and Understanding of Digital signal processing
Chapter 2 Face detection and Tracking , Concept of room automation using face detection.
Understanding and practically verified video processing
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
TECHNO INDIA NJR INSTITUTE OF TECHNOLOGY, UDAIPUR-313003
4. 4
ACKNOWLEDGMENTS
We take this opportunity to record our sincere thanks to all who helped us to successfully complete this
work. Firstly, We are grateful to our Assistant Prof. Isha Purbia for his invaluable guidance and
constant encouragement, support and most importantly for giving us the opportunity to carry out this
work.
We would like to express our deepest sense of gratitude and humble regards to our
Head of Department Assistant Prof. Nitin Kothari for giving invariable encouragement in our
endeavors and providing necessary facility for the same. We are very thankful to Prof. Pradeep
Chhawchharia , Director (Research & New Initiatives) for encouraging us in this project work. Also
a sincere thanks to all faculty members of ECE, TINJRIT for their help in the project directly or
indirectly.
Finally, We would like to thank my friends for their support and discussions that have proved very
valuable for us. We are indebted to our parents for providing constant support, love and
encouragement. We thank them for the sacrifices they made so that we could grow up in a learning
environment. They have always stood by us in everything we have done, providing constant support,
encouragement and love
NARAYAN LAL MENARIYA (14ETCEC015)
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
TECHNO INDIA NJR INSTITUTE OF TECHNOLOGY, UDAIPUR-313003
5. 5
CONTENTS
CATEGORY PAGE NO.
List of Tables……………………………………………………...................................
5
List of Figure…………………………………………………………………………… 6
Chapter 1 INTRODUCTION…………………………………………...................... 7
8
8
9
10
10
11
16
17
17
Chapter 2 MATLAB IMAGE PROCESSING TOOLBOX
2.1 Typical usage
2.2 The basic
2.3 Application of MATLAB
2.4 Video Processing Toolbox
2.5 Room Automation Using Face Detection And MATLAB DIP
2.6 Results
2.7 Limitation
2.8 Conclusion
Appendix……………………………………………………………………………….. 19
Reference……………………………………………………………………………….. 23
9. 9
Chapter 2
Matlab Image Processing Toolbox
Fig 2.1 Matlab logo
MATLAB, short for Matrix Laboratory is a programming package specifically designed for quick and
easy scientific calculations and I/O. It has literally hundreds of built-in functions for a wide variety of
computations and many toolboxes designed for specific research disciplines, including statistics,
optimization, solution of partial differential equations, data analysis. MATLAB is an high performance
language for technical computing. It integrates computation, visualization and programming in an easy
to use environment where problems and solutions are expressed in familiar mathematical notations .
2.1 Typical uses include:
Math and computation
Algorithm development modeling ,simulation and prototyping Data analysis, exploration and
visualization
Scientific and engineering computations
MATLAB is an interactive system whose basic data element is an array that does not require
dimensioning. This allows you to solve many technical computing problems, especially those with
matrix and vector formulation, in a fraction of the time it would take to write a program in a scalar non
interactive language such as C or Fortran.
10. 10
MATLAB has evolved over a period of years with input from many users. In university environments,
it is the standard instructional tool for introductory and advanced courses in mathematics, engineering
and science. In industry, MATLAB is the tool of choice for high productivity research, development
and analysis.
MATLAB features a family of application specific solutions called toolboxes. Very important to most
users of MATLAB, toolboxes allow you to learn and apply specialized technology. Toolboxes are
comprehensive collections of MATLAB functions that extend the MATLAB environment to solve
particular classes of problems. Areas in which toolboxes are available include signal processing,
control systems, neural networks, fuzzy logic, simulation and many more.
2.2 THE BASIC
The MATLAB window should come up on your screen. It looks like:
Fig. 2.2 Matlab window
11. 11
This is the window in which you interact with MATLAB. The main window on the right is called the
Command Window. You can see the command prompt in this window, which looks like >>. If this
prompt is visible MATLAB is ready for you to enter a command. In the top left corner you can view
the Launch Pad window and the Workspace window. Swap from one to the other by clicking on the
appropriate tag. The Workspace window will show you all variables that you are using in your current
MATLAB session. When you first start up MATLAB, the workspace is empty. In the bottom left
corner you can see the Command History window, which simply gives a chronological list of all
MATLAB commands that you used, and the Current Directory window which shows you the contents
and location of the directory you are currently working in.
2.3APPLICATIONS OF MATLAB
In Aerospace and defence
IT and programming field
Graphic design and multimedia
Finances and accounting
Sales and marketing
2.4 VIDEO PROCESSING TOOLBOX
Digital image processing is the use of computer algorithms to perform image processing on digital
images. As a subcategory or field of digital signal processing, digital image processing has many
advantages over analog image processing. It allows a much wider range of algorithms to be applied
to the input data and can avoid problems such as the build-up of noise and signal distortion during
processing. Since images are defined over two dimensions (perhaps more) digital image processing
may be modeled in the form of multidimensional systems.
An image sensor or imaging sensor is a sensor that detects and conveys the information that
constitutes an image. It does so by converting the variable attenuation of light waves (as they pass
through or reflect off objects) into signals, small bursts of current that convey the information. The
waves can be light or other electromagnetic radiation. Image sensors are used in electronic imaging
devices of both analog and digital types, which include digital cameras, camera modules, medical
imaging equipment, night vision equipment such as thermal imaging devices, radar, sonar, and
others. As technology changes, digital imaging tends to replace analog imaging.
12. 12
Early analog sensors for visible light were video camera tubes. Currently, used types
are semiconductor charge-coupled devices (CCD) or active pixel sensors in complementary metal–
oxide–semiconductor (CMOS) or N-type metal-oxide-semiconductor (NMOS, Live MOS)
technologies. Analog sensors for invisible radiation tend to involve vacuum tubes of various kinds.
Digital sensors include flat panel detectors.
2.5 ROOM AUTOMATION USING FACE DETECTIONMATLAB IMAGE
PROCESSINGTOOLBOX
PROCEDURE
Detecting Face
Introduction
Object detection and tracking are important in many computer vision applications including activity
recognition, automotive safety, and surveillance. In this example, you will develop a simple face
tracking system by dividing the tracking problem into three separate problems:
1. Detect a face to track
2. Identify facial features to track
3. Track the face
Step 1: Detect a Face To Track
Before you begin tracking a face, you need to first detect it. Use the vision.CascadeObjectDetector to
detect the location of a face in a video frame. The cascade object detector uses the Viola-Jones
detection algorithm and a trained classification model for detection. By default, the detector is
configured to detect faces, but it can be configured for other
13. 13
Fig. 2.3 Face recognition
You can use the cascade object detector to track a face across successive video frames. However, when
the face tilts or the person turns their head, you may lose tracking. This limitation is due to the type of
trained classification model used for detection. To avoid this issue, and because performing face
detection for every video frame is computationally intensive, this example uses a simple facial feature
for tracking.
Step 2: Identify Facial Features To Track
Once the face is located in the video, the next step is to identify a feature that will help you track the
face. For example, you can use the shape, texture, or color. Choose a feature that is unique to the object
and remains invariant even when the object moves.
In this example, you use skin tone as the feature to track. The skin tone provides a good deal of contrast
between the face and the background and does not change as the face rotates or moves.
14. 14
Fig. 2.4 Hue image
Step 3: Track the Face
With the skin tone selected as the feature to track, you can now use
the vision.HistogramBasedTracker for tracking. The histogram based tracker uses the CAMShift
algorithm, which provides the capability to track an object using a histogram of pixel values. In this
example, the Hue channel pixels are extracted from the nose region of the detected face. These pixels
are used to initialize the histogram for the tracker. The example tracks the object over successive video
frames using this histogram.
Fig. 2.5 Tracked image
15. 15
CAMShift Algorithm:
1. Set the region of interest (ROI) of the probability distribution image to the entire image.
2. Select an initial location of the Mean Shift search window. The selected location is the target
distribution to be tracked.
3. Calculate a colour probability distribution of the region centred at the Mean Shift search
window.
4. Iterate Mean Shift algorithm to find the centroid of the probability image. Store the zeroth
moment (distribution area) and centroid location.
5. For the following frame, centre the search window at the mean location found in Step 4 and set
the window size to a function of the zeroth moment. Go to Step 3.
Viola-Jones algorithm: Two features are selected for the task of face detection:
1. first feature: the region of the eyes is often darker than the region of the nose and cheeks
2. second feature: the eyes are darker than the bridge of the nose
3. Classifier can be constructed which reject many of the negative sub windows while detecting
almost all positive instances.
4. The final detector is scanned across the image at multiple scales and locations
5. The detector is also scanned across location, by shifting the window some number of pixels
6. It is useful to post process the detected sub-windows in order to combine overlapping detections
into a single detection
16. 16
Fig. 2.6 Haar image
Detecting Respective Quadrant Of Class Room In Which Face Is
Detected :
as shown in figure we can see that face is detected in each quadrant 1-2.
So in quadrant 2 face is detected
Fig. 2.7 Quadrant divided image
17. 17
2.6 RESULT
Camera Image
Fig. 2.8 Camera image of room
Image SeparatedIn Quadrant
Fig. 2.9 Quadrant divided image
18. 18
Face DetectedIn Each & Every Quadrant
Fig.2.10 Face detected in quadrant 2
2.7 LIMITATIONS
Multiple Face Tracking is Yet to implement
4 quadrant detection is yet to implement
Quadrants dimension are user defined not automatic
Photo Frames in room can reduce applicability of the program
Intially to start the process 1st frame with face detected is required
2.8 CONCLUSION
The main concernof this project is to save the wastage of unwanted electricity.
Although this can be done using various other methods but this project is proposed to
control the home appliance automatically using MATLAB.
This project is of low costand can be applicable to various places such as
Domestic application
Industrial application
19. 19
Medical application
Military application
The main advantages of this project is that the area used for installation of this project is
very less and also it requires very less maintenance.
21. 21
bbox1 = step(bodyDetector, I1);
bbox2 = step(bodyDetector, I2);
% Draw the returned bounding box around the detected face.
videoOut = insertObjectAnnotation(I1,'rectangle',bbox1,'face');
figure, imshow(videoOut), title('Detected body');
videoOut = insertObjectAnnotation(I2,'rectangle',bbox2,'face');
figure, imshow(videoOut), title('Detected body');
videoInfo = info(videoFileReader);
videoPlayer = vision.VideoPlayer('Position',[300 300 videoInfo.VideoSize+30]);
flag1=0;
flag2=0;
while ~isDone(videoFileReader)
% Extract the next video frame
videoFrame = step(videoFileReader);
I1=videoFrame(1:240,1:160);
I2=videoFrame(1:240,160:320);
bbox1 = step(bodyDetector, I1);
bbox2 = step(bodyDetector, I2);
% isempty return 0 if array have some values
22. 22
f1=isempty(bbox1);
f2 =isempty(bbox2);
if f2==0
flag2=1
else
flag2=0
end
if f1==0
flag1=1
else
flag1=0
end
videoOut = insertObjectAnnotation(I1,'rectangle',bbox1,'face');
figure, imshow(videoOut), title('Detected body');
videoOut = insertObjectAnnotation(I2,'rectangle',bbox2,'face');
figure, imshow(videoOut), title('Detected body');
% Display the annotated video frame using the video player object
step(videoPlayer, videoOut);