16f05263f204dc9ccb180271894d0c14c77c49d6
[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 // Multi-Tracked Path
26
27 #include <iostream>
28 #include <fstream>
29
30 using namespace std;
31
32 #include "tracker.h"
33
34 int main(int argc, char **argv) {
35
36   if(argc < 2) {
37     cerr << argv[0] << " <tracker file>" << endl;
38     exit(EXIT_FAILURE);
39   }
40
41   ifstream *in_tracker = new ifstream(argv[1]);
42
43   if(in_tracker->good()) {
44
45     Tracker *tracker = new Tracker();
46
47     tracker->read(in_tracker);
48     cout << "Read " << argv[1] << endl;
49
50     tracker->build_graph();
51     tracker->track();
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 }