gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalibratedCamera.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 
19 #pragma once
20 
21 #include <gtsam/base/DerivedValue.h>
22 #include <gtsam/geometry/Pose2.h>
23 #include <gtsam/geometry/Pose3.h>
24 
25 namespace gtsam {
26 
27 class GTSAM_EXPORT CheiralityException: public ThreadsafeException<
28  CheiralityException> {
29 public:
31  ThreadsafeException<CheiralityException>("Cheirality Exception") {
32  }
33 };
34 
42 class GTSAM_EXPORT CalibratedCamera: public DerivedValue<CalibratedCamera> {
43 private:
44  Pose3 pose_; // 6DOF pose
45 
46 public:
47 
50 
53  }
54 
56  explicit CalibratedCamera(const Pose3& pose);
57 
61 
63  explicit CalibratedCamera(const Vector &v);
64 
68 
69  virtual void print(const std::string& s = "") const {
70  pose_.print(s);
71  }
72 
74  bool equals(const CalibratedCamera &camera, double tol = 1e-9) const {
75  return pose_.equals(camera.pose(), tol);
76  }
77 
81 
83  virtual ~CalibratedCamera() {
84  }
85 
87  inline const Pose3& pose() const {
88  return pose_;
89  }
90 
92  inline const CalibratedCamera compose(const CalibratedCamera &c,
93  boost::optional<Matrix&> H1 = boost::none, boost::optional<Matrix&> H2 =
94  boost::none) const {
95  return CalibratedCamera(pose_.compose(c.pose(), H1, H2));
96  }
97 
99  inline const CalibratedCamera between(const CalibratedCamera& c,
100  boost::optional<Matrix&> H1 = boost::none, boost::optional<Matrix&> H2 =
101  boost::none) const {
102  return CalibratedCamera(pose_.between(c.pose(), H1, H2));
103  }
104 
106  inline const CalibratedCamera inverse(boost::optional<Matrix&> H1 =
107  boost::none) const {
108  return CalibratedCamera(pose_.inverse(H1));
109  }
110 
117  static CalibratedCamera Level(const Pose2& pose2, double height);
118 
122 
124  CalibratedCamera retract(const Vector& d) const;
125 
127  Vector localCoordinates(const CalibratedCamera& T2) const;
128 
130  inline size_t dim() const {
131  return 6;
132  }
133 
135  inline static size_t Dim() {
136  return 6;
137  }
138 
139  /* ************************************************************************* */
140  // measurement functions and derivatives
141  /* ************************************************************************* */
142 
146 
154  Point2 project(const Point3& point,
155  boost::optional<Matrix&> Dpose = boost::none,
156  boost::optional<Matrix&> Dpoint = boost::none) const;
157 
163  static Point2 project_to_camera(const Point3& cameraPoint,
164  boost::optional<Matrix&> H1 = boost::none);
165 
169  static Point3 backproject_from_camera(const Point2& p, const double scale);
170 
178  double range(const Point3& point, boost::optional<Matrix&> H1 = boost::none,
179  boost::optional<Matrix&> H2 = boost::none) const {
180  return pose_.range(point, H1, H2);
181  }
182 
190  double range(const Pose3& pose, boost::optional<Matrix&> H1 = boost::none,
191  boost::optional<Matrix&> H2 = boost::none) const {
192  return pose_.range(pose, H1, H2);
193  }
194 
202  double range(const CalibratedCamera& camera, boost::optional<Matrix&> H1 =
203  boost::none, boost::optional<Matrix&> H2 = boost::none) const {
204  return pose_.range(camera.pose_, H1, H2);
205  }
206 
207 private:
208 
212 
214  friend class boost::serialization::access;
215  template<class Archive>
216  void serialize(Archive & ar, const unsigned int version) {
217  ar
218  & boost::serialization::make_nvp("CalibratedCamera",
219  boost::serialization::base_object<Value>(*this));
220  ar & BOOST_SERIALIZATION_NVP(pose_);
221  }
222 
224  };}
225 
const Pose3 & pose() const
return pose
Definition: CalibratedCamera.h:87
static size_t Dim()
Lie group dimensionality.
Definition: CalibratedCamera.h:135
const CalibratedCamera compose(const CalibratedCamera &c, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
compose the two camera poses: TODO Frank says this might not make sense
Definition: CalibratedCamera.h:92
Base exception type that uses tbb_exception if GTSAM is compiled with TBB.
Definition: types.h:154
Definition: Point2.h:35
2D Pose
double range(const Pose3 &pose, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
Calculate range to another pose.
Definition: CalibratedCamera.h:190
virtual ~CalibratedCamera()
destructor
Definition: CalibratedCamera.h:83
CalibratedCamera()
default constructor
Definition: CalibratedCamera.h:52
Definition: Pose3.h:42
Definition: CalibratedCamera.h:42
Definition: CalibratedCamera.h:27
size_t dim() const
Lie group dimensionality.
Definition: CalibratedCamera.h:130
virtual void print(const std::string &s="") const
Print this value, for debugging and unit tests.
Definition: CalibratedCamera.h:69
const CalibratedCamera inverse(boost::optional< Matrix & > H1=boost::none) const
invert the camera pose: TODO Frank says this might not make sense
Definition: CalibratedCamera.h:106
bool equals(const CalibratedCamera &camera, double tol=1e-9) const
check equality to another camera
Definition: CalibratedCamera.h:74
Definition: Pose2.h:36
3D Pose
const CalibratedCamera between(const CalibratedCamera &c, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
between the two camera poses: TODO Frank says this might not make sense
Definition: CalibratedCamera.h:99
double range(const Point3 &point, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
Calculate range to a landmark.
Definition: CalibratedCamera.h:178
Definition: DerivedValue.h:44
Definition: Point3.h:39
double range(const CalibratedCamera &camera, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
Calculate range to another camera.
Definition: CalibratedCamera.h:202