comparison c/feature-based-tracking.cpp @ 219:841a1714f702

added comments for future development
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 21 Jun 2012 19:10:47 -0400
parents 48f83ff769fd
children bc93e87a2108
comparison
equal deleted inserted replaced
218:b5772df11b37 219:841a1714f702
248 trajectoryDB->endTransaction(); 248 trajectoryDB->endTransaction();
249 trajectoryDB->disconnect(); 249 trajectoryDB->disconnect();
250 } 250 }
251 251
252 void groupFeatures(const KLTFeatureTrackingParameters& params) { 252 void groupFeatures(const KLTFeatureTrackingParameters& params) {
253 cout << "group" << endl;
254
255 boost::shared_ptr<TrajectoryDBAccessList<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccessList<Point2f> >(new TrajectoryDBAccessList<Point2f>()); 253 boost::shared_ptr<TrajectoryDBAccessList<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccessList<Point2f> >(new TrajectoryDBAccessList<Point2f>());
256 //TODO write generic methods for blob and list versions TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>(); 254 //TODO write generic methods for blob and list versions TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>();
257 bool success = trajectoryDB->connect(params.databaseFilename.c_str()); 255 bool success = trajectoryDB->connect(params.databaseFilename.c_str());
258 trajectoryDB->createObjectTable("objects", "objects_features"); 256 trajectoryDB->createObjectTable("objects", "objects_features");
259 unsigned int savedObjectId=0; 257 unsigned int savedObjectId=0;
272 // } 270 // }
273 // c_end = std::clock(); 271 // c_end = std::clock();
274 // cout << "Loaded " << trajectories.size() << " trajectories one by one in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl; 272 // cout << "Loaded " << trajectories.size() << " trajectories one by one in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl;
275 273
276 trajectoryDB->createViewInstants(); 274 trajectoryDB->createViewInstants();
277 int maxTrajectoryLength; 275 // int maxTrajectoryLength;
278 trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); 276 // trajectoryDB->maxTrajectoryLength(maxTrajectoryLength);
279 cout << "max trajectory length " << maxTrajectoryLength << endl; 277 // cout << "max trajectory length " << maxTrajectoryLength << endl;
280 maxTrajectoryLength = 20; // for tests 278 //maxTrajectoryLength = 20; // for tests
279
280 // 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
281 int queryIntervalLength = 100;
281 282
282 FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime, params.minNFeaturesPerGroup); 283 FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime, params.minNFeaturesPerGroup);
283 284
284 // main loop 285 // main loop
285 // TODO version that can be interrupted? 286 // TODO version that can be interrupted?
286 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { 287 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
287 vector<int> trajectoryIds; 288 vector<int> trajectoryIds;
288 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending 289 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending
289 cout << "frame " << frameNum << " " << success << endl; 290 cout << "frame " << frameNum << " " << success << endl;
290 cout << trajectoryIds.size() << " trajectories " << endl; 291 cout << trajectoryIds.size() << " trajectories " << endl;
291 BOOST_FOREACH(int trajectoryId, trajectoryIds) { 292 BOOST_FOREACH(int trajectoryId, trajectoryIds) {