gtsam  4.0.0
gtsam
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  std::runtime_error("Stereo Cheirality Exception") {
30  }
31 };
32 
37 class GTSAM_EXPORT StereoCamera {
38 
39 public:
40 
46 
47 private:
48  Pose3 leftCamPose_;
50 
51 public:
52 
53  enum {
54  dimension = 6
55  };
56 
59 
62  K_(new Cal3_S2Stereo()) {
63  }
64 
66  StereoCamera(const Pose3& leftCamPose, const Cal3_S2Stereo::shared_ptr K);
67 
69  const Cal3_S2Stereo& calibration() const {
70  return *K_;
71  }
72 
76 
78  void print(const std::string& s = "") const {
79  leftCamPose_.print(s + ".camera.");
80  K_->print(s + ".calibration.");
81  }
82 
84  bool equals(const StereoCamera &camera, double tol = 1e-9) const {
85  return leftCamPose_.equals(camera.leftCamPose_, tol)
86  && K_->equals(*camera.K_, tol);
87  }
88 
92 
94  inline size_t dim() const {
95  return 6;
96  }
97 
99  static inline size_t Dim() {
100  return 6;
101  }
102 
104  inline StereoCamera retract(const Vector& v) const {
105  return StereoCamera(pose().retract(v), K_);
106  }
107 
109  inline Vector6 localCoordinates(const StereoCamera& t2) const {
110  return leftCamPose_.localCoordinates(t2.leftCamPose_);
111  }
112 
116 
118  const Pose3& pose() const {
119  return leftCamPose_;
120  }
121 
123  double baseline() const {
124  return K_->baseline();
125  }
126 
128  StereoPoint2 project(const Point3& point) const;
129 
134  StereoPoint2 project2(const Point3& point, OptionalJacobian<3, 6> H1 =
135  boost::none, OptionalJacobian<3, 3> H2 = boost::none) const;
136 
138  Point3 backproject(const StereoPoint2& z) const;
139 
144  Point3 backproject2(const StereoPoint2& z,
145  OptionalJacobian<3, 6> H1 = boost::none,
146  OptionalJacobian<3, 3> H2 = boost::none) const;
147 
151 
159  OptionalJacobian<3, 3> H2 = boost::none, OptionalJacobian<3, 0> H3 =
160  boost::none) const;
161 
163 
164 private:
165 
166  friend class boost::serialization::access;
167  template<class Archive>
168  void serialize(Archive & ar, const unsigned int /*version*/) {
169  ar & BOOST_SERIALIZATION_NVP(leftCamPose_);
170  ar & BOOST_SERIALIZATION_NVP(K_);
171  }
172 
173 };
174 
175 template<>
176 struct traits<StereoCamera> : public internal::Manifold<StereoCamera> {
177 };
178 
179 template<>
180 struct traits<const StereoCamera> : public internal::Manifold<StereoCamera> {
181 };
182 }
Definition: Cal3_S2Stereo.h:29
Point2_ project(const Point3_ &p_cam)
Expression version of PinholeBase::Project.
Definition: expressions.h:57
double baseline() const
baseline
Definition: StereoCamera.h:123
3D Pose
void print(const std::string &s="") const
print
Definition: StereoCamera.h:78
const Pose3 & pose() const
pose
Definition: StereoCamera.h:118
A 2D stereo point (uL,uR,v)
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition: OptionalJacobian.h:39
Definition: StereoPoint2.h:32
Vector6 localCoordinates(const StereoCamera &t2) const
Local coordinates of manifold neighborhood around current value.
Definition: StereoCamera.h:109
Definition: Pose3.h:37
const Cal3_S2Stereo & calibration() const
Return shared pointer to calibration.
Definition: StereoCamera.h:69
Definition: Point3.h:45
StereoPoint2 Measurement
Some classes template on either PinholeCamera or StereoCamera, and this typedef informs those classes...
Definition: StereoCamera.h:45
size_t dim() const
Dimensionality of the tangent space.
Definition: StereoCamera.h:94
boost::shared_ptr< Cal3_S2Stereo > shared_ptr
shared pointer to stereo calibration object
Definition: Cal3_S2Stereo.h:38
Both ManifoldTraits and Testable.
Definition: Manifold.h:120
void print(const std::string &s="") const
print with optional string
Definition: Pose3.cpp:107
StereoCamera()
Default constructor allocates a calibration!
Definition: StereoCamera.h:61
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
Definition: StereoCamera.h:26
static size_t Dim()
Dimensionality of the tangent space.
Definition: StereoCamera.h:99
bool equals(const StereoCamera &camera, double tol=1e-9) const
equals
Definition: StereoCamera.h:84
bool equals(const Pose3 &pose, double tol=1e-9) const
assert equality up to a tolerance
Definition: Pose3.cpp:114
The most common 5DOF 3D->2D calibration + Stereo baseline.
TangentVector localCoordinates(const Class &g) const
localCoordinates as required by manifold concept: finds tangent vector between *this and g ...
Definition: Lie.h:138
Definition: StereoCamera.h:37
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
StereoCamera retract(const Vector &v) const
Updates a with tangent space delta.
Definition: StereoCamera.h:104