关于人脸检测的Matlab代码
FACE DETECTION:
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','-','EdgeC olor','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);