* IMPLEMENTATION
-The two main classes are MTPGraph and Tracker.
+The two main classes are MTPGraph and MTPTracker.
The MTPGraph class stores a directed acyclic graph (DAG), with a
length for each edge -- which can be negative -- and can compute the
the sense that the family it computes eventually is globally optimal,
even if the computation is iterative.
-The Tracker class allows
+The MTPTracker class allows
(1) to define a spatial topology composed of
score (i.e. the sum of the detection scores of the nodes visited by
the trajectories)
-The Tracker class uses the MTPGraph. From the definition of the
+The MTPTracker class uses the MTPGraph. From the definition of the
spatial topology, it builds a graph with one source, one sink, and two
nodes per location and time. This structure ensures the trajectories
computed by the tracker to be node-disjoint by forcing the paths
of length zero, and the edge between the two nodes of such a pair has
a length equal to the opposite of the detection score.
-The file mtp.cc gives a very simple usage example of the Tracker
+The file mtp.cc gives a very simple usage example of the MTPTracker
class.
-The tracker data file one can read with Tracker::read has the
+The tracker data file one can read with MTPTracker::read has the
following format (with L the number of locations and T the number of
time steps):
*
*/
-#include "tracker.h"
+#include "mtp_tracker.h"
#include <iostream>
using namespace std;
-void Tracker::free() {
+void MTPTracker::free() {
delete[] _edge_lengths;
delete _graph;
deallocate_array<scalar_t>(detection_scores);
delete[] entrances;
}
-void Tracker::allocate(int nb_time_steps, int nb_locations) {
+void MTPTracker::allocate(int nb_time_steps, int nb_locations) {
free();
_nb_locations = nb_locations;
_graph = 0;
}
-void Tracker::write(ostream *os) {
+void MTPTracker::write(ostream *os) {
(*os) << _nb_locations << " " << _nb_time_steps <<endl;
(*os) << endl;
}
}
-void Tracker::read(istream *is) {
+void MTPTracker::read(istream *is) {
int nb_locations, nb_time_steps;
(*is) >> nb_locations >> nb_time_steps;
}
}
-void Tracker::write_trajectories(ostream *os) {
+void MTPTracker::write_trajectories(ostream *os) {
for(int t = 0; t < nb_trajectories(); t++) {
(*os) << t
<< " " << trajectory_entrance_time(t)
}
}
-Tracker::Tracker() {
+MTPTracker::MTPTracker() {
_nb_locations = 0;
_nb_time_steps = 0;
_graph = 0;
}
-Tracker::~Tracker() {
+MTPTracker::~MTPTracker() {
delete[] _edge_lengths;
delete _graph;
deallocate_array<scalar_t>(detection_scores);
delete[] entrances;
}
-int Tracker::early_pair_node(int t, int l) {
+int MTPTracker::early_pair_node(int t, int l) {
return 1 + (2 * (t + 0) + 0) * _nb_locations + l;
}
-int Tracker::late_pair_node(int t, int l) {
+int MTPTracker::late_pair_node(int t, int l) {
return 1 + (2 * (t + 0) + 1) * _nb_locations + l;
}
-void Tracker::build_graph() {
+void MTPTracker::build_graph() {
// Delete the existing graph if there was one
delete[] _edge_lengths;
delete _graph;
delete[] node_to;
}
-void Tracker::print_graph_dot(ostream *os) {
+void MTPTracker::print_graph_dot(ostream *os) {
int e = 0;
for(int t = 0; t < _nb_time_steps; t++) {
for(int l = 0; l < _nb_locations; l++) {
_graph->print_dot(os);
}
-void Tracker::track() {
+void MTPTracker::track() {
ASSERT(_graph);
int e = 0;
#endif
}
-int Tracker::nb_trajectories() {
+int MTPTracker::nb_trajectories() {
return _graph->nb_paths;
}
-scalar_t Tracker::trajectory_score(int k) {
+scalar_t MTPTracker::trajectory_score(int k) {
return -_graph->paths[k]->length;
}
-int Tracker::trajectory_entrance_time(int k) {
+int MTPTracker::trajectory_entrance_time(int k) {
return (_graph->paths[k]->nodes[1] - 1) / (2 * _nb_locations);
}
-int Tracker::trajectory_duration(int k) {
+int MTPTracker::trajectory_duration(int k) {
return (_graph->paths[k]->nb_nodes - 2) / 2;
}
-int Tracker::trajectory_location(int k, int time_from_entry) {
+int MTPTracker::trajectory_location(int k, int time_from_entry) {
return (_graph->paths[k]->nodes[2 * time_from_entry + 1] - 1) % _nb_locations;
}