diff 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
line wrap: on
line diff
--- a/include/Motion.hpp	Thu Oct 27 13:56:46 2011 -0400
+++ b/include/Motion.hpp	Sun Oct 30 11:25:51 2011 -0400
@@ -1,5 +1,5 @@
-#ifndef FEATURE_HPP
-#define FEATURE_HPP
+#ifndef MOTION_HPP
+#define MOTION_HPP
 
 #include "src/Trajectory.h"
 
@@ -7,6 +7,7 @@
 #include <boost/graph/adjacency_list.hpp>
 
 template<typename T> class TrajectoryDBAccess;
+template<typename T> class TrajectoryDBAccessList;
 
 typedef boost::shared_ptr<TrajectoryPoint2f> TrajectoryPoint2fPtr;
 
@@ -17,6 +18,12 @@
 public:
   FeatureTrajectory(const int& frameNum, const cv::Point2f& p, const cv::Mat& homography);
 
+  FeatureTrajectory(TrajectoryPoint2fPtr& _positions, TrajectoryPoint2fPtr& _velocities);
+
+  /** loads from database
+   can be made generic for different list and blob */
+  FeatureTrajectory(const int& id, TrajectoryDBAccessList<cv::Point2f>& trajectoryDB, const std::string& positionsTableName, const std::string& velocitiesTableName);
+
   unsigned int length(void) const { return positions->size();}
 
   void setId(const unsigned int& id) { positions->setId(id);velocities->setId(id);}
@@ -40,6 +47,8 @@
   void draw(cv::Mat& img, const cv::Mat& homography, const cv::Scalar& color) const;
 #endif
 
+  friend std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft);
+
 protected:
   bool lost;
   TrajectoryPoint2fPtr positions;
@@ -51,11 +60,18 @@
   std::vector<float> displacementDistances;
 
   void computeMotionData(const int& frameNum);
-
 };
 
 typedef boost::shared_ptr<FeatureTrajectory> FeatureTrajectoryPtr;
 
+// inlined
+inline std::stringstream& operator<<(std::stringstream& out, const FeatureTrajectory& ft) {
+  out << *(ft.positions);
+  out << "\n";
+  out << *(ft.velocities);
+  return out;
+}
+
 // class MovingObject {}
 // roadUserType, group of features