Mercurial Hosting > traffic-intelligence
changeset 179:4f10e97cb677
added getting first and last instant for each feature
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 31 Oct 2011 19:17:42 -0400 |
parents | d7df8ecf5ccd |
children | 3a4eef37384f |
files | c/Motion.cpp c/feature-based-tracking.cpp include/Motion.hpp |
diffstat | 3 files changed, 28 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Motion.cpp Mon Oct 31 00:35:34 2011 -0400 +++ b/c/Motion.cpp Mon Oct 31 19:17:42 2011 -0400 @@ -31,6 +31,8 @@ success = trajectoryDB.read(velocities, id, velocitiesTableName); if (!success) cout << "problem loading velocities" << endl; + // take advantage to request first and last instant from database + trajectoryDB.timeInterval(firstInstant, lastInstant, id); } bool FeatureTrajectory::isDisplacementSmall(const unsigned int& nDisplacements, const float& minTotalFeatureDisplacement) const { @@ -117,3 +119,4 @@ } /******************** FeatureGraph ********************/ +
--- a/c/feature-based-tracking.cpp Mon Oct 31 00:35:34 2011 -0400 +++ b/c/feature-based-tracking.cpp Mon Oct 31 19:17:42 2011 -0400 @@ -273,7 +273,7 @@ // TODO version que l'on peut interrompre ? for (int frameNum = params.frame1; ((frameNum-params.frame1 < params.nFrames) || (params.nFrames < 0)); frameNum++) { vector<int> trajectoryIds; - success = trajectoryDB->trajectoryIdStartingAt(trajectoryIds, frameNum); + success = trajectoryDB->trajectoryIdStartingAt(trajectoryIds, frameNum); // ending cout << "frame " << frameNum << " " << success << endl; cout << trajectoryIds.size() << " trajectories " << endl; BOOST_FOREACH(int trajectoryId, trajectoryIds) { @@ -281,7 +281,8 @@ // boost::shared_ptr<Trajectory<cv::Point2f> > trajectory; // success = trajectoryDB->read(trajectory, trajectoryId, "positions"); // velocities FeatureTrajectoryPtr ft = FeatureTrajectoryPtr(new FeatureTrajectory(trajectoryId, *trajectoryDB, "positions", "velocities")); - //stringstream ss;ss << *ft; cout << ss.str() << endl; + stringstream ss;ss << *ft; cout << ss.str() << endl; + cout << ft->getFirstInstant() << " " << ft->getLastInstant() << endl; } // should the trajectory be loaded one by one? yes
--- a/include/Motion.hpp Mon Oct 31 00:35:34 2011 -0400 +++ b/include/Motion.hpp Mon Oct 31 19:17:42 2011 -0400 @@ -24,13 +24,16 @@ can be made generic for different list and blob */ FeatureTrajectory(const int& id, TrajectoryDBAccessList<cv::Point2f>& trajectoryDB, const std::string& positionsTableName, const std::string& velocitiesTableName); - unsigned int length(void) const { return positions->size();} + unsigned int length(void) const { return positions->size();} // cautious if not continuous: max-min+1 void setId(const unsigned int& id) { positions->setId(id);velocities->setId(id);} void setLost(void) { lost = true;} bool isLost(void) { return lost;} + unsigned int getFirstInstant(void) {return firstInstant;} + unsigned int getLastInstant(void) {return lastInstant;} + /// indicates whether the sum of the last nDisplacements displacements has been inferior to minFeatureDisplacement bool isDisplacementSmall(const unsigned int& nDisplacements, const float& minTotalFeatureDisplacement) const; @@ -50,7 +53,12 @@ friend std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft); protected: - bool lost; + bool lost; /// \todo remove + /// first frame number + unsigned int firstInstant; + /// last frame number + unsigned int lastInstant; + TrajectoryPoint2fPtr positions; /** one fewer velocity than position v_n = p_n+1 - p_n*/ @@ -75,10 +83,14 @@ // class MovingObject {} // roadUserType, group of features -/// Class to group features +/** Class to group features: Beymer et al. 99/Saunier and Sayed 06 + \todo create various graph types with different parameters, that accept different feature distances or ways to connect and segment features */ class FeatureGraph { public: - FeatureGraph(float _minDistance, float _maxDistance) : minDistance (_minDistance), maxDistance(_maxDistance) {} + //FeatureGraph(float _minDistance, float _maxDistance) : minDistance (_minDistance), maxDistance(_maxDistance) {} + FeatureGraph(float _connectionDistance, float _segmentationDistance) : connectionDistance (_connectionDistance), segmentationDistance(_segmentationDistance) {} + + void addFeature(const FeatureTrajectoryPtr& ft); // add vertex, includes adding links to current vertices // find connected components, check if old enough, if so, remove @@ -90,17 +102,19 @@ }; struct VertexInformation { - boost::shared_ptr<FeatureTrajectory> feature; + FeatureTrajectoryPtr feature; }; typedef boost::adjacency_list <boost::listS, boost::listS, boost::undirectedS, VertexInformation, FeatureConnection> UndirectedGraph; - float minDistance; - float maxDistance; + float connectionDistance; + float segmentationDistance; + // float minDistance; + // float maxDistance; UndirectedGraph graph; - std::vector<UndirectedGraph::vertex_descriptor> currentVertices, lostVertices; + //std::vector<UndirectedGraph::vertex_descriptor> currentVertices, lostVertices; }; // inlined implementations