Added a printout when the tracking itself starts and stops.
[mtp.git] / mtp.cc
1
2 /*
3  *  mtp is the ``Multi Tracked Paths'', an implementation of the
4  *  k-shortest paths algorithm for multi-target tracking.
5  *
6  *  Copyright (c) 2012 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of mtp.
10  *
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.
14  *
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.
19  *
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/>.
22  *
23  */
24
25 #include <iostream>
26 #include <fstream>
27
28 using namespace std;
29
30 #include "mtp_tracker.h"
31
32 int main(int argc, char **argv) {
33
34   if(argc < 2) {
35     cerr << argv[0] << " <tracker file>" << endl;
36     exit(EXIT_FAILURE);
37   }
38
39   ifstream *in_tracker = new ifstream(argv[1]);
40
41   if(in_tracker->good()) {
42
43     MTPTracker *tracker = new MTPTracker();
44
45     tracker->read(in_tracker);
46     cout << "Read " << argv[1] << endl;
47
48     tracker->build_graph();
49     cout << "Starting to track ... "; cout.flush();
50     tracker->track();
51     cout << "done." << endl;
52
53     ofstream out_traj("result.trj");
54     tracker->write_trajectories(&out_traj);
55     cout << "Wrote result.trj" << endl;
56
57     ofstream out_dot("graph.dot");
58     tracker->print_graph_dot(&out_dot);
59     cout << "Wrote graph.dot" << endl;
60
61     delete tracker;
62
63   } else {
64
65     cerr << "Can not open " << argv[1] << endl;
66     exit(EXIT_FAILURE);
67
68   }
69
70   delete in_tracker;
71
72   exit(EXIT_SUCCESS);
73 }