# HG changeset patch # User Nicolas Saunier # Date 1319665571 14400 # Node ID ec9734015d53fbbc86f2abd97a0c552773aa19ce # Parent 319a04ba9033f652044071e87e993266ffc62183 tested loading trajectory by id numbers diff -r 319a04ba9033 -r ec9734015d53 c/feature-based-tracking.cpp --- a/c/feature-based-tracking.cpp Wed Oct 26 15:04:38 2011 -0400 +++ b/c/feature-based-tracking.cpp Wed Oct 26 17:46:11 2011 -0400 @@ -18,6 +18,7 @@ #include #include +#include using namespace std; using namespace cv; @@ -61,6 +62,10 @@ } void trackFeatures(const KLTFeatureTrackingParameters& params) { + // BriefDescriptorExtractor brief(32); + // const int DESIRED_FTRS = 500; + // GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4); + Mat homography = ::loadMat(params.homographyFilename, " "); Mat invHomography; if (params.display && !homography.empty()) @@ -245,13 +250,18 @@ bool success = trajectoryDB->connect(params.databaseFilename.c_str()); vector > > trajectories; cout << trajectories.size() << endl; - success = trajectoryDB->read(trajectories, "positions"); // TODO load velocities as well in a FeatureTrajectory object // attention, velocities lack the first instant - cout << "Loaded " << trajectories.size() << " trajectories" << endl; - // for (int i=0; i<5; ++i) { - // stringstream ss; - // ss << *trajectories[i]; - // cout << ss.str() << endl; + // std::clock_t c_start = std::clock(); + // success = trajectoryDB->read(trajectories, "positions"); // TODO load velocities as well in a FeatureTrajectory object // attention, velocities lack the first instant + // std::clock_t c_end = std::clock(); + // cout << "Loaded " << trajectories.size() << " trajectories in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl; + + // boost::shared_ptr > trajectory; + // c_start = std::clock(); + // for (unsigned int i = 0; iread(trajectory, i, "positions"); // } + // c_end = std::clock(); + // cout << "Loaded " << trajectories.size() << " trajectories one by one in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl; trajectoryDB->createViewInstants("first"); trajectoryDB->createViewInstants("last"); @@ -259,26 +269,26 @@ // main loop // TODO version que l'on peut interrompre ? for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { - vector ids; - cout << "frame " << frameNum << " " << trajectoryDB->trajectoryIdStartingAt(ids, frameNum) << endl; - cout << ids.size() << ": "; - BOOST_FOREACH(int i, ids) - cout << i << " "; - cout << endl; + vector trajectoryIds; + success = trajectoryDB->trajectoryIdStartingAt(trajectoryIds, frameNum); + cout << "frame " << frameNum << " " << success << endl; + cout << trajectoryIds.size() << " trajectories " << endl; + BOOST_FOREACH(int trajectoryId, trajectoryIds) { + //cout << trajectoryId << " " << endl; + boost::shared_ptr > trajectory; + success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities + stringstream ss;ss << *trajectory; cout << ss.str() << endl; + } // should the trajectory be loaded one by one? yes - } + } trajectoryDB->endTransaction(); trajectoryDB->disconnect(); } int main(int argc, char *argv[]) { - // BriefDescriptorExtractor brief(32); - // const int DESIRED_FTRS = 500; - // GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4); - KLTFeatureTrackingParameters params(argc, argv); cout << params.parameterDescription << endl;