diff c/feature-based-tracking.cpp @ 221:bc93e87a2108

cleaned and corrected connected components and feature groups
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 25 Jun 2012 23:50:18 -0400
parents 841a1714f702
children 426321b46e44
line wrap: on
line diff
--- a/c/feature-based-tracking.cpp	Thu Jun 21 23:50:51 2012 -0400
+++ b/c/feature-based-tracking.cpp	Mon Jun 25 23:50:18 2012 -0400
@@ -272,10 +272,9 @@
   // cout << "Loaded " << trajectories.size() << " trajectories one by one in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl;
 
   trajectoryDB->createViewInstants();
-  // int maxTrajectoryLength;
-  // trajectoryDB->maxTrajectoryLength(maxTrajectoryLength);
-  // cout << "max trajectory length " << maxTrajectoryLength << endl;
-  //maxTrajectoryLength = 20; // for tests
+
+  // unsigned int maxTrajectoryLength;
+  // // trajectoryDB->maxTrajectoryLength(maxTrajectoryLength);
 
   // alternative: read and load features in batches directly select * from positions where trajectory_id in select trajectory_id from positions where frame_number <100 and frame_number > 50 group by trajectory_id
   int queryIntervalLength = 100;
@@ -283,7 +282,6 @@
   FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime, params.minNFeaturesPerGroup);
 
   // main loop
-  // TODO version that can be interrupted?
   for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { // frameNum += queryIntervalLength // interval = frameNum, min(frameNum+queryIntervalLength, frameNum+params.nFrames) // stop if no trajectory available ? problem if nothing moves, timeout, get max of trajectory frame numbers
     vector<int> trajectoryIds;
     success  = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending
@@ -302,7 +300,7 @@
     // check for connected components that are old enough (no chance to match with trajectories to be added later
     // we could check only when some features are getting old enough?
     if (frameNum%10 == 0) {
-      featureGraph.connectedComponents(frameNum-maxTrajectoryLength+params.minFeatureTime);
+      featureGraph.connectedComponents(frameNum+params.minFeatureTime);
       vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups();
       for (unsigned int i=0; i<featureGroups.size(); ++i) {
 	trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features"));