Mercurial Hosting > traffic-intelligence
comparison include/Motion.hpp @ 614:5e09583275a4
Merged Nicolas/trafficintelligence into default
author | Mohamed Gomaa <eng.m.gom3a@gmail.com> |
---|---|
date | Fri, 05 Dec 2014 12:13:53 -0500 |
parents | b6ad86ee7033 |
children | 045d05cef9d0 |
comparison
equal
deleted
inserted
replaced
598:11f96bd08552 | 614:5e09583275a4 |
---|---|
2 #define MOTION_HPP | 2 #define MOTION_HPP |
3 | 3 |
4 #include "src/Trajectory.h" | 4 #include "src/Trajectory.h" |
5 #include <boost/shared_ptr.hpp> | 5 #include <boost/shared_ptr.hpp> |
6 #include <boost/graph/adjacency_list.hpp> | 6 #include <boost/graph/adjacency_list.hpp> |
7 | |
7 | 8 |
8 template<typename T> class TrajectoryDBAccess; | 9 template<typename T> class TrajectoryDBAccess; |
9 template<typename T> class TrajectoryDBAccessList; | 10 template<typename T> class TrajectoryDBAccessList; |
10 | 11 |
11 typedef boost::shared_ptr<TrajectoryPoint2f> TrajectoryPoint2fPtr; | 12 typedef boost::shared_ptr<TrajectoryPoint2f> TrajectoryPoint2fPtr; |
12 | 13 |
13 /** Class for feature data | 14 /** Class for feature data |
14 positions, velocities and other statistics to evaluate their quality | 15 positions, velocities and other statistics to evaluate their quality |
15 before saving. */ | 16 before saving. */ |
16 class FeatureTrajectory { | 17 class FeatureTrajectory |
18 { | |
17 public: | 19 public: |
18 FeatureTrajectory(const unsigned int& frameNum, const cv::Point2f& p, const cv::Mat& homography); | 20 FeatureTrajectory(const unsigned int& frameNum, const cv::Point2f& p, const cv::Mat& homography); |
19 | 21 |
20 FeatureTrajectory(TrajectoryPoint2fPtr& _positions, TrajectoryPoint2fPtr& _velocities); | 22 FeatureTrajectory(TrajectoryPoint2fPtr& _positions, TrajectoryPoint2fPtr& _velocities); |
21 | 23 |
45 | 47 |
46 void addPoint(const unsigned int& frameNum, const cv::Point2f& p, const cv::Mat& homography); | 48 void addPoint(const unsigned int& frameNum, const cv::Point2f& p, const cv::Mat& homography); |
47 | 49 |
48 void shorten(void); | 50 void shorten(void); |
49 | 51 |
52 void movingAverage(const unsigned int& nFramesSmoothing); | |
53 | |
50 void write(TrajectoryDBAccess<cv::Point2f>& trajectoryDB, const std::string& positionsTableName, const std::string& velocitiesTableName) const; | 54 void write(TrajectoryDBAccess<cv::Point2f>& trajectoryDB, const std::string& positionsTableName, const std::string& velocitiesTableName) const; |
51 | 55 |
52 #ifdef USE_OPENCV | 56 #ifdef USE_OPENCV |
53 void draw(cv::Mat& img, const cv::Mat& homography, const cv::Scalar& color) const; | 57 void draw(cv::Mat& img, const cv::Mat& homography, const cv::Scalar& color) const; |
54 #endif | 58 #endif |
55 | 59 |
56 friend std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft); | 60 friend std::ostream& operator<<(std::ostream& out, const FeatureTrajectory& ft); |
57 | 61 |
58 protected: | 62 protected: |
59 /// first frame number | 63 /// first frame number |
60 unsigned int firstInstant; | 64 unsigned int firstInstant; |
61 /// last frame number | 65 /// last frame number |
62 unsigned int lastInstant; | 66 unsigned int lastInstant; |
63 | 67 |
64 TrajectoryPoint2fPtr positions; | 68 TrajectoryPoint2fPtr positions; |
65 /** one fewer velocity than position | 69 /** one fewer velocity than position |
66 v_n = p_n+1 - p_n*/ | 70 v_n = p_n - p_n-1*/ |
67 TrajectoryPoint2fPtr velocities; | 71 TrajectoryPoint2fPtr velocities; |
68 | 72 |
69 /// norms of velocities for feature constraints, one fewer positions than positions | 73 /// norms of velocities for feature constraints, one fewer positions than positions |
70 std::vector<float> displacementDistances; | 74 std::vector<float> displacementDistances; |
71 | 75 |
73 }; | 77 }; |
74 | 78 |
75 typedef boost::shared_ptr<FeatureTrajectory> FeatureTrajectoryPtr; | 79 typedef boost::shared_ptr<FeatureTrajectory> FeatureTrajectoryPtr; |
76 | 80 |
77 // inlined | 81 // inlined |
78 inline std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft) { | 82 inline std::ostream& operator<<(std::ostream& out, const FeatureTrajectory& ft) |
83 { | |
79 out << *(ft.positions); | 84 out << *(ft.positions); |
80 out << "\n"; | 85 out << "\n"; |
81 out << *(ft.velocities); | 86 out << *(ft.velocities); |
87 | |
82 return out; | 88 return out; |
83 } | 89 } |
84 | 90 |
85 // class MovingObject {} | 91 // class MovingObject {} |
86 // roadUserType, group of features | 92 // roadUserType, group of features |
114 /// Computes the connected components: features have to be older than lastInstant | 120 /// Computes the connected components: features have to be older than lastInstant |
115 void connectedComponents(const unsigned int& lastInstant); | 121 void connectedComponents(const unsigned int& lastInstant); |
116 | 122 |
117 /** Performs some checks on groups of features and return their lists of ids if correct | 123 /** Performs some checks on groups of features and return their lists of ids if correct |
118 Removes the vertices from the graph */ | 124 Removes the vertices from the graph */ |
119 std::vector<std::vector<unsigned int> > getFeatureGroups(void); | 125 void getFeatureGroups(std::vector<std::vector<FeatureTrajectoryPtr> >& featureGroups); |
120 | 126 |
121 std::string informationString(void) const; | 127 std::string informationString(void) const; |
122 | 128 |
123 int getNVertices(void) const; | 129 int getNVertices(void) const; |
124 int getNEdges(void) const; | 130 int getNEdges(void) const; |