Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
58 views4 pages

Face and Feature Detection Guide

This document demonstrates using the Viola-Jones algorithm to detect different objects in an image using MATLAB. It detects faces using the default CascadeObjectDetector, then modifies parameters to detect noses, mouths and eyes. Detecting noses requires increasing the 'MergeThreshold' to avoid multiple detections of the same object. The algorithm returns bounding box values containing x,y coordinates and width/height of detected objects.

Uploaded by

Sahil Dhir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views4 pages

Face and Feature Detection Guide

This document demonstrates using the Viola-Jones algorithm to detect different objects in an image using MATLAB. It detects faces using the default CascadeObjectDetector, then modifies parameters to detect noses, mouths and eyes. Detecting noses requires increasing the 'MergeThreshold' to avoid multiple detections of the same object. The algorithm returns bounding box values containing x,y coordinates and width/height of detected objects.

Uploaded by

Sahil Dhir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

clear all

clc
%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);

figure,
imshow(I); hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-
','EdgeColor','r');
end
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
NOSE DETECTION:

%To detect Nose


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

BB=step(NoseDetect,I);

figure,
imshow(I); hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-
','EdgeColor','b');
end
title('Nose Detection');
hold off;

EXPLANATION:

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


passed.

vision.CascadeObjectDetector('Nose','MergeThreshold',16);

The default syntax for Nose detection :

vision.CascadeObjectDetector('Nose');

Based on the input image, we can modify the default values of the
parameters passed tovision.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.

MOUTH DETECTION:

%To detect Mouth


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

BB=step(MouthDetect,I);

figure,
imshow(I); hold on
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','r');
end
title('Mouth Detection');
hold off;

EYE DETECTION:

%To detect Eyes


EyeDetect = vision.CascadeObjectDetector('EyePairBig');

%Read the input Image


I = imread('harry_potter.jpg');

BB=step(EyeDetect,I);
figure,imshow(I);
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
title('Eyes Detection');
Eyes=imcrop(I,BB);
figure,imshow(Eyes);

You might also like