Mercurial > hg > nsaunier > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 220:f0f800b95765 | 221:bc93e87a2108 |
|---|---|
| 270 // } | 270 // } |
| 271 // c_end = std::clock(); | 271 // c_end = std::clock(); |
| 272 // 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; |
| 273 | 273 |
| 274 trajectoryDB->createViewInstants(); | 274 trajectoryDB->createViewInstants(); |
| 275 // int maxTrajectoryLength; | 275 |
| 276 // trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); | 276 // unsigned int maxTrajectoryLength; |
| 277 // cout << "max trajectory length " << maxTrajectoryLength << endl; | 277 // // trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); |
| 278 //maxTrajectoryLength = 20; // for tests | |
| 279 | 278 |
| 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 | 279 // 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; | 280 int queryIntervalLength = 100; |
| 282 | 281 |
| 283 FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime, params.minNFeaturesPerGroup); | 282 FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime, params.minNFeaturesPerGroup); |
| 284 | 283 |
| 285 // main loop | 284 // main loop |
| 286 // TODO version that can be interrupted? | |
| 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 | 285 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 |
| 288 vector<int> trajectoryIds; | 286 vector<int> trajectoryIds; |
| 289 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending | 287 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending |
| 290 cout << "frame " << frameNum << " " << success << endl; | 288 cout << "frame " << frameNum << " " << success << endl; |
| 291 cout << trajectoryIds.size() << " trajectories " << endl; | 289 cout << trajectoryIds.size() << " trajectories " << endl; |
| 300 } | 298 } |
| 301 | 299 |
| 302 // check for connected components that are old enough (no chance to match with trajectories to be added later | 300 // check for connected components that are old enough (no chance to match with trajectories to be added later |
| 303 // we could check only when some features are getting old enough? | 301 // we could check only when some features are getting old enough? |
| 304 if (frameNum%10 == 0) { | 302 if (frameNum%10 == 0) { |
| 305 featureGraph.connectedComponents(frameNum-maxTrajectoryLength+params.minFeatureTime); | 303 featureGraph.connectedComponents(frameNum+params.minFeatureTime); |
| 306 vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); | 304 vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); |
| 307 for (unsigned int i=0; i<featureGroups.size(); ++i) { | 305 for (unsigned int i=0; i<featureGroups.size(); ++i) { |
| 308 trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); | 306 trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); |
| 309 savedObjectId++; | 307 savedObjectId++; |
| 310 } | 308 } |
