Mercurial Hosting > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
179:4f10e97cb677 | 180:3a4eef37384f |
---|---|
136 Mat prevDesc, currDesc; | 136 Mat prevDesc, currDesc; |
137 | 137 |
138 vector<FeatureTrajectoryPtr> lostFeatures; | 138 vector<FeatureTrajectoryPtr> lostFeatures; |
139 vector<FeaturePointMatch> featurePointMatches; | 139 vector<FeaturePointMatch> featurePointMatches; |
140 | 140 |
141 FeatureGraph graph(params.mmConnectionDistance, params.mmSegmentationDistance); | |
142 | |
143 int key = '?'; | 141 int key = '?'; |
144 unsigned int savedFeatureId=0; | 142 unsigned int savedFeatureId=0; |
145 Mat frame, currentFrameBW, previousFrameBW; | 143 Mat frame, currentFrameBW, previousFrameBW; |
146 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)) && !::interruptionKey(key); frameNum++) { | 144 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)) && !::interruptionKey(key); frameNum++) { |
147 capture >> frame; | 145 capture >> frame; |
267 //trajectoryDB->createViewInstants("last"); | 265 //trajectoryDB->createViewInstants("last"); |
268 int maxTrajectoryLength; | 266 int maxTrajectoryLength; |
269 trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); | 267 trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); |
270 cout << "max trajectory length " << maxTrajectoryLength << endl; | 268 cout << "max trajectory length " << maxTrajectoryLength << endl; |
271 | 269 |
270 FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime); | |
271 | |
272 // main loop | 272 // main loop |
273 // TODO version que l'on peut interrompre ? | 273 // TODO version que l'on peut interrompre ? |
274 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { | 274 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { |
275 vector<int> trajectoryIds; | 275 vector<int> trajectoryIds; |
276 success = trajectoryDB->trajectoryIdStartingAt(trajectoryIds, frameNum); // ending | 276 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending |
277 cout << "frame " << frameNum << " " << success << endl; | 277 cout << "frame " << frameNum << " " << success << endl; |
278 cout << trajectoryIds.size() << " trajectories " << endl; | 278 cout << trajectoryIds.size() << " trajectories " << endl; |
279 BOOST_FOREACH(int trajectoryId, trajectoryIds) { | 279 BOOST_FOREACH(int trajectoryId, trajectoryIds) { |
280 //cout << trajectoryId << " " << endl; | 280 //cout << trajectoryId << " " << endl; |
281 // boost::shared_ptr<Trajectory<cv::Point2f> > trajectory; | 281 // boost::shared_ptr<Trajectory<cv::Point2f> > trajectory; |
282 // success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities | 282 // success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities |
283 FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities")); | 283 FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities")); |
284 stringstream ss;ss << *ft; cout << ss.str() << endl; | 284 // stringstream ss;ss << *ft; cout << ss.str() << endl; |
285 cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl; | 285 // cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl; |
286 featureGraph.addFeature(ft); | |
286 } | 287 } |
287 | 288 |
288 // should the trajectory be loaded one by one? yes | 289 // should the trajectory be loaded one by one? yes |
289 | 290 |
290 } | 291 cout << featureGraph.informationString() << endl; |
292 } | |
291 | 293 |
292 trajectoryDB->endTransaction(); | 294 trajectoryDB->endTransaction(); |
293 trajectoryDB->disconnect(); | 295 trajectoryDB->disconnect(); |
294 } | 296 } |
295 | 297 |