comparison include/Motion.hpp @ 177:ae2286b1a3fd

added loading FeatureTrajectory from database, printing
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 30 Oct 2011 11:25:51 -0400
parents 9323427aa0a3
children d7df8ecf5ccd
comparison
equal deleted inserted replaced
176:9323427aa0a3 177:ae2286b1a3fd
1 #ifndef FEATURE_HPP 1 #ifndef MOTION_HPP
2 #define FEATURE_HPP 2 #define MOTION_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 #include <boost/graph/adjacency_list.hpp>
8 8
9 template<typename T> class TrajectoryDBAccess; 9 template<typename T> class TrajectoryDBAccess;
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 {
17 public: 18 public:
18 FeatureTrajectory(const int& frameNum, const cv::Point2f& p, const cv::Mat& homography); 19 FeatureTrajectory(const int& frameNum, const cv::Point2f& p, const cv::Mat& homography);
20
21 FeatureTrajectory(TrajectoryPoint2fPtr& _positions, TrajectoryPoint2fPtr& _velocities);
22
23 /** loads from database
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);
19 26
20 unsigned int length(void) const { return positions->size();} 27 unsigned int length(void) const { return positions->size();}
21 28
22 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);}
23 30
38 45
39 #ifdef USE_OPENCV 46 #ifdef USE_OPENCV
40 void draw(cv::Mat& img, const cv::Mat& homography, const cv::Scalar& color) const; 47 void draw(cv::Mat& img, const cv::Mat& homography, const cv::Scalar& color) const;
41 #endif 48 #endif
42 49
50 friend std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft);
51
43 protected: 52 protected:
44 bool lost; 53 bool lost;
45 TrajectoryPoint2fPtr positions; 54 TrajectoryPoint2fPtr positions;
46 /** one fewer velocity than position 55 /** one fewer velocity than position
47 v_n = p_n+1 - p_n*/ 56 v_n = p_n+1 - p_n*/
49 58
50 /// norms of velocities for feature constraints, one fewer positions than positions 59 /// norms of velocities for feature constraints, one fewer positions than positions
51 std::vector<float> displacementDistances; 60 std::vector<float> displacementDistances;
52 61
53 void computeMotionData(const int& frameNum); 62 void computeMotionData(const int& frameNum);
54
55 }; 63 };
56 64
57 typedef boost::shared_ptr<FeatureTrajectory> FeatureTrajectoryPtr; 65 typedef boost::shared_ptr<FeatureTrajectory> FeatureTrajectoryPtr;
66
67 // inlined
68 inline std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft) {
69 out << *(ft.positions);
70 out << "\n";
71 out << *(ft.velocities);
72 return out;
73 }
58 74
59 // class MovingObject {} 75 // class MovingObject {}
60 // roadUserType, group of features 76 // roadUserType, group of features
61 77
62 /// Class to group features 78 /// Class to group features