comparison c/Motion.cpp @ 225:d4d3b1e8a9f1

added code to process only needed frames based on saved features
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 26 Jun 2012 03:37:19 -0400
parents bc93e87a2108
children 249d65ff6c35
comparison
equal deleted inserted replaced
224:37a434fb848e 225:d4d3b1e8a9f1
99 if (frameNum < firstInstant) 99 if (frameNum < firstInstant)
100 firstInstant = frameNum; 100 firstInstant = frameNum;
101 if (frameNum > lastInstant) 101 if (frameNum > lastInstant)
102 lastInstant = frameNum; 102 lastInstant = frameNum;
103 computeMotionData(frameNum); 103 computeMotionData(frameNum);
104 assert(positions.size() == displacementDistances.size()+1); 104 assert(positions->size() == displacementDistances.size()+1);
105 assert(positions.size() == velocities.size()+1); 105 assert(positions->size() == velocities->size()+1);
106 } 106 }
107 107
108 void FeatureTrajectory::shorten(void) { 108 void FeatureTrajectory::shorten(void) {
109 positions->pop_back(); 109 positions->pop_back();
110 velocities->pop_back(); 110 velocities->pop_back();
156 graph[newVertex].feature = ft; 156 graph[newVertex].feature = ft;
157 for (graph_traits<UndirectedGraph>::vertex_iterator vi = vertices(graph).first; 157 for (graph_traits<UndirectedGraph>::vertex_iterator vi = vertices(graph).first;
158 vi!=vertices(graph).second; ++vi) { // vi pointer to vertex_descriptor 158 vi!=vertices(graph).second; ++vi) { // vi pointer to vertex_descriptor
159 FeatureTrajectoryPtr ft2 = graph[*vi].feature; 159 FeatureTrajectoryPtr ft2 = graph[*vi].feature;
160 if (newVertex != *vi) { 160 if (newVertex != *vi) {
161 int lastInstant = static_cast<int>(min(ft->getLastInstant(), ft2->getLastInstant())); 161 int lastInstant = static_cast<int>(MIN(ft->getLastInstant(), ft2->getLastInstant()));
162 int firstInstant = static_cast<int>(max(ft->getFirstInstant(), ft2->getFirstInstant())); 162 int firstInstant = static_cast<int>(MAX(ft->getFirstInstant(), ft2->getFirstInstant()));
163 if (lastInstant-firstInstant > static_cast<int>(minFeatureTime)) { // equivalent to lastInstant-firstInstant+1 >= minFeatureTime 163 if (lastInstant-firstInstant > static_cast<int>(minFeatureTime)) { // equivalent to lastInstant-firstInstant+1 >= minFeatureTime
164 if (ft->minMaxSimilarity(*ft2, firstInstant, lastInstant, connectionDistance, segmentationDistance)) { 164 if (ft->minMaxSimilarity(*ft2, firstInstant, lastInstant, connectionDistance, segmentationDistance)) {
165 UndirectedGraph::edge_descriptor e; 165 UndirectedGraph::edge_descriptor e;
166 bool unused; 166 bool unused;
167 tie(e, unused) = add_edge(newVertex, *vi, graph); 167 tie(e, unused) = add_edge(newVertex, *vi, graph);
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();
211 unsigned int lastInstant = graph[objectHypotheses[i][0]].feature->getLastInstant(); 211 unsigned int lastInstant = graph[objectHypotheses[i][0]].feature->getLastInstant();
212 for (unsigned int j=1; j<objectHypotheses[i].size(); ++j) { 212 for (unsigned int j=1; j<objectHypotheses[i].size(); ++j) {
213 totalFeatureTime += graph[objectHypotheses[i][j]].feature->length(); 213 totalFeatureTime += graph[objectHypotheses[i][j]].feature->length();
214 firstInstant = min(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant()); 214 firstInstant = MIN(firstInstant, graph[objectHypotheses[i][j]].feature->getFirstInstant());
215 lastInstant = max(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant()); 215 lastInstant = MAX(lastInstant, graph[objectHypotheses[i][j]].feature->getLastInstant());
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