# HG changeset patch # User Nicolas Saunier # Date 1374793135 14400 # Node ID 03dbecd3a887feacfe2d8e1e2e0b978e18f84d04 # Parent 6d26dcc7bba05236c0aa14da6779e968c4abac08 modified feature grouping to return vectors of pointers to feature trajectories diff -r 6d26dcc7bba0 -r 03dbecd3a887 c/Motion.cpp --- a/c/Motion.cpp Thu Jul 25 16:01:12 2013 -0400 +++ b/c/Motion.cpp Thu Jul 25 18:58:55 2013 -0400 @@ -201,8 +201,8 @@ } } -vector > FeatureGraph::getFeatureGroups(void) { - vector > featureGroups; +void FeatureGraph::getFeatureGroups(vector >& featureGroups) { + featureGroups.clear(); for (unsigned int i=0; i()); + featureGroups.push_back(vector()); for (unsigned int j=0; jgetId()); + featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature); #if DEBUG cout << featureGroups.size() << " " << objectHypotheses[i][j] << endl; #endif @@ -229,8 +229,6 @@ } } } - - return featureGroups; } string FeatureGraph::informationString(void) const { diff -r 6d26dcc7bba0 -r 03dbecd3a887 c/feature-based-tracking.cpp --- a/c/feature-based-tracking.cpp Thu Jul 25 16:01:12 2013 -0400 +++ b/c/feature-based-tracking.cpp Thu Jul 25 18:58:55 2013 -0400 @@ -314,9 +314,13 @@ int lastInstant = frameNum+params.minFeatureTime-maxTrajectoryLength; if (lastInstant > 0 && frameNum%10==0) { featureGraph.connectedComponents(lastInstant); - vector > featureGroups = featureGraph.getFeatureGroups(); + vector > featureGroups; + featureGraph.getFeatureGroups(featureGroups); for (unsigned int i=0; iwriteObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); + vector featureNumbers; + for (unsigned int j=0; jgetId()); + trajectoryDB->writeObject(savedObjectId, featureNumbers, -1, 1, string("objects"), string("objects_features")); savedObjectId++; } } @@ -327,9 +331,13 @@ // save remaining objects featureGraph.connectedComponents(frameNum+maxTrajectoryLength+1); - vector > featureGroups = featureGraph.getFeatureGroups(); + vector > featureGroups; + featureGraph.getFeatureGroups(featureGroups); for (unsigned int i=0; iwriteObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); + vector featureNumbers; + for (unsigned int j=0; jgetId()); + trajectoryDB->writeObject(savedObjectId, featureNumbers, -1, 1, string("objects"), string("objects_features")); savedObjectId++; } diff -r 6d26dcc7bba0 -r 03dbecd3a887 c/test_graph.cpp --- a/c/test_graph.cpp Thu Jul 25 16:01:12 2013 -0400 +++ b/c/test_graph.cpp Thu Jul 25 18:58:55 2013 -0400 @@ -29,13 +29,14 @@ REQUIRE(featureGraph.getNEdges() == 1); featureGraph.connectedComponents(lastInstant); - vector > components = featureGraph.getFeatureGroups(); + vector > components; + featureGraph.getFeatureGroups(components); REQUIRE(components.size() == 0); REQUIRE(featureGraph.getNVertices() == 2); REQUIRE(featureGraph.getNEdges() == 1); featureGraph.connectedComponents(lastInstant+1); - components = featureGraph.getFeatureGroups(); + featureGraph.getFeatureGroups(components); REQUIRE(components.size() == 1); REQUIRE(components[0].size() == 2); REQUIRE(featureGraph.getNVertices() == 0); @@ -60,7 +61,7 @@ REQUIRE(featureGraph.getNEdges() == 2); featureGraph.connectedComponents(lastInstant+1); - components = featureGraph.getFeatureGroups(); + featureGraph.getFeatureGroups(components); REQUIRE(components.size() == 2); REQUIRE(components[0].size() == 3); REQUIRE(components[1].size() == 1); diff -r 6d26dcc7bba0 -r 03dbecd3a887 include/Motion.hpp --- a/include/Motion.hpp Thu Jul 25 16:01:12 2013 -0400 +++ b/include/Motion.hpp Thu Jul 25 18:58:55 2013 -0400 @@ -116,7 +116,7 @@ /** Performs some checks on groups of features and return their lists of ids if correct Removes the vertices from the graph */ - std::vector > getFeatureGroups(void); + void getFeatureGroups(std::vector >& featureGroups); std::string informationString(void) const; diff -r 6d26dcc7bba0 -r 03dbecd3a887 python/utils.py --- a/python/utils.py Thu Jul 25 16:01:12 2013 -0400 +++ b/python/utils.py Thu Jul 25 18:58:55 2013 -0400 @@ -542,7 +542,7 @@ try: cursor = connection.cursor() for tableName in tableNames: - cursor.execute('DROP TABLE '+tableName) + cursor.execute('DROP TABLE IF EXISTS '+tableName) except sqlite3.OperationalError as error: printDBError(error)