X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=mtp.git;a=blobdiff_plain;f=mtp_tracker.cc;h=8cc45179fbd9217b58aa2336e777d5aee8cd451d;hp=b91a000ef3f84846d4c2967c7aea78056d61efe5;hb=HEAD;hpb=2bee794949c48671540bc70690d0b77c9168f953 diff --git a/mtp_tracker.cc b/mtp_tracker.cc index b91a000..8cc4517 100644 --- a/mtp_tracker.cc +++ b/mtp_tracker.cc @@ -32,7 +32,7 @@ void MTPTracker::free() { delete[] _edge_lengths; delete _graph; deallocate_array(detection_scores); - deallocate_array(allowed_motion); + deallocate_array(allowed_motions); deallocate_array(exits); deallocate_array(entrances); } @@ -44,14 +44,14 @@ void MTPTracker::allocate(int t, int l) { nb_time_steps = t; detection_scores = allocate_array(nb_time_steps, nb_locations); - allowed_motion = allocate_array(nb_locations, nb_locations); + allowed_motions = allocate_array(nb_locations, nb_locations); entrances = allocate_array(nb_time_steps, nb_locations); exits = allocate_array(nb_time_steps, nb_locations); for(int l = 0; l < nb_locations; l++) { for(int m = 0; m < nb_locations; m++) { - allowed_motion[l][m] = 0; + allowed_motions[l][m] = 0; } } @@ -74,7 +74,7 @@ void MTPTracker::write(ostream *os) { for(int l = 0; l < nb_locations; l++) { for(int m = 0; m < nb_locations; m++) { - (*os) << allowed_motion[l][m]; + (*os) << allowed_motions[l][m]; if(m < nb_locations - 1) (*os) << " "; else (*os) << endl; } } @@ -108,7 +108,7 @@ void MTPTracker::write(ostream *os) { } void MTPTracker::read(istream *is) { - int l, t; + int l = 0, t = 0; (*is) >> l >> t; @@ -116,7 +116,7 @@ void MTPTracker::read(istream *is) { for(int l = 0; l < nb_locations; l++) { for(int m = 0; m < nb_locations; m++) { - (*is) >> allowed_motion[l][m]; + (*is) >> allowed_motions[l][m]; } } @@ -158,7 +158,7 @@ MTPTracker::MTPTracker() { nb_time_steps = 0; detection_scores = 0; - allowed_motion = 0; + allowed_motions = 0; entrances = 0; exits = 0; @@ -168,12 +168,7 @@ MTPTracker::MTPTracker() { } MTPTracker::~MTPTracker() { - delete[] _edge_lengths; - delete _graph; - deallocate_array(detection_scores); - deallocate_array(allowed_motion); - deallocate_array(entrances); - deallocate_array(exits); + free(); } int MTPTracker::early_pair_node(int t, int l) { @@ -197,7 +192,7 @@ void MTPTracker::build_graph() { if(entrances[t][l]) nb_entrances++; } for(int m = 0; m < nb_locations; m++) { - if(allowed_motion[l][m]) nb_motions++; + if(allowed_motions[l][m]) nb_motions++; } } @@ -237,7 +232,7 @@ void MTPTracker::build_graph() { for(int t = 0; t < nb_time_steps - 1; t++) { for(int l = 0; l < nb_locations; l++) { for(int k = 0; k < nb_locations; k++) { - if(allowed_motion[l][k]) { + if(allowed_motions[l][k]) { node_from[e] = late_pair_node(t, l); node_to[e] = early_pair_node(t+1, k); _edge_lengths[e] = 0.0;