Extrinsics.h
Go to the documentation of this file.
00001 /*
00002  * Extrinsics.h
00003  *
00004  *  Created on: Oct 20, 2010
00005  *      Author: erublee
00006  */
00007 
00008 #ifndef EXTRINSICS_H_
00009 #define EXTRINSICS_H_
00010 
00011 #include "pano_core/pano_interfaces.h"
00012 
00013 #include <opencv2/core/core.hpp>
00014 #include <opencv2/calib3d/calib3d.hpp>
00015 #include <vector>
00016 namespace pano
00017 {
00018 class Extrinsics : public serializable
00019 {
00020 public:
00021   Extrinsics();
00022   Extrinsics(const Extrinsics& rhs);
00023   Extrinsics& operator=(const Extrinsics& rhs);
00024   Extrinsics(const std::vector<cv::Mat>& mats, const std::vector<double>& vals, const std::vector<int>& flags);
00025   Extrinsics(const cv::Mat& R, const cv::Mat& T, double latitude, double longitude, double gps_accuracy, double confidence, double gps_time,
00026              bool estimated);
00027   Extrinsics(const cv::Mat& R, double confidence);
00028   ~Extrinsics();
00029 
00030   virtual int version() const
00031   {
00032     return 0;
00033   }
00034   virtual void serialize(cv::FileStorage& fs) const;
00035   virtual void deserialize(const cv::FileNode& fn);
00036 
00037   const cv::Mat& mat(int idx) const
00038   {
00039     return mats_[idx];
00040   }
00041 
00042   cv::Mat relativeToOther(const Extrinsics& ext, int idx) const
00043   {
00044     return  mats_[idx] * ext.mats_[idx].t();
00045   }
00046 
00047   double val(int idx) const
00048   {
00049     return vals_[idx];
00050   }
00051   bool flag(int idx) const
00052   {
00053     return flags_[idx];
00054   }
00055 
00056   cv::Mat& mat(int idx)
00057   {
00058     return mats_[idx];
00059   }
00060 
00061   double& val(int idx)
00062   {
00063     return vals_[idx];
00064   }
00065   int& flag(int idx)
00066   {
00067     return flags_[idx];
00068   }
00069 
00070   enum StdMats
00071   {
00072     R = 0, T, W, N_STD_MATS
00073   };
00074   enum StdVals
00075   {
00076     LATITUDE = 0, LONGITUDE, GPS_ACCURACY, CONFIDENCE, GPS_TIME, N_STD_VALS
00077   };
00078 
00079   enum StdFlags
00080   {
00081     ESTIMATED = 0, N_STD_FLAGS
00082   };
00083 
00084 private:
00085   void copyData(const Extrinsics& rhs);
00086   std::vector<cv::Mat> mats_;
00087   std::vector<double> vals_;
00088   std::vector<int> flags_;
00089 };
00090 
00091 inline float angularDist(const Extrinsics& ext1, const Extrinsics& ext2)
00092 {
00093   cv::Mat R12 = ext1.relativeToOther(ext2, Extrinsics::R);
00094   cv::Mat v;
00095   cv::Rodrigues(R12, v);
00096   return norm(v);
00097 
00098 }
00099 
00100 inline cv::Mat skewsym(const cv::Mat& x)
00101 {
00102   // W = skewsym( w )
00103   cv::Mat_<float> m(3,3);
00104   m(0,1) = -(m(1,0) = x.at<float>(2));
00105   m(1,2) = -(m(2,1) = x.at<float>(0));
00106   m(2,0) = -(m(0,2) = x.at<float>(1));
00107   return m;
00108 }
00109 
00110 }
00111 #endif /* EXTRINSICS_H_ */


pano_core
Author(s): Ethan Rublee
autogenerated on Mon Oct 6 2014 08:04:38