3 * mtp is the ``Multi Tracked Paths'', an implementation of the
4 * k-shortest paths algorithm for multi-target tracking.
6 * Copyright (c) 2012 Idiap Research Institute, http://www.idiap.ch/
7 * Written by Francois Fleuret <francois.fleuret@idiap.ch>
9 * This file is part of mtp.
11 * mtp is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 3 as
13 * published by the Free Software Foundation.
15 * mtp is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 * License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with selector. If not, see <http://www.gnu.org/licenses/>.
31 #include "mtp_tracker.h"
33 scalar_t diff_in_second(struct timeval *start, struct timeval *end) {
35 scalar_t(end->tv_sec - start->tv_sec) +
36 scalar_t(end->tv_usec - start->tv_usec)/1000000;
39 int main(int argc, char **argv) {
40 timeval start_time, end_time;
43 cerr << argv[0] << " <tracker file>" << endl;
47 ifstream *in_tracker = new ifstream(argv[1]);
49 if(in_tracker->good()) {
51 MTPTracker *tracker = new MTPTracker();
53 cout << "Reading " << argv[1] << "." << endl;
54 tracker->read(in_tracker);
56 cout << "Building the graph ... "; cout.flush();
57 gettimeofday(&start_time, 0);
58 tracker->build_graph();
59 gettimeofday(&end_time, 0);
60 cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
62 cout << "Tracking ... "; cout.flush();
63 gettimeofday(&start_time, 0);
65 gettimeofday(&end_time, 0);
66 cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
68 ofstream out_traj("result.trj");
69 tracker->write_trajectories(&out_traj);
70 cout << "Wrote result.trj" << endl;
72 ofstream out_dot("graph.dot");
73 tracker->print_graph_dot(&out_dot);
74 cout << "Wrote graph.dot" << endl;
80 cerr << "Can not open " << argv[1] << endl;