-
Notifications
You must be signed in to change notification settings - Fork 168
/
MDP_reward_occluded.m
81 lines (80 loc) · 2.38 KB
/
MDP_reward_occluded.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
% --------------------------------------------------------
% MDP Tracking
% Copyright (c) 2015 CVGL Stanford
% Licensed under The MIT License [see LICENSE for details]
% Written by Yu Xiang
% --------------------------------------------------------
%
% compute reward in tracked state
function [reward, label, f, is_end] = MDP_reward_occluded(fr, f, dres_image, dres_gt, ...
dres, index_det, tracker, opt, is_text)
is_end = 0;
label = 0;
% check if any detection overlap with gt
index = find(dres_gt.fr == fr);
if isempty(index) == 1
overlap = 0;
else
if dres_gt.covered(index) > opt.overlap_occ
overlap = 0;
else
overlap = calc_overlap(dres_gt, index, dres, index_det);
end
end
if is_text
fprintf('max overlap in association %.2f\n', max(overlap));
end
if max(overlap) > opt.overlap_pos
if tracker.state == 2
% if the association is correct
ov = calc_overlap(dres_gt, index, tracker.dres, numel(tracker.dres.fr));
if ov > opt.overlap_pos
reward = 1;
else
reward = -1;
label = -1;
is_end = 1;
if is_text
fprintf('associated to wrong target (%.2f, %.2f)! Game over\n', max(overlap), ov);
end
end
else % target not associated
if dres_gt.covered(index) == 0
if isempty(find(tracker.flags ~= 2, 1)) == 1
reward = 0; % no update
else
reward = -1; % no association
label = 1;
% extract features
[~, ind] = max(overlap);
dres_one = sub(dres, index_det(ind));
f = MDP_feature_occluded(fr, dres_image, dres_one, tracker);
if is_text
fprintf('Missed association!\n');
end
is_end = 1;
end
else
reward = 1;
end
end
else
if tracker.state == 3
reward = 1;
else
ov = calc_overlap(dres_gt, index, tracker.dres, numel(tracker.dres.fr));
if ov < opt.overlap_neg || max(overlap) < opt.overlap_neg
reward = -1;
label = -1;
is_end = 1;
if is_text
fprintf('associated to wrong target! Game over\n');
end
else
reward = 0;
end
end
end
if is_text
fprintf('reward %.1f\n', reward);
end