-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheckTracking.m
40 lines (32 loc) · 1.25 KB
/
checkTracking.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
function error = checkTracking( data, estimatedIds )
% error = checkTracking( data, estimatedIds )
% Compares ids in data and in estimatedIds
% Inputs:
% data - a struct, that can be loaded from "data.mat"
% estimatedIds - cell array, with size data.nFrames, each element is a
% vector of integers, representing an id of the corresponding
% rectangle from the data.
% Outputs:
% error - double from 0 to 1, showing percentage of wringly tracked rects
nRectangles = 0;
nCorrectlyTracked = 0;
for frame=2:data.nFrames
% current frame
idsEst = estimatedIds{frame}; % estimated ids
idsOrig = getIdsFromDataFrame(data.Frames(frame)); % original ids
% previous frame
idsEstPrev = estimatedIds{frame-1}; % estimated
idsOrigPrev = getIdsFromDataFrame(data.Frames(frame-1)); % original
% find and compare permutatings
[~, permutingOrig] = ismember(idsOrig, idsOrigPrev);
[~, permutingEst] = ismember(idsEst, idsEstPrev);
% update statistics
nRectangles = nRectangles + numel(idsOrig);
nCorrectlyTracked = nCorrectlyTracked + ...
sum(permutingOrig==permutingEst);
if sum(permutingOrig~=permutingEst)>0
%disp(frame);
end
end;
error = 1 - nCorrectlyTracked/nRectangles;
end