-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdrawResultBB.m
executable file
·121 lines (93 loc) · 4.05 KB
/
drawResultBB.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
close all
clear
clc
warning off all;
addpath('./util');
addpath(('./rstEval'));
pathRes = './results/results_TRE_CVPR13/';% The folder containing the tracking results
pathDraw = './tmp/imgs/';% The folder that will stores the images with overlaid bounding box
rstIdx = 1;
seqs=configSeqs;
trks=configTrackers;
if isempty(rstIdx)
rstIdx = 1;
end
LineWidth = 1;
plotSetting;
lenTotalSeq = 0;
resultsAll=[];
trackerNames=[];
for index_seq=1:length(seqs)
seq = seqs{index_seq};
seq_name = seq.name;
% fileName = [pathAnno seq_name '.txt'];
% rect_anno = dlmread(fileName);
seq_length = seq.endFrame-seq.startFrame+1; %size(rect_anno,1);
lenTotalSeq = lenTotalSeq + seq_length;
for index_algrm=1:length(trks)
algrm = trks{index_algrm};
name=algrm.name;
trackerNames{index_algrm}=name;
fileName = [pathRes seq_name '_' name '.mat'];
load(fileName);
res = results{rstIdx};
if ~isfield(res,'type')&&isfield(res,'transformType')
res.type = res.transformType;
res.res = res.res';
end
if strcmp(res.type,'rect')
for i = 2:res.len
r = res.res(i,:);
if (isnan(r) | r(3)<=0 | r(4)<=0)
res.res(i,:)=res.res(i-1,:);
% results.res(i,:) = [1,1,1,1];
end
end
end
resultsAll{index_algrm} = res;
end
nz = strcat('%0',num2str(seq.nz),'d'); %number of zeros in the name of image
pathSave = [pathDraw seq_name '_' num2str(rstIdx) '/'];
if ~exist(pathSave,'dir')
mkdir(pathSave);
end
for i= 1:seq_length
image_no = resultsAll{1}.startFrame + (i - 1);%seq.startFrame + (i-1);
id = sprintf(nz,image_no);
fileName = strcat(seq.path,id,'.',seq.ext);
img = imread(fileName);
imshow(img);
%text(10, 15, ['#' id], 'Color','y', 'FontWeight','bold', 'FontSize',24);
for j=1:length(trks)
disp(trks{j}.name)
LineStyle = plotDrawStyle{j}.lineStyle;
switch resultsAll{j}.type
case 'rect'
rectangle('Position', resultsAll{j}.res(i,:), 'EdgeColor', plotDrawStyle{j}.color, 'LineWidth', LineWidth,'LineStyle',LineStyle);
case 'ivtAff'
drawbox(resultsAll{j}.tmplsize, resultsAll{j}.res(i,:), 'Color', plotDrawStyle{j}.color, 'LineWidth', LineWidth,'LineStyle',LineStyle);
case 'L1Aff'
drawAffine(resultsAll{j}.res(i,:), resultsAll{j}.tmplsize, plotDrawStyle{j}.color, LineWidth, LineStyle);
case 'LK_Aff'
[corner c] = getLKcorner(resultsAll{j}.res(2*i-1:2*i,:), resultsAll{j}.tmplsize);
hold on,
plot([corner(1,:) corner(1,1)], [corner(2,:) corner(2,1)], 'Color', plotDrawStyle{j}.color,'LineWidth',LineWidth,'LineStyle',LineStyle);
case '4corner'
corner = resultsAll{j}.res(2*i-1:2*i,:);
hold on,
plot([corner(1,:) corner(1,1)], [corner(2,:) corner(2,1)], 'Color', plotDrawStyle{j}.color,'LineWidth',LineWidth,'LineStyle',LineStyle);
case 'SIMILARITY'
warp_p = parameters_to_projective_matrix(resultsAll{j}.type,resultsAll{j}.res(i,:));
[corner c] = getLKcorner(warp_p, resultsAll{j}.tmplsize);
hold on,
plot([corner(1,:) corner(1,1)], [corner(2,:) corner(2,1)], 'Color', plotDrawStyle{j}.color,'LineWidth',LineWidth,'LineStyle',LineStyle);
otherwise
disp('The type of output is not supported!')
continue;
end
end
set(gca, 'position', [0 0 1 1], 'units', 'normalized')
imwrite(frame2im(getframe(gcf)), [pathSave num2str(i) '.png']);
end
clf
end