Friday 2 August 2013

Face Detection Matlab Code

Following code used to detect the face.

faceDetection.m



function detectfce = faceDetection(I)



faceDetector = vision.CascadeObjectDetector;  



% Read input image



% Detect faces

bbox = step(faceDetector, I);



% Create a shape inserter object to draw bounding boxes around detections

shapeInserter = vision.ShapeInserter('BorderColor','Custom','CustomBorderColor',[255 255 0]);



% Draw boxes around detected faces and display results             

snapshot0 = step(shapeInserter, I, int32(bbox));   



detectfce = I(bbox(2):bbox(2)+bbox(3),bbox(1):bbox(1)+bbox(4),:,:,:);



Main.m



[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.pgm','All Image Files';...

          '*.*','All Files' },'mytitle');

file = [pathname filename];





FileNames = file;

rgbImage = imread(FileNames);

detectfce = faceDetection(rgbImage );

figure;imshow(detectfce );






Kindly Bookmark and Share it:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...