The methods MTPTracker::write_trajectories now writes first the number of trajectories.
[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   int _nb_locations, _nb_time_steps;
37   scalar_t **_detection_score;
38   int **_allowed_motion;
39   int *_entrances, *_exits;
40
41   MTPGraph *_graph;
42   scalar_t *_edge_lengths;
43
44   int early_pair_node(int t, int l);
45   int late_pair_node(int t, int l);
46
47 public:
48
49   // The spatial structure
50   int **allowed_motion;
51   int *entrances, *exits;
52
53   // The detection scores at each location and time
54   scalar_t **detection_scores;
55
56   MTPTracker();
57   ~MTPTracker();
58
59   void allocate(int nb_time_steps, int nb_locations);
60   void free();
61
62   void write(ostream *os);
63   void read(istream *is);
64   void write_trajectories(ostream *os);
65
66   // Build or print the graph needed for the tracking per se
67
68   void build_graph();
69   void print_graph_dot(ostream *os);
70
71   // Compute the optimal set of trajectories
72
73   void track();
74
75   // Read-out of the optimal trajectories
76
77   int nb_trajectories();
78   scalar_t trajectory_score(int k);
79   int trajectory_entrance_time(int k);
80   int trajectory_duration(int k);
81   int trajectory_location(int k, int time_from_entry);
82 };
83
84 #endif