X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=inline;f=tracker.cc;h=c90ed440144e93fd49acfdddcebfcda97f4743a4;hb=8946d0df4263aa20a670cedd5d61f9709b858fca;hp=8490d6f859570b5db77fdca38fdb2875004f2036;hpb=ea33e3e5dddbe3796d2361910e1e3ed98a19865c;p=mtp.git diff --git a/tracker.cc b/tracker.cc index 8490d6f..c90ed44 100644 --- a/tracker.cc +++ b/tracker.cc @@ -35,13 +35,11 @@ Tracker::Tracker(int nb_time_steps, int nb_locations) { _edge_lengths = 0; _graph = 0; - _edge_occupation = 0; } Tracker::~Tracker() { delete[] _edge_lengths; delete _graph; - delete[] _edge_occupation; deallocate_array(_detection_score); deallocate_array(_allowed_motion); } @@ -55,9 +53,10 @@ void Tracker::set_detection_score(int time, int location, scalar_t score) { } void Tracker::build_graph() { + + // Delete existing graph delete[] _edge_lengths; - delete[] _graph; - delete[] _edge_occupation; + delete _graph; int nb_motions = 0; for(int l = 0; l < _nb_locations; l++) { @@ -77,7 +76,6 @@ void Tracker::build_graph() { int e = 0; _edge_lengths = new scalar_t[nb_edges]; - _edge_occupation = new int[nb_edges]; // We put the in-node edges first, since these are the ones whose // lengths we will have to change according to the detection score @@ -136,22 +134,28 @@ void Tracker::track() { } } - _graph->find_best_paths(_edge_lengths, _edge_occupation); + _graph->find_best_paths(_edge_lengths); + _graph->retrieve_disjoint_paths(); - _graph->print_dot(); + for(int p = 0; p < _graph->nb_paths; p++) { + Path *path = _graph->paths[p]; + cout << "PATH " << p << " [length " << path->length << "] " << path->nodes[0]; + for(int n = 1; n < path->length; n++) { + cout << " -> " << path->nodes[n]; + } + cout << endl; + } + // _graph->print_dot(); } -// void Tracker::track() { -// } - -// int Tracker::nb_trajectories() { -// } - -// int Tracker::trajectory_start_time(int k) { -// } +int Tracker::nb_trajectories() { + return _graph->nb_paths; +} -// int Tracker::trajectory_end_time(int k) { -// } +int Tracker::trajectory_duration(int k) { + return (_graph->paths[k]->length - 2) / 2; +} -// int Tracker::trajectory_location(int k, int time) { -// } +int Tracker::trajectory_location(int k, int time) { + return (_graph->paths[k]->nodes[2 * time + 1] - 1) % _nb_locations; +}