changeset 717:9d6cd4e8dca3

merged major bug correction
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 25 Jul 2015 23:29:11 -0400
parents d6c69d3d09e5 (current diff) 85af65b6d531 (diff)
children 2cd245cb780d
files
diffstat 2 files changed, 15 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/c/Motion.cpp	Fri Jul 24 17:58:59 2015 -0400
+++ b/c/Motion.cpp	Sat Jul 25 23:29:11 2015 -0400
@@ -188,7 +188,7 @@
 #endif
 
   vector<unsigned int> lastInstants(num, 0); // last instant of component with id
-  vector<vector<vertex_descriptor> > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors)
+  vector<vector<vertex_descriptor> > tmpobjects(num); // vector of components (component = vector of vertex descriptors)
 
   graph_traits<UndirectedGraph>::vertex_iterator vi, vend;
   for(boost::tuples::tie(vi,vend) = vertices(graph); vi != vend; ++vi) {
@@ -215,24 +215,25 @@
     unsigned int totalFeatureTime= graph[objectHypotheses[i][0]].feature->length();
     unsigned int firstInstant = graph[objectHypotheses[i][0]].feature->getFirstInstant();
     unsigned int lastInstant = graph[objectHypotheses[i][0]].feature->getLastInstant();
-      for (unsigned int j=1; j<objectHypotheses[i].size(); ++j) {
-	totalFeatureTime += graph[objectHypotheses[i][j]].feature->length();
-	firstInstant = MIN(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant());
-	lastInstant = MAX(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant());	
-      }
-    if (static_cast<float>(totalFeatureTime)/static_cast<float>(lastInstant-firstInstant+1) > minNFeaturesPerGroup) {
+    for (unsigned int j=1; j<objectHypotheses[i].size(); ++j) {
+      totalFeatureTime += graph[objectHypotheses[i][j]].feature->length();
+      firstInstant = MIN(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant());
+      lastInstant = MAX(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant());	
+    }
+    bool saveFeatureGroup = (static_cast<float>(totalFeatureTime)/static_cast<float>(lastInstant-firstInstant+1) > minNFeaturesPerGroup);
 #if DEBUG
-      cout << "save group " << i << " of " << objectHypotheses[i].size() << " features " << endl;
+    cout << "save group " << i << " of " << objectHypotheses[i].size() << " features " << endl;
 #endif
+    if (saveFeatureGroup)
       featureGroups.push_back(vector<FeatureTrajectoryPtr>());
-      for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) {
+    for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) {
+      if (saveFeatureGroup)
 	featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature);
 #if DEBUG
-	cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl;
+      cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl;
 #endif
-	clear_vertex(objectHypotheses[i][j], graph);
-	remove_vertex(objectHypotheses[i][j], graph);
-      }
+      clear_vertex(objectHypotheses[i][j], graph);
+      remove_vertex(objectHypotheses[i][j], graph);
     }
   }
 }
--- a/c/feature-based-tracking.cpp	Fri Jul 24 17:58:59 2015 -0400
+++ b/c/feature-based-tracking.cpp	Sat Jul 25 23:29:11 2015 -0400
@@ -297,22 +297,11 @@
     success  = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum);
     if (frameNum%100 ==0)
       cout << "frame " << frameNum << endl;
-    //success  = trajectoryDB->trajectoryIdInInterval(trajectoryIds, frameNum, min(frameNum+queryIntervalLength-1, frameNum+params.nFrames)); // ending
 #if DEBUG
     cout << trajectoryIds.size() << " trajectories " << endl;
 #endif
-    // vector<TrajectoryPoint2fPtr> positions, velocities;
-    // trajectoryDB->read(positions, trajectoryIds, "positions");
-    // trajectoryDB->read(velocities, trajectoryIds, "velocities");
-    // for (unsigned int i=0; i<trajectoryIds.size(); ++i) {
-    //   FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(positions[i], velocities[i]));
     BOOST_FOREACH(int trajectoryId, trajectoryIds) {
-      //cout << trajectoryId << " " << endl;
-      // std::shared_ptr<Trajectory<cv::Point2f> > trajectory;
-      // success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities
       FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities"));
-      // stringstream ss;ss << *ft; cout << ss.str() << endl;
-      // cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl;
       featureGraph.addFeature(ft);
     }
 
@@ -326,7 +315,7 @@
 	vector<unsigned int> featureNumbers;
 	for (unsigned int j=0; j<featureGroups[i].size(); ++j)
 	  featureNumbers.push_back(featureGroups[i][j]->getId());
-	trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown */, 1, string("objects"), string("objects_features"));
+	trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown type */, 1, string("objects"), string("objects_features"));
 	savedObjectId++;
       }
     }