Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Recent Posts


                                  Lets see how to detect face, nose, mouth and eyes using the MATLAB built-in class and function. Based on Viola-Jones face detection algorithm, the computer vision system toolbox contains vision.CascadeObjectDetector System object which detects objects based on above mentioned algorithm.
Prerequisite: Computer vision system toolbox


clear all
%Detect objects using Viola-Jones Algorithm

%To detect Face
FDetect = vision.CascadeObjectDetector;

%Read the input image
I = imread('HarryPotter.jpg');

%Returns Bounding Box values based on number of objects
BB = step(FDetect,I);

imshow(I); hold on
for i = 1:size(BB,1)
title('Face Detection');
hold off;

The step(Detector,I) returns Bounding Box value that contains [x,y,Height,Width] of the objects of interest.

BB =

    52    38    73    73
   379    84    71    71
   198    57    72    72


%To detect Nose
NoseDetect = vision.CascadeObjectDetector('Nose','MergeThreshold',16);


imshow(I); hold on
for i = 1:size(BB,1)
title('Nose Detection');
hold off;


To denote the object of interest as 'nose', the argument  'Nose' is passed.


The default syntax for Nose detection :

Based on the input image, we can modify the default values of the parameters passed to vision.CascaseObjectDetector. Here the default value for 'MergeThreshold' is 4.

When default value for 'MergeThreshold' is used, the result is not correct.
Here there are more than one detection on Hermione.

To avoid multiple detection around an object, the 'MergeThreshold' value can be overridden. 


%To detect Mouth
MouthDetect = vision.CascadeObjectDetector('Mouth','MergeThreshold',16);


imshow(I); hold on
for i = 1:size(BB,1)
title('Mouth Detection');
hold off;


%To detect Eyes
EyeDetect = vision.CascadeObjectDetector('EyePairBig');

%Read the input Image
I = imread('harry_potter.jpg');


title('Eyes Detection');

Cropped Image

I will discuss more about object detection and how to train detectors to identify object of our interest in my upcoming posts. Keep reading for updates.

like button Like "IMAGE PROCESSING" page


Rohini Bhargava said... Reply to comment

I have MATLAB of version R2010a which does not have the Computer vision system toolbox.How to detect eyes,mouth,nose in that case?

Aaron Angel said... Reply to comment

@Rohini Bhargava

You need to install 'Computer vision system toolbox' . For more information, visit http://www.mathworks.in/products/computer-vision/ .

Praga Deesan said... Reply to comment

@AaronAngel_ hi ...i am doing a mini project on matlab....pls help me... i need to capture image ,recognize the customer ,display his names.

Mitesh Ochaney said... Reply to comment

i hav matlab version 7. how do i perform face recognition on that.. please help..

Gul Sayyar Ali said... Reply to comment

can some0ne tell me how to install computer vivsion toolbox

nishant agrawal said... Reply to comment

i m doing a major projct on matlab... plz tell me how to campare or recognize captured image with the image stored in database and will display the name

nishant agrawal said... Reply to comment

i m doing my major project on matlab..plz tell me how to campare or recognize captured image with the image stored in database and will be display the name after successful matching...

Saxena Hidangmayum said... Reply to comment

thnk u very much....i was wondering how to detect the facial features.....it is interesting.

pallavi sharma said... Reply to comment

@nishant agrawalhaan yr ye he humein samajh nhe aa rhe tujhe pta chale to reply zarur karna yaad se bhoolna mat.....

銘仁^^ said... Reply to comment

Dear friend
what your Principle on ur mouth and eyes detection?

銘仁^^ said... Reply to comment

Dear friend
What Theory or Principle on your mouth and eyes ?
I want to do research in this area thanks more^^

mae nak said... Reply to comment

how to separate left eye and right eye?

ram said... Reply to comment

hey !!! can you help me in Iris localaization

Divya jax said... Reply to comment

Dear Friend. How to identify a face in snap?? Please response me

Divya jax said... Reply to comment

How to identify a face in snap???

Abhishek Gourav said... Reply to comment

how can i find the centre of the squares that detects eyes or nythiing???

ankita taparia said... Reply to comment

I am an assistant professor in an engg college and need an account on MATLAB. Please tell me the procedure

Gaurav Lonkar said... Reply to comment

Can you give me the m file?

Nive Nivetha said... Reply to comment

but i dnt hv control vision toolbox,witout that vision cascade object detector method is not possible?wat can i do?

Bindu Pedapalli said... Reply to comment

computer vision system tool box in matlab which verision

KT said... Reply to comment

There's something wrong with mouth detection. It detects everything like eyes and nose. On the other great tutorial thanks!

Hana Anber said... Reply to comment

Could you please tell me are you using Viola and jones algorithm only or you used Adaboost beside ?

nevraa said... Reply to comment

It's very useful, thank you!

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Related Posts Plugin for WordPress, Blogger...
Twitter Bird Gadget Google ping Hypersmash.com