gtsam  4.0.0
gtsam
SimpleCamera.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 
23 #include <gtsam/geometry/Cal3_S2.h>
24 
25 namespace gtsam {
26 
29 
34 class GTSAM_EXPORT SimpleCamera : public PinholeCameraCal3_S2 {
35 
37  typedef boost::shared_ptr<SimpleCamera> shared_ptr;
38 
39 public:
40 
43 
46  Base() {
47  }
48 
50  explicit SimpleCamera(const Pose3& pose) :
51  Base(pose) {
52  }
53 
55  SimpleCamera(const Pose3& pose, const Cal3_S2& K) :
56  Base(pose, K) {
57  }
58 
62 
70  static SimpleCamera Level(const Cal3_S2 &K, const Pose2& pose2,
71  double height) {
72  return SimpleCamera(Base::LevelPose(pose2, height), K);
73  }
74 
76  static SimpleCamera Level(const Pose2& pose2, double height) {
77  return SimpleCamera::Level(Cal3_S2(), pose2, height);
78  }
79 
89  static SimpleCamera Lookat(const Point3& eye, const Point3& target,
90  const Point3& upVector, const Cal3_S2& K = Cal3_S2()) {
91  return SimpleCamera(Base::LookatPose(eye, target, upVector), K);
92  }
93 
97 
99  explicit SimpleCamera(const Vector &v) :
100  Base(v) {
101  }
102 
104  SimpleCamera(const Vector &v, const Vector &K) :
105  Base(v, K) {
106  }
107 
109  SimpleCamera::shared_ptr clone() const { return boost::make_shared<SimpleCamera>(*this); }
110 
111 
115 
117  SimpleCamera retract(const Vector& d) const {
118  if ((size_t) d.size() == 6)
119  return SimpleCamera(this->pose().retract(d), calibration());
120  else
121  return SimpleCamera(this->pose().retract(d.head(6)),
122  calibration().retract(d.tail(calibration().dim())));
123  }
124 
126 
127 };
128 
130 GTSAM_EXPORT SimpleCamera simpleCamera(const Matrix34& P);
131 
132 // manifold traits
133 template <>
134 struct traits<SimpleCamera> : public internal::Manifold<SimpleCamera> {};
135 
136 template <>
137 struct traits<const SimpleCamera> : public internal::Manifold<SimpleCamera> {};
138 
139 // range traits, used in RangeFactor
140 template <typename T>
141 struct Range<SimpleCamera, T> : HasRange<SimpleCamera, T, double> {};
142 
143 } // namespace gtsam
SimpleCamera(const Vector &v)
Init from vector, can be 6D (default calibration) or dim.
Definition: SimpleCamera.h:99
The most common 5DOF 3D->2D calibration.
SimpleCamera::shared_ptr clone() const
Copy this object as its actual derived type.
Definition: SimpleCamera.h:109
SimpleCamera(const Pose3 &pose)
constructor with pose
Definition: SimpleCamera.h:50
Both ManifoldTraits and Testable.
Definition: Manifold.h:120
Definition: PinholeCamera.h:33
Definition: Point3.h:45
SimpleCamera(const Pose3 &pose, const Cal3_S2 &K)
constructor with pose and calibration
Definition: SimpleCamera.h:55
SimpleCamera(const Vector &v, const Vector &K)
Init from Vector and calibration.
Definition: SimpleCamera.h:104
Bearing-Range product.
Base class for all pinhole cameras.
static SimpleCamera Level(const Cal3_S2 &K, const Pose2 &pose2, double height)
Create a level camera at the given 2D pose and height.
Definition: SimpleCamera.h:70
Definition: BearingRange.h:193
Definition: SimpleCamera.h:34
static SimpleCamera Lookat(const Point3 &eye, const Point3 &target, const Point3 &upVector, const Cal3_S2 &K=Cal3_S2())
Create a camera at the given eye position looking at a target point in the scene with the specified u...
Definition: SimpleCamera.h:89
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: Pose2.h:36
Definition: BearingRange.h:39
static SimpleCamera Level(const Pose2 &pose2, double height)
PinholeCamera::level with default calibration.
Definition: SimpleCamera.h:76
Definition: Cal3_S2.h:33
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
SimpleCamera simpleCamera(const Matrix34 &P)
Recover camera from 3*4 camera matrix.
Definition: SimpleCamera.cpp:24
SimpleCamera retract(const Vector &d) const
move a cameras according to d
Definition: SimpleCamera.h:117
gtsam::PinholeCamera< gtsam::Cal3_S2 > PinholeCameraCal3_S2
A simple camera class with a Cal3_S2 calibration.
Definition: SimpleCamera.h:28
SimpleCamera()
default constructor
Definition: SimpleCamera.h:45
Definition: Pose3.h:37