Repository navigation
Expand file tree
/
Copy pathupdateAssignedTracks.m
More file actions
72 lines (52 loc) · 2.27 KB
/
Copy pathupdateAssignedTracks.m
File metadata and controls
72 lines (52 loc) · 2.27 KB
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
function tracks = updateAssignedTracks(assignments,centroids,bboxes,tracks)
numAssignedTracks = size(assignments, 1);
largeInd=0;
maxLen=0;
for i = 1:numAssignedTracks
trackIdx = assignments(i, 1);
detectionIdx = assignments(i, 2);
centroid = centroids(detectionIdx, :);
bbox = bboxes(detectionIdx, :);
% correct the estimate of the object's location
% using the new detection
correct(tracks(trackIdx).kalmanFilter, centroid);
% replace predicted bounding box with detected
% bounding box
tracks(trackIdx).bbox = bbox;
%right?????
tracks(trackIdx).bboxHist(end+1,:) = bbox;
siz=size(tracks(trackIdx).bboxHist);
if siz>maxLen
largeInd=trackIdx;
end
[oldCentX,oldCentY]=findCentroid(tracks(trackIdx).bboxHist(end-1,:));
[newCentX,newCentY]=findCentroid(tracks(trackIdx).bboxHist(end,:));
%displacement doesn't care about direction, thus abs
tracks(trackIdx).xMotion(end+1)=abs(newCentX-oldCentX);
tracks(trackIdx).yMotion(end+1)=abs(newCentY-oldCentY);
tracks(trackIdx).time(end+1)=now;
t=(now-tracks(trackIdx).time(end-1))/10^(-5);
%fprintf('time %d\n',t);
% update track's age
tracks(trackIdx).age = tracks(trackIdx).age + 1;
% update visibility
tracks(trackIdx).totalVisibleCount = ...
tracks(trackIdx).totalVisibleCount + 1;
tracks(trackIdx).consecutiveInvisibleCount = 0;
end
if largeInd>0
boxes=tracks(largeInd).bboxHist;
x=boxes(:,1);
y=boxes(:,2);
figure(3);
plot(x,y);
str=sprintf('Number %d',tracks(largeInd).id);
title(str);
axis([0 640 0 480]);
figure(5);
x=tracks(largeInd).xMotion;
y=tracks(largeInd).yMotion;
plot(x);
axis([0 12 0 150]);
end
end