Mercurial > hg > nsaunier > traffic-intelligence
comparison c/feature-based-tracking.cpp @ 717:9d6cd4e8dca3
merged major bug correction
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Sat, 25 Jul 2015 23:29:11 -0400 |
| parents | 85af65b6d531 |
| children | 2cade72d75ad |
comparison
equal
deleted
inserted
replaced
| 714:d6c69d3d09e5 | 717:9d6cd4e8dca3 |
|---|---|
| 295 for (frameNum = firstFrameNum; frameNum<lastFrameNum; frameNum ++) { | 295 for (frameNum = firstFrameNum; frameNum<lastFrameNum; frameNum ++) { |
| 296 vector<int> trajectoryIds; | 296 vector<int> trajectoryIds; |
| 297 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); | 297 success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); |
| 298 if (frameNum%100 ==0) | 298 if (frameNum%100 ==0) |
| 299 cout << "frame " << frameNum << endl; | 299 cout << "frame " << frameNum << endl; |
| 300 //success = trajectoryDB->trajectoryIdInInterval(trajectoryIds, frameNum, min(frameNum+queryIntervalLength-1, frameNum+params.nFrames)); // ending | |
| 301 #if DEBUG | 300 #if DEBUG |
| 302 cout << trajectoryIds.size() << " trajectories " << endl; | 301 cout << trajectoryIds.size() << " trajectories " << endl; |
| 303 #endif | 302 #endif |
| 304 // vector<TrajectoryPoint2fPtr> positions, velocities; | |
| 305 // trajectoryDB->read(positions, trajectoryIds, "positions"); | |
| 306 // trajectoryDB->read(velocities, trajectoryIds, "velocities"); | |
| 307 // for (unsigned int i=0; i<trajectoryIds.size(); ++i) { | |
| 308 // FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(positions[i], velocities[i])); | |
| 309 BOOST_FOREACH(int trajectoryId, trajectoryIds) { | 303 BOOST_FOREACH(int trajectoryId, trajectoryIds) { |
| 310 //cout << trajectoryId << " " << endl; | |
| 311 // std::shared_ptr<Trajectory<cv::Point2f> > trajectory; | |
| 312 // success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities | |
| 313 FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities")); | 304 FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities")); |
| 314 // stringstream ss;ss << *ft; cout << ss.str() << endl; | |
| 315 // cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl; | |
| 316 featureGraph.addFeature(ft); | 305 featureGraph.addFeature(ft); |
| 317 } | 306 } |
| 318 | 307 |
| 319 // check for connected components | 308 // check for connected components |
| 320 int lastInstant = frameNum+params.minFeatureTime-maxTrajectoryLength; | 309 int lastInstant = frameNum+params.minFeatureTime-maxTrajectoryLength; |
| 324 featureGraph.getFeatureGroups(featureGroups); | 313 featureGraph.getFeatureGroups(featureGroups); |
| 325 for (unsigned int i=0; i<featureGroups.size(); ++i) { | 314 for (unsigned int i=0; i<featureGroups.size(); ++i) { |
| 326 vector<unsigned int> featureNumbers; | 315 vector<unsigned int> featureNumbers; |
| 327 for (unsigned int j=0; j<featureGroups[i].size(); ++j) | 316 for (unsigned int j=0; j<featureGroups[i].size(); ++j) |
| 328 featureNumbers.push_back(featureGroups[i][j]->getId()); | 317 featureNumbers.push_back(featureGroups[i][j]->getId()); |
| 329 trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown */, 1, string("objects"), string("objects_features")); | 318 trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown type */, 1, string("objects"), string("objects_features")); |
| 330 savedObjectId++; | 319 savedObjectId++; |
| 331 } | 320 } |
| 332 } | 321 } |
| 333 | 322 |
| 334 if (frameNum%100 ==0) | 323 if (frameNum%100 ==0) |
