-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathevaluateTrackB.m
117 lines (109 loc) · 3.97 KB
/
evaluateTrackB.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
function [tendallMets, allresult] = evaluateTrackB(seqPath, resPath, gtPath, evalClassSet)
% Input:
% - seqPath
% Sequence path is the path of all sequences to be evaluated in a single run.
%
% - resPath
% The folder containing the tracking results. Each one should be saved in a
% separate .txt file with the name of the respective sequence
%
% - gtPath
% The folder containing the groundtruth files.
%
% - evalClassSet
% The set of evaluated object category
%
% Output:
% - tendallMets
% Scores for each sequence on the evaluated object category
%
% - allresult
% Aggregate score over all sequences
% benchmark specific properties
world = 0;
% read sequence list
allSequences = findSeqList(seqPath); % find the sequence list
fprintf('Sequences: \n');
disp(allSequences');
numSeqs = length(allSequences);
gtMat = cell(1, numSeqs);
resMat = cell(1, numSeqs);
%% evaluate sequences individually
allMets = [];
tendallMets = [];
allresult = [];
for ind = 1:numSeqs
% parse groundtruth
sequenceName = char(allSequences(ind));
sequenceFolder = fullfile(seqPath, sequenceName, filesep);
dataset = dir(fullfile(sequenceFolder, '*.jpg'));
img = imread(fullfile(sequenceFolder, dataset(1).name));
[imgHeight, imgWidth, ~] = size(img);
fprintf('\t... %s\n',sequenceName);
assert(isdir(sequenceFolder), 'Sequence folder %s missing.\n', sequenceFolder);
gtFilename = fullfile(gtPath, [allSequences{ind} '.txt']);
if(~exist(gtFilename, 'file'))
error('No annotation files is provided for evaluation.');
end
gtdata_ori = dlmread(gtFilename);
% process groudtruth
clean_gtFilename = fullfile(gtPath, [allSequences{ind} '_clean.txt']);
if(~exist(clean_gtFilename, 'file'))
gtdata = dropObjects(gtdata_ori, gtdata_ori, imgHeight, imgWidth);
dlmwrite(clean_gtFilename, gtdata);
else
gtdata = dlmread(clean_gtFilename);
end
% break the groundtruth trajetory with multiple object categories
gtdata = breakGts(gtdata);
gtMat{ind} = gtdata;
% split the groundtruth for each object category
gtsortdata = classSplit(gtdata);
% parse result
resFilename = fullfile(resPath, [allSequences{ind} '.txt']);
% read result file
if(exist(resFilename,'file'))
s = dir(resFilename);
if(s.bytes ~= 0)
resdata = dlmread(resFilename);
else
resdata = zeros(0,9);
end
else
error('Invalid submission. Result file for sequence %s is missing or invalid\n', resFilename);
end
% process result
resdata = dropObjects(resdata, gtdata_ori, imgHeight, imgWidth);
resdata(resdata(:,1) > max(gtMat{ind}(:,1)),:) = []; % clip result to gtMaxFrame
resMat{ind} = resdata;
% split the result for each object category
ressortdata = classSplit(resdata);
% evaluate sequence
tendMets = classEval(gtsortdata, ressortdata, allMets, ind, evalClassSet, sequenceName);
tendallMets = [tendallMets,tendMets];
tendmetsBenchmark = evaluateBenchmark(tendMets, world);
fprintf(' ********************* Sequence %s Results *********************\n', sequenceName);
printMetrics(tendmetsBenchmark);
allresult = cat(1, allresult, tendmetsBenchmark);
end
%% calculate overall scores
metsBenchmark = evaluateBenchmark(tendallMets, world);
allresult = cat(1, allresult, metsBenchmark);
fprintf('\n');
fprintf(' ********************* Your VisDrone2019 Results *********************\n');
printMetrics(metsBenchmark);
fprintf('\n');
%% calculate overall scores for each object category
for k = 1:length(evalClassSet)
className = evalClassSet{k};
cateallMets = [];
curInd = k:length(evalClassSet):length(tendallMets);
for i = 1:length(curInd)
cateallMets = [cateallMets, tendallMets(curInd(i))];
end
metsCategory = evaluateBenchmark(cateallMets, world);
metsCategory(isnan(metsCategory)) = 0;
fprintf('evaluating tracking %s:\n', className);
printMetrics(metsCategory);
fprintf('\n');
end