-
Notifications
You must be signed in to change notification settings - Fork 168
/
MOT_make_videos.m
60 lines (52 loc) · 1.73 KB
/
MOT_make_videos.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
% --------------------------------------------------------
% MDP Tracking
% Copyright (c) 2015 CVGL Stanford
% Licensed under The MIT License [see LICENSE for details]
% Written by Yu Xiang
% --------------------------------------------------------
function MOT_make_videos
is_save = 1;
opt = globals();
N = numel(opt.mot2d_test_seqs);
for seq_idx = 1:N
close all;
hf = figure(1);
seq_name = opt.mot2d_test_seqs{seq_idx};
seq_num = opt.mot2d_test_nums(seq_idx);
% build the dres structure for images
filename = sprintf('%s/%s_dres_image.mat', opt.results, seq_name);
if exist(filename, 'file') ~= 0
object = load(filename);
dres_image = object.dres_image;
fprintf('load images from file %s done\n', filename);
else
dres_image = read_dres_image(opt, seq_set, seq_name, seq_num);
fprintf('read images done\n');
save(filename, 'dres_image', '-v7.3');
end
% read tracking results
filename = sprintf('results_MOT/results_MOT_1/%s.txt', seq_name);
dres_track = read_mot2dres(filename);
fprintf('read tracking results from %s\n', filename);
ids = unique(dres_track.id);
cmap = colormap(hsv(numel(ids)));
cmap = cmap(randperm(numel(ids)),:);
if is_save
file_video = sprintf('results_MOT/results_MOT_1/%s.avi', seq_name);
aviobj = VideoWriter(file_video);
aviobj.FrameRate = 9;
open(aviobj);
fprintf('save video to %s\n', file_video);
end
for fr = 1:seq_num
show_dres(fr, dres_image.I{fr}, '', dres_track, 2, cmap);
if is_save
writeVideo(aviobj, getframe(hf));
else
pause;
end
end
if is_save
close(aviobj);
end
end