Overview:
In this article I am going to show you the simplest and fastest method to implement a face detection code in MATLAB 2012

Things to know:
Detailed working and code demonstrations:
In MATLAB 2012 there is a Computer Vision library which is used in this proposed code. Which implements the Voila-jones method to detect the haar-like features of frontal face.
Here's what Wikipedia says about Haar-like features
First of all read the lenna image from your disk using imread command
Then Create a Detector object using Vission Library of MATLAB
Now get the bounding box of face from RGB image of lenna readed in variable x
This will be done using step function
In this article I am going to show you the simplest and fastest method to implement a face detection code in MATLAB 2012

Things to know:
- Haar-like features
- Voila-jones Method
- MATLAB Basic image processing
Test Image:
In this article to test the code we are using the famous Lenna Image.
Detailed working and code demonstrations:
In MATLAB 2012 there is a Computer Vision library which is used in this proposed code. Which implements the Voila-jones method to detect the haar-like features of frontal face.
Here's what Wikipedia says about Haar-like features
Haar-like features are digital image features used in object recognition. They owe their name to their intuitive similarity with Haar wavelets and were used in the first real-time face detector.and about voila-jones method
The Viola–Jones object detection framework is the first object detection framework to provide competitive object detection rates in real-time proposed in 2001 by Paul Viola and Michael Jones.Coding:
First of all read the lenna image from your disk using imread command
x = imread('lenna.jpg');
Then Create a Detector object using Vission Library of MATLAB
det_face = vision.CascadeObjectDetector('FrontalFaceCART');
Now get the bounding box of face from RGB image of lenna readed in variable x
This will be done using step function
bbox_face = step(det_face,x);
[M N]=size(bbox_face);
if(M>0)
%if any face is detected
bbox_face = bbox_face(1,:); %assumed there is only one face in image
face_croped = imcrop(x,int32(bbox_face)); %crop the face
figure,imshow(face_croped);
title('face');
%to draw the rectangle
figure,imshow(x);hold on
rectangle('Position',int32(bbox_face), 'LineWidth',2, 'EdgeColor','g');
hold off
else
msgbox('No face is detected');
end
%=================================================================
Comments
Post a Comment