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