Made some parts clearer.
[mtp.git] / mtp_tracker.h
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 #ifndef MTP_TRACKER_H
26 #define MTP_TRACKER_H
27
28 #include <iostream>
29
30 using namespace std;
31
32 #include "misc.h"
33 #include "mtp_graph.h"
34
35 class MTPTracker {
36   MTPGraph *_graph;
37   scalar_t *_edge_lengths;
38
39   int early_pair_node(int t, int l);
40   int late_pair_node(int t, int l);
41
42 public:
43
44   // The spatial structure
45   int nb_locations, nb_time_steps;
46   int **allowed_motions;
47   int **entrances, **exits;
48
49   // The detection scores at each location and time
50   scalar_t **detection_scores;
51
52   MTPTracker();
53   ~MTPTracker();
54
55   void allocate(int nb_time_steps, int nb_locations);
56   void free();
57
58   void write(ostream *os);
59   void read(istream *is);
60   void write_trajectories(ostream *os);
61
62   // Build or print the graph needed for the tracking per se
63
64   void build_graph();
65   void print_graph_dot(ostream *os);
66
67   // Compute the optimal set of trajectories
68
69   void track();
70
71   // Read-out of the optimal trajectories
72
73   int nb_trajectories();
74   scalar_t trajectory_score(int k);
75   int trajectory_entrance_time(int k);
76   int trajectory_duration(int k);
77   int trajectory_location(int k, int time_from_entry);
78 };
79
80 #endif