Added README.md
[mtp.git] / mtp_tracker.cc
index b91a000..8cc4517 100644 (file)
@@ -32,7 +32,7 @@ void MTPTracker::free() {
   delete[] _edge_lengths;
   delete _graph;
   deallocate_array<scalar_t>(detection_scores);
-  deallocate_array<int>(allowed_motion);
+  deallocate_array<int>(allowed_motions);
   deallocate_array<int>(exits);
   deallocate_array<int>(entrances);
 }
@@ -44,14 +44,14 @@ void MTPTracker::allocate(int t, int l) {
   nb_time_steps = t;
 
   detection_scores = allocate_array<scalar_t>(nb_time_steps, nb_locations);
-  allowed_motion = allocate_array<int>(nb_locations, nb_locations);
+  allowed_motions = allocate_array<int>(nb_locations, nb_locations);
 
   entrances = allocate_array<int>(nb_time_steps, nb_locations);
   exits = allocate_array<int>(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<scalar_t>(detection_scores);
-  deallocate_array<int>(allowed_motion);
-  deallocate_array<int>(entrances);
-  deallocate_array<int>(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;