diff c/feature-based-tracking.cpp @ 180:3a4eef37384f

method to add features and vertices to graph
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 01 Nov 2011 00:12:33 -0400
parents 4f10e97cb677
children 6c48283a78ca
line wrap: on
line diff
--- a/c/feature-based-tracking.cpp	Mon Oct 31 19:17:42 2011 -0400
+++ b/c/feature-based-tracking.cpp	Tue Nov 01 00:12:33 2011 -0400
@@ -138,8 +138,6 @@
   vector<FeatureTrajectoryPtr> lostFeatures;
   vector<FeaturePointMatch> featurePointMatches;
 
-  FeatureGraph graph(params.mmConnectionDistance, params.mmSegmentationDistance);
-    
   int key = '?';
   unsigned int savedFeatureId=0;
   Mat frame, currentFrameBW, previousFrameBW;
@@ -269,11 +267,13 @@
   trajectoryDB->maxTrajectoryLength(maxTrajectoryLength);
   cout << "max trajectory length " << maxTrajectoryLength << endl;
 
+  FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime);
+
   // main loop
   // TODO version que l'on peut interrompre ?
   for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) {
     vector<int> trajectoryIds;
-    success  = trajectoryDB->trajectoryIdStartingAt(trajectoryIds, frameNum); // ending
+    success  = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending
     cout << "frame " << frameNum << " " << success << endl;
     cout << trajectoryIds.size() << " trajectories " << endl;
     BOOST_FOREACH(int trajectoryId, trajectoryIds) {
@@ -281,13 +281,15 @@
       // boost::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;
+      // stringstream ss;ss << *ft; cout << ss.str() << endl;
+      // cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl;
+      featureGraph.addFeature(ft);
     }
 
     // should the trajectory be loaded one by one? yes
 
-    }
+    cout << featureGraph.informationString() << endl;
+  }
 
   trajectoryDB->endTransaction();
   trajectoryDB->disconnect();