-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviola_jones_FD.m
34 lines (27 loc) · 957 Bytes
/
viola_jones_FD.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
%~~~~~~~~ Andrew Hibbs 2021 ~~~~~~~~~~~~~~~
%Face detection function utilizing the Viola-Jones
% grayscale algorithm. Uses the Matlab Computer Vision
% And Image Processing Toolbox
%Initialize the face detector
Detector=vision.CascadeObjectDetector('FrontalFaceCART');
% "Read" the image that is uploaded
image=imread('3.jpg');
%Convert the Image to grayscale to analyze
image=rgb2gray(image);
% Start the face detection
detects=step(Detector,image);
% Annotate over the detected faces
iimg = insertObjectAnnotation(image, 'rectangle',...
detects, 'Face Right Here');
figure(1);
imshow(iimg);
title('Detected Faces');
htextinsface = vision.TextInserter('Text', 'face : %2d',...
'Location', [5 2],'Font', 'Courier New','FontSize', 14);
% Start the for loop to "outline" the detected faces
hold on
for i=1:size(detects,1)
rectangle('position',detects(i,:),'Linewidth',2,...
'Linestyle','-','Edgecolor','y');
end
hold on