Mercurial > hg > nsaunier > traffic-intelligence
comparison include/Motion.hpp @ 163:cde87a07eb58
added graph structures
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 27 Sep 2011 01:38:05 -0400 |
| parents | 0089fb29cd26 |
| children | 50964af05a80 |
comparison
equal
deleted
inserted
replaced
| 162:61fd5aff418c | 163:cde87a07eb58 |
|---|---|
| 2 #define FEATURE_HPP | 2 #define FEATURE_HPP |
| 3 | 3 |
| 4 #include "src/Trajectory.h" | 4 #include "src/Trajectory.h" |
| 5 | 5 |
| 6 #include <boost/shared_ptr.hpp> | 6 #include <boost/shared_ptr.hpp> |
| 7 #include <boost/graph/adjacency_list.hpp> | |
| 7 | 8 |
| 8 template<typename T> class TrajectoryDBAccess; | 9 template<typename T> class TrajectoryDBAccess; |
| 9 | 10 |
| 10 /** Class for feature data | 11 /** Class for feature data |
| 11 positions, velocities and other statistics to evaluate their quality | 12 positions, velocities and other statistics to evaluate their quality |
| 15 FeatureTrajectory(const int& frameNum, const cv::Point2f& p, const cv::Mat& homography); | 16 FeatureTrajectory(const int& frameNum, const cv::Point2f& p, const cv::Mat& homography); |
| 16 | 17 |
| 17 unsigned int length(void) const { return positions.size();} | 18 unsigned int length(void) const { return positions.size();} |
| 18 | 19 |
| 19 void setId(const unsigned int& id) { positions.setId(id);velocities.setId(id);} | 20 void setId(const unsigned int& id) { positions.setId(id);velocities.setId(id);} |
| 21 | |
| 22 void setLost(void) { lost = true;} | |
| 23 bool isLost(void) { return lost;} | |
| 20 | 24 |
| 21 /// indicates whether the sum of the last nDisplacements displacements has been inferior to minFeatureDisplacement | 25 /// indicates whether the sum of the last nDisplacements displacements has been inferior to minFeatureDisplacement |
| 22 bool smallDisplacement(const unsigned int& nDisplacements, const float& minTotalFeatureDisplacement) const; | 26 bool smallDisplacement(const unsigned int& nDisplacements, const float& minTotalFeatureDisplacement) const; |
| 23 | 27 |
| 24 /// indicates whether the last two displacements are smooth (limited acceleration and angle) | 28 /// indicates whether the last two displacements are smooth (limited acceleration and angle) |
| 33 #ifdef USE_OPENCV | 37 #ifdef USE_OPENCV |
| 34 void draw(cv::Mat& img, const cv::Mat& homography, const cv::Scalar& color) const; | 38 void draw(cv::Mat& img, const cv::Mat& homography, const cv::Scalar& color) const; |
| 35 #endif | 39 #endif |
| 36 | 40 |
| 37 protected: | 41 protected: |
| 42 bool lost; | |
| 38 Trajectory<cv::Point2f> positions; | 43 Trajectory<cv::Point2f> positions; |
| 39 /** one fewer velocity than position | 44 /** one fewer velocity than position |
| 40 v_n = p_n+1 - p_n*/ | 45 v_n = p_n+1 - p_n*/ |
| 41 Trajectory<cv::Point2f> velocities; | 46 Trajectory<cv::Point2f> velocities; |
| 42 | 47 |
| 50 typedef boost::shared_ptr<FeatureTrajectory> FeatureTrajectoryPtr; | 55 typedef boost::shared_ptr<FeatureTrajectory> FeatureTrajectoryPtr; |
| 51 | 56 |
| 52 // class MovingObject {} | 57 // class MovingObject {} |
| 53 // roadUserType, group of features | 58 // roadUserType, group of features |
| 54 | 59 |
| 60 /// Class to group features | |
| 61 class FeatureGraph { | |
| 62 public: | |
| 63 FeatureGraph(float _minDistance, float _maxDistance) : minDistance (_minDistance), maxDistance(_maxDistance) {} | |
| 64 | |
| 65 protected: | |
| 66 struct FeatureConnection { | |
| 67 float minDistance; | |
| 68 float maxDistance; | |
| 69 }; | |
| 70 | |
| 71 struct VertexInformation { | |
| 72 boost::shared_ptr<FeatureTrajectory> feature; | |
| 73 }; | |
| 74 | |
| 75 typedef boost::adjacency_list <boost::listS, boost::listS, boost::undirectedS, VertexInformation, FeatureConnection> UndirectedGraph; | |
| 76 | |
| 77 float minDistance; | |
| 78 float maxDistance; | |
| 79 | |
| 80 UndirectedGraph graph; | |
| 81 | |
| 82 std::vector<UndirectedGraph::vertex_descriptor> currentVertices, lostVertices; | |
| 83 }; | |
| 84 | |
| 85 // inlined implementations | |
| 86 // inline FeatureGraph::FeatureGraph(float _minDistance, float _maxDistance) | |
| 87 | |
| 55 #endif | 88 #endif |
