comparison c/Motion.cpp @ 391:03dbecd3a887

modified feature grouping to return vectors of pointers to feature trajectories
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 25 Jul 2013 18:58:55 -0400
parents 21f14fadd098
children f43bc0b0ba74
comparison
equal deleted inserted replaced
389:6d26dcc7bba0 391:03dbecd3a887
199 if (lastInstants[i] < lastInstant) 199 if (lastInstants[i] < lastInstant)
200 objectHypotheses.push_back(tmpobjects[i]); 200 objectHypotheses.push_back(tmpobjects[i]);
201 } 201 }
202 } 202 }
203 203
204 vector<vector<unsigned int> > FeatureGraph::getFeatureGroups(void) { 204 void FeatureGraph::getFeatureGroups(vector<vector<FeatureTrajectoryPtr> >& featureGroups) {
205 vector<vector<unsigned int> > featureGroups; 205 featureGroups.clear();
206 206
207 for (unsigned int i=0; i<objectHypotheses.size(); ++i) { 207 for (unsigned int i=0; i<objectHypotheses.size(); ++i) {
208 // check that there is on average at least minNFeaturesPerGroup features at each frame in the group 208 // check that there is on average at least minNFeaturesPerGroup features at each frame in the group
209 unsigned int totalFeatureTime= graph[objectHypotheses[i][0]].feature->length(); 209 unsigned int totalFeatureTime= graph[objectHypotheses[i][0]].feature->length();
210 unsigned int firstInstant = graph[objectHypotheses[i][0]].feature->getFirstInstant(); 210 unsigned int firstInstant = graph[objectHypotheses[i][0]].feature->getFirstInstant();
216 } 216 }
217 if (static_cast<float>(totalFeatureTime)/static_cast<float>(lastInstant-firstInstant+1) > minNFeaturesPerGroup) { 217 if (static_cast<float>(totalFeatureTime)/static_cast<float>(lastInstant-firstInstant+1) > minNFeaturesPerGroup) {
218 #if DEBUG 218 #if DEBUG
219 cout << "save group " << i << " of " << objectHypotheses[i].size() << " features " << endl; 219 cout << "save group " << i << " of " << objectHypotheses[i].size() << " features " << endl;
220 #endif 220 #endif
221 featureGroups.push_back(vector<unsigned int>()); 221 featureGroups.push_back(vector<FeatureTrajectoryPtr>());
222 for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) { 222 for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) {
223 featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature->getId()); 223 featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature);
224 #if DEBUG 224 #if DEBUG
225 cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; 225 cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl;
226 #endif 226 #endif
227 clear_vertex(objectHypotheses[i][j], graph); 227 clear_vertex(objectHypotheses[i][j], graph);
228 remove_vertex(objectHypotheses[i][j], graph); 228 remove_vertex(objectHypotheses[i][j], graph);
229 } 229 }
230 } 230 }
231 } 231 }
232
233 return featureGroups;
234 } 232 }
235 233
236 string FeatureGraph::informationString(void) const { 234 string FeatureGraph::informationString(void) const {
237 stringstream ss; 235 stringstream ss;
238 ss << num_vertices(graph) << " vertices, " << num_edges(graph) << " edges"; 236 ss << num_vertices(graph) << " vertices, " << num_edges(graph) << " edges";