gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Cal3DS2_Base.h
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
21 #include <gtsam/base/DerivedValue.h>
22 #include <gtsam/geometry/Point2.h>
23 
24 namespace gtsam {
25 
40 class GTSAM_EXPORT Cal3DS2_Base {
41 
42 protected:
43 
44  double fx_, fy_, s_, u0_, v0_ ; // focal length, skew and principal point
45  double k1_, k2_ ; // radial 2nd-order and 4th-order
46  double p1_, p2_ ; // tangential distortion
47 
48 public:
49  Matrix K() const ;
50  Eigen::Vector4d k() const { return Eigen::Vector4d(k1_, k2_, p1_, p2_); }
51  Vector vector() const ;
52 
55 
57  Cal3DS2_Base() : fx_(1), fy_(1), s_(0), u0_(0), v0_(0), k1_(0), k2_(0), p1_(0), p2_(0) {}
58 
59  Cal3DS2_Base(double fx, double fy, double s, double u0, double v0,
60  double k1, double k2, double p1 = 0.0, double p2 = 0.0) :
61  fx_(fx), fy_(fy), s_(s), u0_(u0), v0_(v0), k1_(k1), k2_(k2), p1_(p1), p2_(p2) {}
62 
66 
67  Cal3DS2_Base(const Vector &v) ;
68 
72 
74  void print(const std::string& s = "") const ;
75 
77  bool equals(const Cal3DS2_Base& K, double tol = 10e-9) const;
78 
82 
84  inline double fx() const { return fx_;}
85 
87  inline double fy() const { return fy_;}
88 
90  inline double skew() const { return s_;}
91 
93  inline double px() const { return u0_;}
94 
96  inline double py() const { return v0_;}
97 
99  inline double k1() const { return k1_;}
100 
102  inline double k2() const { return k2_;}
103 
105  inline double p1() const { return p1_;}
106 
108  inline double p2() const { return p2_;}
109 
117  Point2 uncalibrate(const Point2& p,
118  boost::optional<Matrix&> Dcal = boost::none,
119  boost::optional<Matrix&> Dp = boost::none) const ;
120 
122  Point2 calibrate(const Point2& p, const double tol=1e-5) const;
123 
125  Matrix D2d_intrinsic(const Point2& p) const ;
126 
128  Matrix D2d_calibration(const Point2& p) const ;
129 
130 
131 private:
132 
136 
138  friend class boost::serialization::access;
139  template<class Archive>
140  void serialize(Archive & ar, const unsigned int version)
141  {
142  ar & BOOST_SERIALIZATION_NVP(fx_);
143  ar & BOOST_SERIALIZATION_NVP(fy_);
144  ar & BOOST_SERIALIZATION_NVP(s_);
145  ar & BOOST_SERIALIZATION_NVP(u0_);
146  ar & BOOST_SERIALIZATION_NVP(v0_);
147  ar & BOOST_SERIALIZATION_NVP(k1_);
148  ar & BOOST_SERIALIZATION_NVP(k2_);
149  ar & BOOST_SERIALIZATION_NVP(p1_);
150  ar & BOOST_SERIALIZATION_NVP(p2_);
151  }
152 
154 
155 };
156 
157 }
158 
double fy() const
focal length x
Definition: Cal3DS2_Base.h:87
Definition: Cal3DS2_Base.h:40
double k2() const
Second distortion coefficient.
Definition: Cal3DS2_Base.h:102
double p2() const
Second tangential distortion coefficient.
Definition: Cal3DS2_Base.h:108
Definition: Point2.h:35
2D Point
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
double p1() const
First tangential distortion coefficient.
Definition: Cal3DS2_Base.h:105
double py() const
image center in y
Definition: Cal3DS2_Base.h:96
double k1() const
First distortion coefficient.
Definition: Cal3DS2_Base.h:99
double px() const
image center in x
Definition: Cal3DS2_Base.h:93
Cal3DS2_Base()
Default Constructor with only unit focal length.
Definition: Cal3DS2_Base.h:57
double skew() const
skew
Definition: Cal3DS2_Base.h:90
double fx() const
focal length x
Definition: Cal3DS2_Base.h:84