Mercurial Hosting > traffic-intelligence
diff c/Motion.cpp @ 716:85af65b6d531 dev
corrected major bug slowing feature grouping
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sat, 25 Jul 2015 23:28:52 -0400 |
parents | 045d05cef9d0 |
children | 6022350f8173 |
line wrap: on
line diff
--- 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<unsigned int> lastInstants(num, 0); // last instant of component with id - vector<vector<vertex_descriptor> > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) + vector<vector<vertex_descriptor> > tmpobjects(num); // vector of components (component = vector of vertex descriptors) graph_traits<UndirectedGraph>::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; j<objectHypotheses[i].size(); ++j) { - totalFeatureTime += graph[objectHypotheses[i][j]].feature->length(); - firstInstant = MIN(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant()); - lastInstant = MAX(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant()); - } - if (static_cast<float>(totalFeatureTime)/static_cast<float>(lastInstant-firstInstant+1) > minNFeaturesPerGroup) { + for (unsigned int j=1; j<objectHypotheses[i].size(); ++j) { + totalFeatureTime += graph[objectHypotheses[i][j]].feature->length(); + firstInstant = MIN(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant()); + lastInstant = MAX(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant()); + } + bool saveFeatureGroup = (static_cast<float>(totalFeatureTime)/static_cast<float>(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<FeatureTrajectoryPtr>()); - for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) { + for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) { + if (saveFeatureGroup) featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature); #if DEBUG - cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; + cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; #endif - clear_vertex(objectHypotheses[i][j], graph); - remove_vertex(objectHypotheses[i][j], graph); - } + clear_vertex(objectHypotheses[i][j], graph); + remove_vertex(objectHypotheses[i][j], graph); } } }