Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic Face Detection Using MATLAB

I am trying to implement automatic face detection using MATLAB. I know how to implement it using OpenCV, but i would like to do it in MATLAB.

I saw two websites on this:

1) http://www.mathworks.com/matlabcentral/fileexchange/11073. Firstly, this website is good and it works on neural networks. It works well witht the images that are given together with it. However, when I train the neural networks using my images, the accuracy is very bad.

2) The second is http://www.mathworks.com/matlabcentral/fileexchange/13716-face-eye-detection. The accuracy is bad when i test with an image of my own.

Looking for better solutions as well as suggestions on what i should do. Thanks.

like image 492
lakshmen Avatar asked Feb 15 '12 19:02

lakshmen


1 Answers

Starting with the R2012a release, the Computer Vision System Toolbox includes a Viola-Jones based face detector with the vision.CascadeObjectDetector system object.

demo


EDIT:

Since you mentioned OpenCV, how about directly using it from MATLAB. Checkout mexopencv project.

Here is sample code to detect faces:

%# Load a face detector and an image
detector = cv.CascadeClassifier('haarcascade_frontalface_alt.xml');
im = imread('myface.jpg');
%# Preprocess
gr = cv.cvtColor(im, 'RGB2GRAY');
gr = cv.equalizeHist(gr);
%# Detect
boxes = detector.detect(gr, 'ScaleFactor',1.3, 'MinNeighbors',2, 'MinSize',[30,30]);
%# Draw results
imshow(im);
for i = 1:numel(boxes)
    rectangle('Position',boxes{i}, 'EdgeColor','g');
end

It is worth mentioning that MATLAB's computer vision toolbox also uses OpenCV in its implementation..

like image 161
Amro Avatar answered Oct 23 '22 23:10

Amro