Mercurial Hosting > traffic-intelligence
changeset 163:cde87a07eb58
added graph structures
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 27 Sep 2011 01:38:05 -0400 |
parents | 61fd5aff418c |
children | 76610dcf3b8d |
files | c/Motion.cpp c/feature-based-tracking.cpp include/Motion.hpp |
diffstat | 3 files changed, 41 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Motion.cpp Tue Sep 27 00:34:03 2011 -0400 +++ b/c/Motion.cpp Tue Sep 27 01:38:05 2011 -0400 @@ -9,7 +9,10 @@ using namespace std; using namespace cv; -FeatureTrajectory::FeatureTrajectory(const int& frameNum, const cv::Point2f& p, const Mat& homography) { +/******************** FeatureTrajectory ********************/ + +FeatureTrajectory::FeatureTrajectory(const int& frameNum, const cv::Point2f& p, const Mat& homography) + : lost(false) { addPoint(frameNum, p, homography); } @@ -95,3 +98,5 @@ displacementDistances.push_back(dist); } } + +/******************** FeatureGraph ********************/
--- a/c/feature-based-tracking.cpp Tue Sep 27 00:34:03 2011 -0400 +++ b/c/feature-based-tracking.cpp Tue Sep 27 01:38:05 2011 -0400 @@ -141,6 +141,8 @@ vector<FeatureTrajectoryPtr> lostFeatures; vector<FeaturePointMatch> featurePointMatches; + + FeatureGraph graph(params.mmConnectionDistance, params.mmSegmentationDistance); int key = '?'; unsigned int savedFeatureId=0;
--- a/include/Motion.hpp Tue Sep 27 00:34:03 2011 -0400 +++ b/include/Motion.hpp Tue Sep 27 01:38:05 2011 -0400 @@ -4,6 +4,7 @@ #include "src/Trajectory.h" #include <boost/shared_ptr.hpp> +#include <boost/graph/adjacency_list.hpp> template<typename T> class TrajectoryDBAccess; @@ -18,6 +19,9 @@ void setId(const unsigned int& id) { positions.setId(id);velocities.setId(id);} + void setLost(void) { lost = true;} + bool isLost(void) { return lost;} + /// indicates whether the sum of the last nDisplacements displacements has been inferior to minFeatureDisplacement bool smallDisplacement(const unsigned int& nDisplacements, const float& minTotalFeatureDisplacement) const; @@ -35,6 +39,7 @@ #endif protected: + bool lost; Trajectory<cv::Point2f> positions; /** one fewer velocity than position v_n = p_n+1 - p_n*/ @@ -52,4 +57,32 @@ // class MovingObject {} // roadUserType, group of features +/// Class to group features +class FeatureGraph { +public: + FeatureGraph(float _minDistance, float _maxDistance) : minDistance (_minDistance), maxDistance(_maxDistance) {} + +protected: + struct FeatureConnection { + float minDistance; + float maxDistance; + }; + + struct VertexInformation { + boost::shared_ptr<FeatureTrajectory> feature; + }; + + typedef boost::adjacency_list <boost::listS, boost::listS, boost::undirectedS, VertexInformation, FeatureConnection> UndirectedGraph; + + float minDistance; + float maxDistance; + + UndirectedGraph graph; + + std::vector<UndirectedGraph::vertex_descriptor> currentVertices, lostVertices; +}; + +// inlined implementations +// inline FeatureGraph::FeatureGraph(float _minDistance, float _maxDistance) + #endif