# HG changeset patch # User Nicolas Saunier # Date 1323732730 18000 # Node ID 09c7881073f3a5be90282ccaeec21871b735a013 # Parent a728fce85881131506e077ad51300ad2ecc02097 connected commponents works, but issue with removing the vertices diff -r a728fce85881 -r 09c7881073f3 c/Motion.cpp --- a/c/Motion.cpp Mon Dec 12 15:44:54 2011 -0500 +++ b/c/Motion.cpp Mon Dec 12 18:32:10 2011 -0500 @@ -7,7 +7,6 @@ #include "opencv2/highgui/highgui.hpp" #include -#include #include #include @@ -167,7 +166,7 @@ } } -vector > FeatureGraph::connectedComponents(const int& lastInstant) { +void FeatureGraph::connectedComponents(const int& lastInstant) { computeVertexIndex(); property_map::type components = get(&VertexInformation::index, graph); @@ -181,37 +180,38 @@ for(tie(vi,vend) = vertices(graph); vi != vend; ++vi) { //for (int i = 0; i < nVertices; ++i) { unsigned int id = components[*vi]; - cout << "Vertex " << *vi << " is in component " << id << endl;// "(last " << graph[i].feature->getLastInstant() << " " << lastInstants[components[i]] << " " << (lastInstants[components[i]] < graph[i].feature->getLastInstant()) << ")" << endl; + //cout << "Vertex " << *vi << " is in component " << id << endl;// "(last " << graph[i].feature->getLastInstant() << " " << lastInstants[components[i]] << " " << (lastInstants[components[i]] < graph[i].feature->getLastInstant()) << ")" << endl; if (lastInstants[id] < graph[*vi].feature->getLastInstant()) lastInstants[id] = graph[*vi].feature->getLastInstant(); tmpobjects[id].push_back(*vi); } + objectHypotheses.clear(); for (int i = 0; i < num; ++i) { cout << i << " " << lastInstants[i] << endl; if (static_cast(lastInstants[i]) < lastInstant) - objects.push_back(tmpobjects[i]); + objectHypotheses.push_back(tmpobjects[i]); } - - return objects; } -vector > FeatureGraph::getFeatureGroups(const vector >& objectHypotheses) { +vector > FeatureGraph::getFeatureGroups(void) { vector > featureGroups; for (unsigned int i=0; i(graph[objectHypotheses[i][j]].feature->length()); - - if (totalFeatureTime/static_cast(objectHypotheses.size()) > minNFeaturesPerGroup) { - cout << "save group" << endl; + cout << i << endl; + if (totalFeatureTime/static_cast(objectHypotheses[i].size()) > minNFeaturesPerGroup) { + cout << "save group " << objectHypotheses[i].size() << " " << totalFeatureTime/static_cast(objectHypotheses[i].size()) << endl; featureGroups.push_back(vector()); - for (unsigned int j=0; jgetId()); + for (unsigned int j=0; jgetId());cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; + clear_vertex(objectHypotheses[i][j], graph);cout << "cleared "<< objectHypotheses[i][j] << endl; + remove_vertex(objectHypotheses[i][j], graph);cout << "removed "<< objectHypotheses[i][j] << endl; + } } - // remove vertices: todo using listS } return featureGroups; diff -r a728fce85881 -r 09c7881073f3 c/feature-based-tracking.cpp --- a/c/feature-based-tracking.cpp Mon Dec 12 15:44:54 2011 -0500 +++ b/c/feature-based-tracking.cpp Mon Dec 12 18:32:10 2011 -0500 @@ -298,12 +298,8 @@ // check for connected components that are old enough (no chance to match with trajectories to be added later // we could check only when some features are getting old enough? if (frameNum%10 == 0) { - vector > objects = featureGraph.connectedComponents(frameNum-maxTrajectoryLength+params.minFeatureTime); - cout << objects.size() << " objects" << endl; - - if (!objects.empty()) { - vector > featureGroups = featureGraph.getFeatureGroups(objects); - } + featureGraph.connectedComponents(frameNum-maxTrajectoryLength+params.minFeatureTime); + vector > featureGroups = featureGraph.getFeatureGroups(); } cout << featureGraph.informationString() << endl; diff -r a728fce85881 -r 09c7881073f3 include/Motion.hpp --- a/include/Motion.hpp Mon Dec 12 15:44:54 2011 -0500 +++ b/include/Motion.hpp Mon Dec 12 18:32:10 2011 -0500 @@ -117,12 +117,12 @@ // find connected components, check if old enough, if so, remove /// Computes the connected components: features have to be older than lastInstant - std::vector > connectedComponents(const int& lastInstant); + void connectedComponents(const int& lastInstant); /** Performs some checks on groups of features and return their lists of ids if correct Removes the vertices from the graph */ - std::vector > getFeatureGroups(const std::vector >& objectHypotheses); + std::vector > getFeatureGroups(void); std::string informationString(void); @@ -136,6 +136,8 @@ UndirectedGraph graph; + std::vector > objectHypotheses; + void computeVertexIndex(void); //std::vector currentVertices, lostVertices;