# HG changeset patch # User Nicolas Saunier # Date 1437881332 14400 # Node ID 85af65b6d5317852b4b243857330f66d601c86d7 # Parent a05f79c74d6d9c33282061f80176510182532906 corrected major bug slowing feature grouping diff -r a05f79c74d6d -r 85af65b6d531 c/Motion.cpp --- a/c/Motion.cpp Sat Jul 25 22:36:39 2015 -0400 +++ b/c/Motion.cpp Sat Jul 25 23:28:52 2015 -0400 @@ -188,7 +188,7 @@ #endif vector lastInstants(num, 0); // last instant of component with id - vector > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) + vector > tmpobjects(num); // vector of components (component = vector of vertex descriptors) graph_traits::vertex_iterator vi, vend; for(boost::tuples::tie(vi,vend) = vertices(graph); vi != vend; ++vi) { @@ -215,24 +215,25 @@ unsigned int totalFeatureTime= graph[objectHypotheses[i][0]].feature->length(); unsigned int firstInstant = graph[objectHypotheses[i][0]].feature->getFirstInstant(); unsigned int lastInstant = graph[objectHypotheses[i][0]].feature->getLastInstant(); - for (unsigned int j=1; jlength(); - firstInstant = MIN(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant()); - lastInstant = MAX(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant()); - } - if (static_cast(totalFeatureTime)/static_cast(lastInstant-firstInstant+1) > minNFeaturesPerGroup) { + for (unsigned int j=1; jlength(); + firstInstant = MIN(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant()); + lastInstant = MAX(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant()); + } + bool saveFeatureGroup = (static_cast(totalFeatureTime)/static_cast(lastInstant-firstInstant+1) > minNFeaturesPerGroup); #if DEBUG - cout << "save group " << i << " of " << objectHypotheses[i].size() << " features " << endl; + cout << "save group " << i << " of " << objectHypotheses[i].size() << " features " << endl; #endif + if (saveFeatureGroup) featureGroups.push_back(vector()); - for (unsigned int j=0; jtrajectoryIdEndingAt(trajectoryIds, frameNum); if (frameNum%100 ==0) 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 positions, velocities; - // trajectoryDB->read(positions, trajectoryIds, "positions"); - // trajectoryDB->read(velocities, trajectoryIds, "velocities"); - // for (unsigned int i=0; i > trajectory; - // success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities")); - // stringstream ss;ss << *ft; cout << ss.str() << endl; - // cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl; featureGraph.addFeature(ft); } @@ -326,7 +315,7 @@ vector featureNumbers; for (unsigned int j=0; jgetId()); - trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown */, 1, string("objects"), string("objects_features")); + trajectoryDB->writeObject(savedObjectId, featureNumbers, 0 /* unknown type */, 1, string("objects"), string("objects_features")); savedObjectId++; } }