Mercurial Hosting > traffic-intelligence
comparison include/Motion.hpp @ 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 |
comparison
equal
deleted
inserted
replaced
178:d7df8ecf5ccd | 179:4f10e97cb677 |
---|---|
22 | 22 |
23 /** loads from database | 23 /** loads from database |
24 can be made generic for different list and blob */ | 24 can be made generic for different list and blob */ |
25 FeatureTrajectory(const int& id, TrajectoryDBAccessList<cv::Point2f>& trajectoryDB, const std::string& positionsTableName, const std::string& velocitiesTableName); | 25 FeatureTrajectory(const int& id, TrajectoryDBAccessList<cv::Point2f>& trajectoryDB, const std::string& positionsTableName, const std::string& velocitiesTableName); |
26 | 26 |
27 unsigned int length(void) const { return positions->size();} | 27 unsigned int length(void) const { return positions->size();} // cautious if not continuous: max-min+1 |
28 | 28 |
29 void setId(const unsigned int& id) { positions->setId(id);velocities->setId(id);} | 29 void setId(const unsigned int& id) { positions->setId(id);velocities->setId(id);} |
30 | 30 |
31 void setLost(void) { lost = true;} | 31 void setLost(void) { lost = true;} |
32 bool isLost(void) { return lost;} | 32 bool isLost(void) { return lost;} |
33 | |
34 unsigned int getFirstInstant(void) {return firstInstant;} | |
35 unsigned int getLastInstant(void) {return lastInstant;} | |
33 | 36 |
34 /// indicates whether the sum of the last nDisplacements displacements has been inferior to minFeatureDisplacement | 37 /// indicates whether the sum of the last nDisplacements displacements has been inferior to minFeatureDisplacement |
35 bool isDisplacementSmall(const unsigned int& nDisplacements, const float& minTotalFeatureDisplacement) const; | 38 bool isDisplacementSmall(const unsigned int& nDisplacements, const float& minTotalFeatureDisplacement) const; |
36 | 39 |
37 /// indicates whether the last two displacements are smooth (limited acceleration and angle) | 40 /// indicates whether the last two displacements are smooth (limited acceleration and angle) |
48 #endif | 51 #endif |
49 | 52 |
50 friend std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft); | 53 friend std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft); |
51 | 54 |
52 protected: | 55 protected: |
53 bool lost; | 56 bool lost; /// \todo remove |
57 /// first frame number | |
58 unsigned int firstInstant; | |
59 /// last frame number | |
60 unsigned int lastInstant; | |
61 | |
54 TrajectoryPoint2fPtr positions; | 62 TrajectoryPoint2fPtr positions; |
55 /** one fewer velocity than position | 63 /** one fewer velocity than position |
56 v_n = p_n+1 - p_n*/ | 64 v_n = p_n+1 - p_n*/ |
57 TrajectoryPoint2fPtr velocities; | 65 TrajectoryPoint2fPtr velocities; |
58 | 66 |
73 } | 81 } |
74 | 82 |
75 // class MovingObject {} | 83 // class MovingObject {} |
76 // roadUserType, group of features | 84 // roadUserType, group of features |
77 | 85 |
78 /// Class to group features | 86 /** Class to group features: Beymer et al. 99/Saunier and Sayed 06 |
87 \todo create various graph types with different parameters, that accept different feature distances or ways to connect and segment features */ | |
79 class FeatureGraph { | 88 class FeatureGraph { |
80 public: | 89 public: |
81 FeatureGraph(float _minDistance, float _maxDistance) : minDistance (_minDistance), maxDistance(_maxDistance) {} | 90 //FeatureGraph(float _minDistance, float _maxDistance) : minDistance (_minDistance), maxDistance(_maxDistance) {} |
91 FeatureGraph(float _connectionDistance, float _segmentationDistance) : connectionDistance (_connectionDistance), segmentationDistance(_segmentationDistance) {} | |
92 | |
93 void addFeature(const FeatureTrajectoryPtr& ft); | |
82 | 94 |
83 // add vertex, includes adding links to current vertices | 95 // add vertex, includes adding links to current vertices |
84 // find connected components, check if old enough, if so, remove | 96 // find connected components, check if old enough, if so, remove |
85 | 97 |
86 protected: | 98 protected: |
88 float minDistance; | 100 float minDistance; |
89 float maxDistance; | 101 float maxDistance; |
90 }; | 102 }; |
91 | 103 |
92 struct VertexInformation { | 104 struct VertexInformation { |
93 boost::shared_ptr<FeatureTrajectory> feature; | 105 FeatureTrajectoryPtr feature; |
94 }; | 106 }; |
95 | 107 |
96 typedef boost::adjacency_list <boost::listS, boost::listS, boost::undirectedS, VertexInformation, FeatureConnection> UndirectedGraph; | 108 typedef boost::adjacency_list <boost::listS, boost::listS, boost::undirectedS, VertexInformation, FeatureConnection> UndirectedGraph; |
97 | 109 |
98 float minDistance; | 110 float connectionDistance; |
99 float maxDistance; | 111 float segmentationDistance; |
112 // float minDistance; | |
113 // float maxDistance; | |
100 | 114 |
101 UndirectedGraph graph; | 115 UndirectedGraph graph; |
102 | 116 |
103 std::vector<UndirectedGraph::vertex_descriptor> currentVertices, lostVertices; | 117 //std::vector<UndirectedGraph::vertex_descriptor> currentVertices, lostVertices; |
104 }; | 118 }; |
105 | 119 |
106 // inlined implementations | 120 // inlined implementations |
107 // inline FeatureGraph::FeatureGraph(float _minDistance, float _maxDistance) | 121 // inline FeatureGraph::FeatureGraph(float _minDistance, float _maxDistance) |
108 | 122 |