StereoCamera.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 
18 #pragma once
19 
21 #include <gtsam/geometry/Pose3.h>
23 
24 namespace gtsam {
25 
26 class GTSAM_EXPORT StereoCheiralityException: public std::runtime_error {
27 public:
29  : StereoCheiralityException(std::numeric_limits<Key>::max()) {}
30 
32  : std::runtime_error("Stereo Cheirality Exception"),
33  j_(j) {}
34 
35  Key nearbyVariable() const {
36  return j_;
37  }
38 
39 private:
41 };
42 
47 class GTSAM_EXPORT StereoCamera {
48 
49 public:
50 
57 
58 private:
61 
62 public:
63 
64  inline constexpr static auto dimension = 6;
65 
68 
71  K_(new Cal3_S2Stereo()) {
72  }
73 
75  StereoCamera(const Pose3& leftCamPose, const Cal3_S2Stereo::shared_ptr K);
76 
78  const Cal3_S2Stereo& calibration() const {
79  return *K_;
80  }
81 
85 
87  void print(const std::string& s = "") const {
88  leftCamPose_.print(s + ".camera.");
89  K_->print(s + ".calibration.");
90  }
91 
93  bool equals(const StereoCamera &camera, double tol = 1e-9) const {
94  return leftCamPose_.equals(camera.leftCamPose_, tol)
95  && K_->equals(*camera.K_, tol);
96  }
97 
101 
103  inline size_t dim() const {
104  return 6;
105  }
106 
108  static inline size_t Dim() {
109  return 6;
110  }
111 
113  inline StereoCamera retract(const Vector& v) const {
114  return StereoCamera(pose().retract(v), K_);
115  }
116 
118  inline Vector6 localCoordinates(const StereoCamera& t2) const {
119  return leftCamPose_.localCoordinates(t2.leftCamPose_);
120  }
121 
125 
127  const Pose3& pose() const {
128  return leftCamPose_;
129  }
130 
132  double baseline() const {
133  return K_->baseline();
134  }
135 
137  StereoPoint2 project(const Point3& point) const;
138 
144  {}, OptionalJacobian<3, 3> H2 = {}) const;
145 
147  Point3 backproject(const StereoPoint2& z) const;
148 
153  Point3 backproject2(const StereoPoint2& z,
154  OptionalJacobian<3, 6> H1 = {},
155  OptionalJacobian<3, 3> H2 = {}) const;
156 
160 
167  StereoPoint2 project(const Point3& point, OptionalJacobian<3, 6> H1,
168  OptionalJacobian<3, 3> H2 = {}, OptionalJacobian<3, 0> H3 =
169  {}) const;
170 
173  return Eigen::Matrix<double,traits<Measurement>::dimension,1>::Constant(2.0 * K_->fx());
174  }
175 
177 
178 private:
179 
180 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
181  friend class boost::serialization::access;
182  template<class Archive>
183  void serialize(Archive & ar, const unsigned int /*version*/) {
184  ar & BOOST_SERIALIZATION_NVP(leftCamPose_);
185  ar & BOOST_SERIALIZATION_NVP(K_);
186  }
187 #endif
188 
189 };
190 
191 template<>
192 struct traits<StereoCamera> : public internal::Manifold<StereoCamera> {
193 };
194 
195 template<>
196 struct traits<const StereoCamera> : public internal::Manifold<StereoCamera> {
197 };
198 }
gtsam::StereoCamera::calibration
const Cal3_S2Stereo & calibration() const
Return shared pointer to calibration.
Definition: StereoCamera.h:78
gtsam::StereoCamera::defaultErrorWhenTriangulatingBehindCamera
Vector defaultErrorWhenTriangulatingBehindCamera() const
for Nonlinear Triangulation
Definition: StereoCamera.h:172
gtsam::StereoCamera::pose
const Pose3 & pose() const
pose
Definition: StereoCamera.h:127
pose
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::StereoCamera::K_
Cal3_S2Stereo::shared_ptr K_
Definition: StereoCamera.h:60
gtsam::StereoCamera::MeasurementVector
StereoPoint2Vector MeasurementVector
Definition: StereoCamera.h:56
gtsam::StereoCheiralityException::StereoCheiralityException
StereoCheiralityException()
Definition: StereoCamera.h:28
gtsam::StereoCamera::baseline
double baseline() const
baseline
Definition: StereoCamera.h:132
gtsam::StereoPoint2Vector
std::vector< StereoPoint2 > StereoPoint2Vector
Definition: StereoPoint2.h:168
gtsam::utils.numerical_derivative.retract
def retract(a, np.ndarray xi)
Definition: numerical_derivative.py:44
gtsam::StereoCheiralityException::StereoCheiralityException
StereoCheiralityException(Key j)
Definition: StereoCamera.h:31
gtsam::internal::Manifold
Both ManifoldTraits and Testable.
Definition: Manifold.h:117
backproject
static Point3 backproject(const Pose3 &pose, const Point2 &point, const double &depth)
Definition: testCalibratedCamera.cpp:207
gtsam::StereoCheiralityException::j_
Key j_
Definition: StereoCamera.h:40
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:39
gtsam::StereoCamera::leftCamPose_
Pose3 leftCamPose_
Definition: StereoCamera.h:59
gtsam::StereoCamera::Measurement
StereoPoint2 Measurement
Definition: StereoCamera.h:55
gtsam::StereoCamera::equals
bool equals(const StereoCamera &camera, double tol=1e-9) const
equals
Definition: StereoCamera.h:93
gtsam::project2
Point2_ project2(const Expression< CAMERA > &camera_, const Expression< POINT > &p_)
Definition: slam/expressions.h:151
gtsam::Pose3::print
void print(const std::string &s="") const
print with optional string
Definition: Pose3.cpp:150
gtsam_unstable.tests.test_ProjectionFactorRollingShutter.point
point
Definition: test_ProjectionFactorRollingShutter.py:25
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
gtsam::Pose3
Definition: Pose3.h:37
gtsam::Pose3::equals
bool equals(const Pose3 &pose, double tol=1e-9) const
assert equality up to a tolerance
Definition: Pose3.cpp:155
gtsam::StereoCamera::print
void print(const std::string &s="") const
print
Definition: StereoCamera.h:87
gtsam::StereoCheiralityException::nearbyVariable
Key nearbyVariable() const
Definition: StereoCamera.h:35
gtsam::StereoCamera::Dim
static size_t Dim()
Dimensionality of the tangent space.
Definition: StereoCamera.h:108
gtsam::Cal3_S2Stereo::shared_ptr
std::shared_ptr< Cal3_S2Stereo > shared_ptr
Definition: Cal3_S2Stereo.h:38
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
Cal3_S2Stereo.h
The most common 5DOF 3D->2D calibration + Stereo baseline.
gtsam::StereoCamera::StereoCamera
StereoCamera()
Default constructor allocates a calibration!
Definition: StereoCamera.h:70
StereoPoint2.h
A 2D stereo point (uL,uR,v)
gtsam::LieGroup::localCoordinates
TangentVector localCoordinates(const Class &g) const
localCoordinates as required by manifold concept: finds tangent vector between *this and g
Definition: Lie.h:136
gtsam::StereoCamera::retract
StereoCamera retract(const Vector &v) const
Updates a with tangent space delta.
Definition: StereoCamera.h:113
gtsam::StereoCamera::localCoordinates
Vector6 localCoordinates(const StereoCamera &t2) const
Local coordinates of manifold neighborhood around current value.
Definition: StereoCamera.h:118
gtsam
traits
Definition: SFMdata.h:40
gtsam::Cal3_S2Stereo
The most common 5DOF 3D->2D calibration, stereo version.
Definition: Cal3_S2Stereo.h:30
gtsam::traits
Definition: Group.h:36
K
#define K
Definition: igam.h:8
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
gtsam::StereoPoint2
Definition: StereoPoint2.h:34
std
Definition: BFloat16.h:88
gtsam::StereoCamera::dim
size_t dim() const
Dimensionality of the tangent space.
Definition: StereoCamera.h:103
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::StereoCamera
Definition: StereoCamera.h:47
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
gtsam::StereoCheiralityException
Definition: StereoCamera.h:26
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
camera
static const CalibratedCamera camera(kDefaultPose)
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::project
Point2_ project(const Point3_ &p_cam)
Expression version of PinholeBase::Project.
Definition: slam/expressions.h:131
max
#define max(a, b)
Definition: datatypes.h:20
Pose3.h
3D Pose manifold SO(3) x R^3 and group SE(3)


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:14:03