Mercurial Hosting > traffic-intelligence
changeset 222:426321b46e44
temporary trajectory instants table
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 26 Jun 2012 02:08:01 -0400 |
parents | bc93e87a2108 |
children | c31722fcc9de |
files | c/feature-based-tracking.cpp |
diffstat | 1 files changed, 22 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/c/feature-based-tracking.cpp Mon Jun 25 23:50:18 2012 -0400 +++ b/c/feature-based-tracking.cpp Tue Jun 26 02:08:01 2012 -0400 @@ -271,22 +271,31 @@ // 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(); + trajectoryDB->createViewInstants("table"); - // unsigned int maxTrajectoryLength; - // // trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); + unsigned int maxTrajectoryLength; + trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); + cout << "Longest trajectory: " << maxTrajectoryLength << endl; // 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 - int queryIntervalLength = 100; + int queryIntervalLength = 10; FeatureGraph featureGraph(params.mmConnectionDistance, params.mmSegmentationDistance, params.minFeatureTime, params.minNFeaturesPerGroup); // main loop - 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 + 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 vector<int> trajectoryIds; success = trajectoryDB->trajectoryIdEndingAt(trajectoryIds, frameNum); // ending - cout << "frame " << frameNum << " " << success << endl; + cout << "frame " << frameNum << endl; + //success = trajectoryDB->trajectoryIdInInterval(trajectoryIds, frameNum, min(frameNum+queryIntervalLength-1, frameNum+params.nFrames)); // ending +#if DEBUG cout << trajectoryIds.size() << " trajectories " << endl; +#endif + // vector<TrajectoryPoint2fPtr> positions, velocities; + // trajectoryDB->read(positions, trajectoryIds, "positions"); + // trajectoryDB->read(velocities, trajectoryIds, "velocities"); + // for (unsigned int i=0; i<trajectoryIds.size(); ++i) { + // FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(positions[i], velocities[i])); BOOST_FOREACH(int trajectoryId, trajectoryIds) { //cout << trajectoryId << " " << endl; // boost::shared_ptr<Trajectory<cv::Point2f> > trajectory; @@ -297,17 +306,14 @@ featureGraph.addFeature(ft); } - // check for connected components that are old enough (no chance to match with trajectories to be added later - // we could check only when some features are getting old enough? - if (frameNum%10 == 0) { - featureGraph.connectedComponents(frameNum+params.minFeatureTime); - vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); - for (unsigned int i=0; i<featureGroups.size(); ++i) { - trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); - savedObjectId++; - } + // check for connected components + featureGraph.connectedComponents(frameNum+params.minFeatureTime); + vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); + for (unsigned int i=0; i<featureGroups.size(); ++i) { + trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); + savedObjectId++; } - + cout << featureGraph.informationString() << endl; }