-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDrawFaceRectangle.m
33 lines (26 loc) · 1.33 KB
/
DrawFaceRectangle.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
function retColor = DrawFaceRectangle(color, depth, showFalsePositives)
FDetect = vision.CascadeObjectDetector;
%Returns Bounding Box values based on number of objects
BB = step(FDetect,color);
widthHeightRectangle = 32;
workspaceWithSVM = load('esviem4.mat');
svm = getfield(workspaceWithSVM, 'esviem4');
retColor = color;
for i=1:size(BB,1)
%fill positives
imCrop = imcrop(depth, [round(BB(i,1) - 0.2*BB(i,3)) round(BB(i,2) - 0.2*BB(i,4)) BB(i,3) BB(i,4)]); %%PAZI NA OVAJ 0.2 ispravak
frameDCroped = imresize(imCrop, [widthHeightRectangle widthHeightRectangle]);
red = double(frameDCroped(:,:,1));
green = double(frameDCroped(:,:,2));
sum = red*255 + green;
features = reshape(sum, 1, []); %plavi kanal je sve u 0 tako da ga ne citamo
result = svmclassify(svm, features);
if (result == 1)
%retColor = insertShape(retColor, 'rectangle', BB(i,:), 'color', 'green');
retColor = DrawBorder(retColor, BB(i,:), 4, 'green');
%retColor = insertShape(color, 'rectangle', BB, 'LineWidth', 5);
elseif (showFalsePositives)
retColor = DrawBorder(retColor, BB(i,:), 4, 'red');
%retColor = insertShape(retColor, 'rectangle', BB(i,:), 'color', 'red');
end
end