Mercurial Hosting > traffic-intelligence
comparison c/feature-based-tracking.cpp @ 172:e508bb0cbb64
modified comments
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 25 Oct 2011 19:01:21 -0400 |
parents | 5f705809d37a |
children | ec9734015d53 |
comparison
equal
deleted
inserted
replaced
171:8e7b354666ec | 172:e508bb0cbb64 |
---|---|
243 boost::shared_ptr<TrajectoryDBAccessList<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccessList<Point2f> >(new TrajectoryDBAccessList<Point2f>()); | 243 boost::shared_ptr<TrajectoryDBAccessList<Point2f> > trajectoryDB = boost::shared_ptr<TrajectoryDBAccessList<Point2f> >(new TrajectoryDBAccessList<Point2f>()); |
244 //TODO write generic methods for blob and list versions TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>(); | 244 //TODO write generic methods for blob and list versions TrajectoryDBAccess<Point2f>* trajectoryDB = new TrajectoryDBAccessBlob<Point2f>(); |
245 bool success = trajectoryDB->connect(params.databaseFilename.c_str()); | 245 bool success = trajectoryDB->connect(params.databaseFilename.c_str()); |
246 vector<boost::shared_ptr<Trajectory<Point2f> > > trajectories; | 246 vector<boost::shared_ptr<Trajectory<Point2f> > > trajectories; |
247 cout << trajectories.size() << endl; | 247 cout << trajectories.size() << endl; |
248 success = trajectoryDB->read(trajectories, "positions"); // TODO load velocities as well | 248 success = trajectoryDB->read(trajectories, "positions"); // TODO load velocities as well in a FeatureTrajectory object // attention, velocities lack the first instant |
249 cout << "Loaded " << trajectories.size() << " trajectories" << endl; | 249 cout << "Loaded " << trajectories.size() << " trajectories" << endl; |
250 // for (int i=0; i<5; ++i) { | 250 // for (int i=0; i<5; ++i) { |
251 // stringstream ss; | 251 // stringstream ss; |
252 // ss << *trajectories[i]; | 252 // ss << *trajectories[i]; |
253 // cout << ss.str() << endl; | 253 // cout << ss.str() << endl; |
254 // } | 254 // } |
255 | 255 |
256 // create views for first and last instants for each trajectory | |
257 // CREATE VIEW IF NOT EXISTS trajectory_first_instants AS select trajectory_id, min(frame_number) as first_instant from positions group by trajectory_id | |
258 // CREATE VIEW IF NOT EXISTS trajectory_last_instants AS select trajectory_id, max(frame_number) as last_instant from positions group by trajectory_id | |
259 //select trajectory_id from trajectory_first_instants where first_instant = 49 | |
260 | |
261 trajectoryDB->createViewInstants("first"); | 256 trajectoryDB->createViewInstants("first"); |
262 trajectoryDB->createViewInstants("last"); | 257 trajectoryDB->createViewInstants("last"); |
263 | 258 |
264 // main loop | 259 // main loop |
265 // TODO version que l'on peut interrompre ? | 260 // TODO version que l'on peut interrompre ? |
266 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { | 261 for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { |
267 vector<int> ids; | 262 vector<int> ids; |
268 cout << "frame " << frameNum << " " << trajectoryDB->trajectoryIdStartingAt(ids, frameNum) << endl; | 263 cout << "frame " << frameNum << " " << trajectoryDB->trajectoryIdStartingAt(ids, frameNum) << endl; |
264 cout << ids.size() << ": "; | |
269 BOOST_FOREACH(int i, ids) | 265 BOOST_FOREACH(int i, ids) |
270 cout << i << " "; | 266 cout << i << " "; |
271 cout << endl; | 267 cout << endl; |
268 | |
269 // should the trajectory be loaded one by one? yes | |
270 | |
272 } | 271 } |
273 | 272 |
274 trajectoryDB->endTransaction(); | 273 trajectoryDB->endTransaction(); |
275 trajectoryDB->disconnect(); | 274 trajectoryDB->disconnect(); |
276 } | 275 } |