# HG changeset patch # User Nicolas Saunier # Date 1322785112 18000 # Node ID 1435965d8181dba27d91fe1ca7f3e2861d8822f4 # Parent aa1061fb969562e362b998051bc83e5a7108a8c0 work on connected components diff -r aa1061fb9695 -r 1435965d8181 c/Motion.cpp --- a/c/Motion.cpp Thu Dec 01 18:13:10 2011 -0500 +++ b/c/Motion.cpp Thu Dec 01 19:18:32 2011 -0500 @@ -1,10 +1,18 @@ #include "Motion.hpp" #include "cvutils.hpp" +#include "src/TrajectoryDBAccessList.h" + #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" -#include "src/TrajectoryDBAccessList.h" +#include +#include + +#include +#include +#include +#include using namespace std; using namespace cv; @@ -157,6 +165,18 @@ } } +void FeatureGraph::connectedComponents(const int& lastInstant) { + vector component(num_vertices(graph)); + // int num = connected_components(graph, &component[0]); + // todo change the type of the component map http://www.boost.org/doc/libs/1_48_0/libs/graph/doc/connected_components.html + + // cout << "Total number of components: " << num << endl; + + for (unsigned int i = 0; i < component.size(); ++i) + cout << "Vertex " << i <<" is in component " << component[i] << endl; + cout << endl; +} + string FeatureGraph::informationString(void) { stringstream ss; ss << num_vertices(graph) << " vertices, " << num_edges(graph) << " edges"; diff -r aa1061fb9695 -r 1435965d8181 c/feature-based-tracking.cpp --- a/c/feature-based-tracking.cpp Thu Dec 01 18:13:10 2011 -0500 +++ b/c/feature-based-tracking.cpp Thu Dec 01 19:18:32 2011 -0500 @@ -246,8 +246,8 @@ boost::shared_ptr > trajectoryDB = boost::shared_ptr >(new TrajectoryDBAccessList()); //TODO write generic methods for blob and list versions TrajectoryDBAccess* trajectoryDB = new TrajectoryDBAccessBlob(); bool success = trajectoryDB->connect(params.databaseFilename.c_str()); - vector > > trajectories; - cout << trajectories.size() << endl; + // vector > > trajectories; + // cout << trajectories.size() << endl; // std::clock_t c_start = std::clock(); // success = trajectoryDB->read(trajectories, "positions"); // TODO load velocities as well in a FeatureTrajectory object // attention, velocities lack the first instant // std::clock_t c_end = std::clock(); @@ -262,7 +262,6 @@ // cout << "Loaded " << trajectories.size() << " trajectories one by one in " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " CPU seconds" << endl; trajectoryDB->createViewInstants(); - //trajectoryDB->createViewInstants("last"); int maxTrajectoryLength; trajectoryDB->maxTrajectoryLength(maxTrajectoryLength); cout << "max trajectory length " << maxTrajectoryLength << endl; @@ -286,7 +285,10 @@ featureGraph.addFeature(ft); } - // should the trajectory be loaded one by one? yes + // check for connected components that are old enough (no chance to match with trajectories to be added later + if (frameNum%10 == 0) { + + } cout << featureGraph.informationString() << endl; } diff -r aa1061fb9695 -r 1435965d8181 include/Motion.hpp --- a/include/Motion.hpp Thu Dec 01 18:13:10 2011 -0500 +++ b/include/Motion.hpp Thu Dec 01 19:18:32 2011 -0500 @@ -101,6 +101,9 @@ // add vertex, includes adding links to current vertices // find connected components, check if old enough, if so, remove + /// Computes the connected components: features have to be older than lastInstant + void connectedComponents(const int& lastInstant); + std::string informationString(void); protected: