Following code used to detect the face.
faceDetection.m
Main.m
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 );
No comments:
Post a Comment