-
Notifications
You must be signed in to change notification settings - Fork 1
/
drawFourPoints.m
65 lines (60 loc) · 1.75 KB
/
drawFourPoints.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% drawFourPoints draws bounding boxes on input image
%
% Y = drawFourPoints( X, fourpoints, thick )
%
%Output parameter:
% Y: image drawn bounding boxes
%
%
%Input parameter:
% X: input image
% fourpoints: fourpoints data to be drawn
% thick(optional): thickness of bounding boxes (defualt:1)
%
%
%Example:
% detector = buildDetector(2,2);
% img = imread('img.jpg');
% fp = detectRotFaceParts(detector,img);
% bbimg = drawFourPoints(img, fp);
%
%
%NOTE: This function is internally called in detectRotFaceParts.
%
%Version: 20120601
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Face Parts Detection: %
% %
% Copyright (C) 2012 Masayuki Tanaka. All rights reserved. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Y = drawFourPoints( X, fourpoints, thick )
if( nargin < 3 )
thick = 1;
end
Y = X;
if( size(fourpoints,1) > 0 )
boxColor = [[0,255,0]; [255,0,255]; [255,0,255]; [0,255,255]; [255,255,0]; ];
M=int32(fourpoints);
if( thick >= 0 )
t = (thick-1)/2;
t0 = -int32(ceil(t));
t1 = int32(floor(t));
else
t0 = 0;
t1 = 0;
end
for k=5:-1:1
shapeInserter = vision.ShapeInserter('Shape','Lines','BorderColor','Custom','Antialiasing',true,'CustomBorderColor',boxColor(k,:));
N = horzcat(M(:,(k-1)*8+1:(k-1)*8+8),M(:,(k-1)*8+1:(k-1)*8+2));
for i=t0:t1
NN = N;
NN(:,[1,3,5,7,9]) = N(:,[1,3,5,7,9]) + i;
Y = step(shapeInserter, Y, NN);
NN = N;
NN(:,[2,4,6,8,10]) = N(:,[2,4,6,8,10]) + i;
Y = step(shapeInserter, Y, NN);
end
end
end