gtsam 4.1.1
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
20#pragma once
21
22#include <gtsam/geometry/Cal3.h>
24
25namespace gtsam {
26
41class GTSAM_EXPORT Cal3DS2_Base : public Cal3 {
42 protected:
43 double k1_ = 0.0f, k2_ = 0.0f;
44 double p1_ = 0.0f, p2_ = 0.0f;
45 double tol_ = 1e-5;
46
47 public:
48 enum { dimension = 9 };
49
52
54 Cal3DS2_Base() = default;
55
56 Cal3DS2_Base(double fx, double fy, double s, double u0, double v0, double k1,
57 double k2, double p1 = 0.0, double p2 = 0.0, double tol = 1e-5)
58 : Cal3(fx, fy, s, u0, v0),
59 k1_(k1),
60 k2_(k2),
61 p1_(p1),
62 p2_(p2),
63 tol_(tol) {}
64
65 ~Cal3DS2_Base() override {}
66
70
71 Cal3DS2_Base(const Vector9& v)
72 : Cal3(v(0), v(1), v(2), v(3), v(4)),
73 k1_(v(5)),
74 k2_(v(6)),
75 p1_(v(7)),
76 p2_(v(8)) {}
77
81
83 GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
84 const Cal3DS2_Base& cal);
85
87 void print(const std::string& s = "") const override;
88
90 bool equals(const Cal3DS2_Base& K, double tol = 1e-8) const;
91
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 Vector4 k() const { return Vector4(k1_, k2_, p1_, p2_); }
110
112 Vector9 vector() const;
113
121 Point2 uncalibrate(const Point2& p, OptionalJacobian<2, 9> Dcal = boost::none,
122 OptionalJacobian<2, 2> Dp = boost::none) const;
123
125 Point2 calibrate(const Point2& p, OptionalJacobian<2, 9> Dcal = boost::none,
126 OptionalJacobian<2, 2> Dp = boost::none) const;
127
129 Matrix2 D2d_intrinsic(const Point2& p) const;
130
132 Matrix29 D2d_calibration(const Point2& p) const;
133
135 size_t dim() const override { return Dim(); }
136
138 inline static size_t Dim() { return dimension; }
139
143
145 virtual boost::shared_ptr<Cal3DS2_Base> clone() const {
146 return boost::shared_ptr<Cal3DS2_Base>(new Cal3DS2_Base(*this));
147 }
148
150
151 private:
154
156 friend class boost::serialization::access;
157 template <class Archive>
158 void serialize(Archive& ar, const unsigned int /*version*/) {
159 ar& boost::serialization::make_nvp(
160 "Cal3DS2_Base", boost::serialization::base_object<Cal3>(*this));
161 ar& BOOST_SERIALIZATION_NVP(k1_);
162 ar& BOOST_SERIALIZATION_NVP(k2_);
163 ar& BOOST_SERIALIZATION_NVP(p1_);
164 ar& BOOST_SERIALIZATION_NVP(p2_);
165 ar& BOOST_SERIALIZATION_NVP(tol_);
166 }
167
169};
170}
2D Point
Common code for all Calibration models.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:112
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
Vector2 Point2
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point2 to Vector2...
Definition: Point2.h:27
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition: OptionalJacobian.h:39
Definition: Cal3.h:69
Definition: Cal3DS2_Base.h:41
Cal3DS2_Base()=default
Default Constructor with only unit focal length.
double p2() const
Second tangential distortion coefficient.
Definition: Cal3DS2_Base.h:106
static size_t Dim()
return DOF, dimensionality of tangent space
Definition: Cal3DS2_Base.h:138
virtual boost::shared_ptr< Cal3DS2_Base > clone() const
Definition: Cal3DS2_Base.h:145
double k2() const
Second distortion coefficient.
Definition: Cal3DS2_Base.h:100
double k1() const
First distortion coefficient.
Definition: Cal3DS2_Base.h:97
size_t dim() const override
return DOF, dimensionality of tangent space
Definition: Cal3DS2_Base.h:135
double p1() const
First tangential distortion coefficient.
Definition: Cal3DS2_Base.h:103
Vector4 k() const
return distortion parameter vector
Definition: Cal3DS2_Base.h:109