Mercurial Hosting > traffic-intelligence
changeset 392:dd4970f4221f
merged
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 25 Jul 2013 18:59:35 -0400 |
parents | 12be4a0cb9aa (current diff) 03dbecd3a887 (diff) |
children | eaf7765221d9 |
files | |
diffstat | 5 files changed, 22 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Motion.cpp Thu Jul 25 18:55:44 2013 -0400 +++ b/c/Motion.cpp Thu Jul 25 18:59:35 2013 -0400 @@ -201,8 +201,8 @@ } } -vector<vector<unsigned int> > FeatureGraph::getFeatureGroups(void) { - vector<vector<unsigned int> > featureGroups; +void FeatureGraph::getFeatureGroups(vector<vector<FeatureTrajectoryPtr> >& featureGroups) { + featureGroups.clear(); for (unsigned int i=0; i<objectHypotheses.size(); ++i) { // check that there is on average at least minNFeaturesPerGroup features at each frame in the group @@ -218,9 +218,9 @@ #if DEBUG cout << "save group " << i << " of " << objectHypotheses[i].size() << " features " << endl; #endif - featureGroups.push_back(vector<unsigned int>()); + featureGroups.push_back(vector<FeatureTrajectoryPtr>()); for (unsigned int j=0; j<objectHypotheses[i].size(); ++j) { - featureGroups.back().push_back(graph[objectHypotheses[i][j]].feature->getId()); + 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 {
--- a/c/feature-based-tracking.cpp Thu Jul 25 18:55:44 2013 -0400 +++ b/c/feature-based-tracking.cpp Thu Jul 25 18:59:35 2013 -0400 @@ -314,9 +314,13 @@ int lastInstant = frameNum+params.minFeatureTime-maxTrajectoryLength; if (lastInstant > 0 && frameNum%10==0) { featureGraph.connectedComponents(lastInstant); - vector<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); + vector<vector<FeatureTrajectoryPtr> > featureGroups; + featureGraph.getFeatureGroups(featureGroups); for (unsigned int i=0; i<featureGroups.size(); ++i) { - trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); + vector<unsigned int> featureNumbers; + for (unsigned int j=0; j<featureGroups[i].size(); ++j) + featureNumbers.push_back(featureGroups[i][j]->getId()); + 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<vector<unsigned int> > featureGroups = featureGraph.getFeatureGroups(); + vector<vector<FeatureTrajectoryPtr> > featureGroups; + featureGraph.getFeatureGroups(featureGroups); for (unsigned int i=0; i<featureGroups.size(); ++i) { - trajectoryDB->writeObject(savedObjectId, featureGroups[i], -1, 1, string("objects"), string("objects_features")); + vector<unsigned int> featureNumbers; + for (unsigned int j=0; j<featureGroups[i].size(); ++j) + featureNumbers.push_back(featureGroups[i][j]->getId()); + trajectoryDB->writeObject(savedObjectId, featureNumbers, -1, 1, string("objects"), string("objects_features")); savedObjectId++; }
--- a/c/test_graph.cpp Thu Jul 25 18:55:44 2013 -0400 +++ b/c/test_graph.cpp Thu Jul 25 18:59:35 2013 -0400 @@ -29,13 +29,14 @@ REQUIRE(featureGraph.getNEdges() == 1); featureGraph.connectedComponents(lastInstant); - vector<vector<unsigned int> > components = featureGraph.getFeatureGroups(); + vector<vector<FeatureTrajectoryPtr> > 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);
--- a/include/Motion.hpp Thu Jul 25 18:55:44 2013 -0400 +++ b/include/Motion.hpp Thu Jul 25 18:59:35 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<std::vector<unsigned int> > getFeatureGroups(void); + void getFeatureGroups(std::vector<std::vector<FeatureTrajectoryPtr> >& featureGroups); std::string informationString(void) const;
--- a/python/utils.py Thu Jul 25 18:55:44 2013 -0400 +++ b/python/utils.py Thu Jul 25 18:59:35 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)