gtsam  4.0.0
gtsam
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/geometry/Point2.h>
22 
23 namespace gtsam {
24 
39 class GTSAM_EXPORT Cal3DS2_Base {
40 
41 protected:
42 
43  double fx_, fy_, s_, u0_, v0_ ; // focal length, skew and principal point
44  double k1_, k2_ ; // radial 2nd-order and 4th-order
45  double p1_, p2_ ; // tangential distortion
46 
47 public:
48 
51 
53  Cal3DS2_Base() : fx_(1), fy_(1), s_(0), u0_(0), v0_(0), k1_(0), k2_(0), p1_(0), p2_(0) {}
54 
55  Cal3DS2_Base(double fx, double fy, double s, double u0, double v0,
56  double k1, double k2, double p1 = 0.0, double p2 = 0.0) :
57  fx_(fx), fy_(fy), s_(s), u0_(u0), v0_(v0), k1_(k1), k2_(k2), p1_(p1), p2_(p2) {}
58 
59  virtual ~Cal3DS2_Base() {}
60 
64 
65  Cal3DS2_Base(const Vector &v) ;
66 
70 
72  virtual void print(const std::string& s = "") const ;
73 
75  bool equals(const Cal3DS2_Base& K, double tol = 10e-9) const;
76 
80 
82  inline double fx() const { return fx_;}
83 
85  inline double fy() const { return fy_;}
86 
88  inline double skew() const { return s_;}
89 
91  inline double px() const { return u0_;}
92 
94  inline double py() const { return v0_;}
95 
97  inline double k1() const { return k1_;}
98 
100  inline double k2() const { return k2_;}
101 
103  inline double p1() const { return p1_;}
104 
106  inline double p2() const { return p2_;}
107 
109  Matrix3 K() const;
110 
112  Vector4 k() const { return Vector4(k1_, k2_, p1_, p2_); }
113 
115  Vector9 vector() const;
116 
124  Point2 uncalibrate(const Point2& p,
125  OptionalJacobian<2,9> Dcal = boost::none,
126  OptionalJacobian<2,2> Dp = boost::none) const ;
127 
129  Point2 calibrate(const Point2& p, const double tol=1e-5) const;
130 
132  Matrix2 D2d_intrinsic(const Point2& p) const ;
133 
135  Matrix29 D2d_calibration(const Point2& p) const ;
136 
140 
142  virtual boost::shared_ptr<Cal3DS2_Base> clone() const {
143  return boost::shared_ptr<Cal3DS2_Base>(new Cal3DS2_Base(*this));
144  }
145 
147 
148 private:
149 
152 
154  friend class boost::serialization::access;
155  template<class Archive>
156  void serialize(Archive & ar, const unsigned int /*version*/)
157  {
158  ar & BOOST_SERIALIZATION_NVP(fx_);
159  ar & BOOST_SERIALIZATION_NVP(fy_);
160  ar & BOOST_SERIALIZATION_NVP(s_);
161  ar & BOOST_SERIALIZATION_NVP(u0_);
162  ar & BOOST_SERIALIZATION_NVP(v0_);
163  ar & BOOST_SERIALIZATION_NVP(k1_);
164  ar & BOOST_SERIALIZATION_NVP(k2_);
165  ar & BOOST_SERIALIZATION_NVP(p1_);
166  ar & BOOST_SERIALIZATION_NVP(p2_);
167  }
168 
170 
171 };
172 
173 }
174 
double k1() const
First distortion coefficient.
Definition: Cal3DS2_Base.h:97
double px() const
image center in x
Definition: Cal3DS2_Base.h:91
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
double p2() const
Second tangential distortion coefficient.
Definition: Cal3DS2_Base.h:106
Vector4 k() const
return distortion parameter vector
Definition: Cal3DS2_Base.h:112
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition: OptionalJacobian.h:39
2D Point
double fx() const
focal length x
Definition: Cal3DS2_Base.h:82
Definition: Point2.h:40
Cal3DS2_Base()
Default Constructor with only unit focal length.
Definition: Cal3DS2_Base.h:53
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
double py() const
image center in y
Definition: Cal3DS2_Base.h:94
virtual boost::shared_ptr< Cal3DS2_Base > clone() const
Definition: Cal3DS2_Base.h:142
double k2() const
Second distortion coefficient.
Definition: Cal3DS2_Base.h:100
double p1() const
First tangential distortion coefficient.
Definition: Cal3DS2_Base.h:103
Definition: Cal3DS2_Base.h:39
double fy() const
focal length x
Definition: Cal3DS2_Base.h:85
double skew() const
skew
Definition: Cal3DS2_Base.h:88