-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpartbased_rawboosting.m
99 lines (86 loc) · 3.49 KB
/
partbased_rawboosting.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
function [objectlocation, confidence, sstrongclassifier] = partbased_rawboosting(sstrongclassifier, sumimagedata, patches)
global parameter;
objectlocation = parameter.patch;
numofpatches = size(patches, 1);
patchesforupdate = zeros(8, 4);
labelforupdate = zeros(8, 1);
%t_selectors = [];
confidence_total = [];
confidence_top = [];
confidence_bottom = [];
confidence_left = [];
confidence_right = [];
for i = 1:parameter.init_iteration
importance = ones(8,1);
patchesforupdate(1,:) = parameter.patch;
labelforupdate(1) = 1;
patchesforupdate(2,:) = patches(numofpatches - 3,:);
labelforupdate(2) = -1;
patchesforupdate(3,:) = parameter.patch;
labelforupdate(3) = 1;
patchesforupdate(4,:) = patches(numofpatches - 2,:);
labelforupdate(4) = -1;
patchesforupdate(5,:) = parameter.patch;
labelforupdate(5) = 1;
patchesforupdate(6,:) = patches(numofpatches - 1,:);
labelforupdate(6) = -1;
patchesforupdate(7,:) = parameter.patch;
labelforupdate(7) = 1;
patchesforupdate(8,:) = patches(numofpatches ,:);
labelforupdate(8) = -1;
sstrongclassifier = partbased_updaterawboost(sstrongclassifier, ...
sumimagedata, patchesforupdate, labelforupdate, importance);
end
flag = 1;
confidence = [];
for imgno = parameter.imgstart+1:parameter.imgend
% t_selectors = [t_selectors, selectors];
if mod(imgno , 10) == 0
imgno
if flag
tic
else
toc
end
flag = ~flag;
end
I = imread(num2str(imgno, parameter.imdirformat));
if( size(I, 3) == 3)
I = rgb2gray(I);
end
subplot(1, 2, 1);
imshow(I);
sumimagedata = intimage(I);
subplot(1, 2, 2);
% if parameter.randompart
sstrongclassifier = partbased_detection(sstrongclassifier , sumimagedata, patches);
[location, confidencenow ] = partbased_maxconfidence(sstrongclassifier);
parameter.patch = location;
imshow(I);
% combined max area
rectangle('Position',parameter.patch, 'edgecolor', 'g');
text( parameter.patch(1) + parameter.patch(3)/2, parameter.patch(2)+ parameter.patch(4)/2, num2str(confidencenow, '%6f'));
objectlocation = [objectlocation; parameter.patch];
confidence = [confidence, confidencenow];
patches = generatepatches(parameter.patch, parameter.searchfactor, parameter.overlap);
numofpatches = size(patches, 1);
importance = ones(8,1);
patchesforupdate(1,:) = parameter.patch;
labelforupdate(1) = 1;
patchesforupdate(2,:) = patches(numofpatches - 3,:);
labelforupdate(2) = -1;
patchesforupdate(3,:) = parameter.patch;
labelforupdate(3) = 1;
patchesforupdate(4,:) = patches(numofpatches - 2,:);
labelforupdate(4) = -1;
patchesforupdate(5,:) = parameter.patch;
labelforupdate(5) = 1;
patchesforupdate(6,:) = patches(numofpatches - 1,:);
labelforupdate(6) = -1;
patchesforupdate(7,:) = parameter.patch;
labelforupdate(7) = 1;
patchesforupdate(8,:) = patches(numofpatches ,:);
labelforupdate(8) = -1;
sstrongclassifier = partbased_updaterawboost(sstrongclassifier, sumimagedata, patchesforupdate, labelforupdate, importance);
end
end