Mercurial Hosting > traffic-intelligence
comparison c/Motion.cpp @ 230:bc4ea09b1743
compatibility modifications for visual studio compilation
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 29 Jun 2012 16:15:13 -0400 |
parents | f7ddfc4aeb1e |
children | 249d65ff6c35 |
comparison
equal
deleted
inserted
replaced
207:48f83ff769fd | 230:bc4ea09b1743 |
---|---|
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(); |
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 std::tr1::tie(e, unused) = add_edge(newVertex, *vi, graph); |
168 // no need to add measures to graph[e] (edge properties) | 168 // no need to add measures to graph[e] (edge properties) |
169 } | 169 } |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
177 property_map<UndirectedGraph, int VertexInformation::*>::type components = get(&VertexInformation::index, graph); | 177 property_map<UndirectedGraph, int VertexInformation::*>::type components = get(&VertexInformation::index, graph); |
178 | 178 |
179 int num = connected_components(graph, components, vertex_index_map(get(&VertexInformation::index, graph))); | 179 int num = connected_components(graph, components, vertex_index_map(get(&VertexInformation::index, graph))); |
180 cout << "last instant threshold " << lastInstant << " Total number of components: " << num << endl; | 180 cout << "last instant threshold " << lastInstant << " Total number of components: " << num << endl; |
181 | 181 |
182 vector<unsigned int> lastInstants(num, 0); // last instant of component with id | 182 std::vector<unsigned int> lastInstants(num, 0); // last instant of component with id |
183 vector<vector<vertex_descriptor> > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) | 183 std::vector<std::vector<vertex_descriptor> > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors) |
184 | 184 |
185 graph_traits<UndirectedGraph>::vertex_iterator vi, vend; | 185 graph_traits<UndirectedGraph>::vertex_iterator vi, vend; |
186 for(tie(vi,vend) = vertices(graph); vi != vend; ++vi) { | 186 for(std::tr1::tie(vi,vend) = vertices(graph); vi != vend; ++vi) { |
187 //for (int i = 0; i < nVertices; ++i) { | 187 //for (int i = 0; i < nVertices; ++i) { |
188 unsigned int id = components[*vi]; | 188 unsigned int id = components[*vi]; |
189 //cout << "Vertex " << *vi << " is in component " << id << endl;// "(last " << graph[i].feature->getLastInstant() << " " << lastInstants[components[i]] << " " << (lastInstants[components[i]] < graph[i].feature->getLastInstant()) << ")" << endl; | 189 //cout << "Vertex " << *vi << " is in component " << id << endl;// "(last " << graph[i].feature->getLastInstant() << " " << lastInstants[components[i]] << " " << (lastInstants[components[i]] < graph[i].feature->getLastInstant()) << ")" << endl; |
190 if (lastInstants[id] < graph[*vi].feature->getLastInstant()) | 190 if (lastInstants[id] < graph[*vi].feature->getLastInstant()) |
191 lastInstants[id] = graph[*vi].feature->getLastInstant(); | 191 lastInstants[id] = graph[*vi].feature->getLastInstant(); |
198 if (static_cast<int>(lastInstants[i]) < lastInstant) | 198 if (static_cast<int>(lastInstants[i]) < lastInstant) |
199 objectHypotheses.push_back(tmpobjects[i]); | 199 objectHypotheses.push_back(tmpobjects[i]); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 vector<vector<unsigned int> > FeatureGraph::getFeatureGroups(void) { | 203 std::vector<std::vector<unsigned int> > FeatureGraph::getFeatureGroups(void) { |
204 vector<vector<unsigned int> > featureGroups; | 204 std::vector<std::vector<unsigned int> > featureGroups; |
205 | 205 |
206 for (unsigned int i=0; i<objectHypotheses.size(); ++i) { | 206 for (unsigned int i=0; i<objectHypotheses.size(); ++i) { |
207 // check that there is on average at least minNFeaturesPerGroup features at each frame in the group | 207 // check that there is on average at least minNFeaturesPerGroup features at each frame in the group |
208 float totalFeatureTime=0; | 208 float totalFeatureTime=0; |
209 for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) | 209 for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) |
210 totalFeatureTime += static_cast<float>(graph[objectHypotheses[i][j]].feature->length()); | 210 totalFeatureTime += static_cast<float>(graph[objectHypotheses[i][j]].feature->length()); |
211 cout << i << endl; | 211 cout << i << endl; |
212 if (totalFeatureTime/static_cast<float>(objectHypotheses[i].size()) > minNFeaturesPerGroup) { | 212 if (totalFeatureTime/static_cast<float>(objectHypotheses[i].size()) > minNFeaturesPerGroup) { |
213 cout << "save group " << objectHypotheses[i].size() << " " << totalFeatureTime/static_cast<float>(objectHypotheses[i].size()) << endl; | 213 cout << "save group " << objectHypotheses[i].size() << " " << totalFeatureTime/static_cast<float>(objectHypotheses[i].size()) << endl; |
214 featureGroups.push_back(vector<unsigned int>()); | 214 featureGroups.push_back(std::vector<unsigned int>()); |
215 for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) { | 215 for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) { |
216 featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature->getId());cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; | 216 featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature->getId());cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; |
217 clear_vertex(objectHypotheses[i][j], graph);cout << "cleared "<< objectHypotheses[i][j] << endl; | 217 clear_vertex(objectHypotheses[i][j], graph);cout << "cleared "<< objectHypotheses[i][j] << endl; |
218 remove_vertex(objectHypotheses[i][j], graph);cout << "removed "<< objectHypotheses[i][j] << endl; | 218 remove_vertex(objectHypotheses[i][j], graph);cout << "removed "<< objectHypotheses[i][j] << endl; |
219 } | 219 } |
234 int FeatureGraph::getNEdges(void) const { return num_edges(graph);} | 234 int FeatureGraph::getNEdges(void) const { return num_edges(graph);} |
235 | 235 |
236 void FeatureGraph::computeVertexIndex(void) { | 236 void FeatureGraph::computeVertexIndex(void) { |
237 graph_traits<FeatureGraph::UndirectedGraph>::vertex_iterator vi, vend; | 237 graph_traits<FeatureGraph::UndirectedGraph>::vertex_iterator vi, vend; |
238 graph_traits<FeatureGraph::UndirectedGraph>::vertices_size_type cnt = 0; | 238 graph_traits<FeatureGraph::UndirectedGraph>::vertices_size_type cnt = 0; |
239 for(tie(vi,vend) = vertices(graph); vi != vend; ++vi) | 239 for(std::tr1::tie(vi,vend) = vertices(graph); vi != vend; ++vi) |
240 graph[*vi].index = cnt++; | 240 graph[*vi].index = cnt++; |
241 } | 241 } |