gtsam
Loading...
Searching...
No Matches
Cal3_S2.h
Go to the documentation of this file.
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
17
21
22#pragma once
23
25#include <gtsam/geometry/Cal3.h>
27
28namespace gtsam {
29
35class GTSAM_EXPORT Cal3_S2 : public Cal3 {
36 public:
37 constexpr static auto dimension = 5;
38
40 using shared_ptr = std::shared_ptr<Cal3_S2>;
41
44
46 Cal3_S2() = default;
47
49 Cal3_S2(double fx, double fy, double s, double u0, double v0)
50 : Cal3(fx, fy, s, u0, v0) {}
51
53 Cal3_S2(const Vector5& d) : Cal3(d) {}
54
61 Cal3_S2(double fov, int w, int h) : Cal3(fov, w, h) {}
62
70 Point2 uncalibrate(const Point2& p, OptionalJacobian<2, 5> Dcal = {},
71 OptionalJacobian<2, 2> Dp = {}) const;
72
80 Point2 calibrate(const Point2& p, OptionalJacobian<2, 5> Dcal = {},
81 OptionalJacobian<2, 2> Dp = {}) const;
82
88 Vector3 calibrate(const Vector3& p) const;
89
93
95 GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
96 const Cal3_S2& cal);
97
99 void print(const std::string& s = "Cal3_S2") const override;
100
102 bool equals(const Cal3_S2& K, double tol = 10e-9) const;
103
107 OptionalJacobian<5, 5> H2 = {}) const {
108 if (H1) *H1 = -I_5x5;
109 if (H2) *H2 = I_5x5;
110 return Cal3_S2(q.fx_ - fx_, q.fy_ - fy_, q.s_ - s_, q.u0_ - u0_,
111 q.v0_ - v0_);
112 }
113
117
119 virtual size_t dim() const { return Dim(); };
120
122 static size_t Dim() { return dimension; }
123
125 Cal3_S2 retract(const Vector& d) const {
126 return Cal3_S2(fx_ + d(0), fy_ + d(1), s_ + d(2), u0_ + d(3), v0_ + d(4));
127 }
128
130 Vector5 localCoordinates(const Cal3_S2& T2) const {
131 return T2.vector() - vector();
132 }
133
137
138 private:
139#if GTSAM_ENABLE_BOOST_SERIALIZATION
141 friend class boost::serialization::access;
142 template <class Archive>
143 void serialize(Archive& ar, const unsigned int /*version*/) {
144 ar& boost::serialization::make_nvp(
145 "Cal3_S2", boost::serialization::base_object<Cal3>(*this));
146 }
147#endif
148
150};
151
152template <>
153struct traits<Cal3_S2> : public internal::Manifold<Cal3_S2> {};
154
155template <>
156struct traits<const Cal3_S2> : public internal::Manifold<Cal3_S2> {};
157
158} // \ namespace gtsam
Macros for Matrix constants to avoid excessive template instantiation.
2D Point
Common code for all Calibration models.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
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:32
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Both ManifoldTraits and Testable.
Definition Manifold.h:156
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition OptionalJacobian.h:40
Vector5 vector() const
vectorized form (column-wise)
Definition Cal3.h:159
Cal3()=default
Create a default calibration that leaves coordinates unchanged.
double fy_
focal length
Definition Cal3.h:71
double s_
skew
Definition Cal3.h:72
double fx() const
focal length x
Definition Cal3.h:138
double v0_
principal point
Definition Cal3.h:73
double fy() const
focal length y
Definition Cal3.h:141
The most common 5DOF 3D->2D calibration.
Definition Cal3_S2.h:35
virtual size_t dim() const
return DOF, dimensionality of tangent space
Definition Cal3_S2.h:119
Cal3_S2()=default
Create a default calibration that leaves coordinates unchanged.
Cal3_S2(double fx, double fy, double s, double u0, double v0)
constructor from doubles
Definition Cal3_S2.h:49
static constexpr auto dimension
shared pointer to calibration object
Definition Cal3_S2.h:37
static size_t Dim()
return DOF, dimensionality of tangent space
Definition Cal3_S2.h:122
Cal3_S2(const Vector5 &d)
constructor from vector
Definition Cal3_S2.h:53
Vector5 localCoordinates(const Cal3_S2 &T2) const
Unretraction for the calibration.
Definition Cal3_S2.h:130
Cal3_S2(double fov, int w, int h)
Easy constructor, takes fov in degrees, asssumes zero skew, unit aspect.
Definition Cal3_S2.h:61
Cal3_S2 between(const Cal3_S2 &q, OptionalJacobian< 5, 5 > H1={}, OptionalJacobian< 5, 5 > H2={}) const
"Between", subtracts calibrations. between(p,q) == compose(inverse(p),q)
Definition Cal3_S2.h:105
Cal3_S2 retract(const Vector &d) const
Given 5-dim tangent vector, create new calibration.
Definition Cal3_S2.h:125