32template<
typename CALIBRATION>
37 GTSAM_CONCEPT_MANIFOLD_TYPE(CALIBRATION)
40 static const int DimK = FixedDimension<CALIBRATION>::value;
44 typedef CALIBRATION CalibrationType;
89 template <
class POINT>
114 OptionalJacobian<2, DimK> Dcal = {})
const {
121 OptionalJacobian<2, DimK> Dcal = {})
const {
128 OptionalJacobian<2, DimK> Dcal = {})
const {
136 OptionalJacobian<3, 1> Dresult_ddepth = {},
137 OptionalJacobian<3, DimK> Dresult_dcal = {})
const {
138 typedef Eigen::Matrix<double, 2, DimK> Matrix2K;
142 Dresult_dp ? &Dpn_dp : 0);
144 Matrix31 Dpoint_ddepth;
146 (Dresult_dp || Dresult_dcal) ? &Dpoint_dpn : 0,
147 Dresult_ddepth ? &Dpoint_ddepth : 0);
148 Matrix33 Dresult_dpoint;
152 Dresult_dcal) ? &Dresult_dpoint : 0);
154 *Dresult_dcal = Dresult_dpoint * Dpoint_dpn * Dpn_dcal;
156 *Dresult_dp = Dresult_dpoint * Dpoint_dpn * Dpn_dp;
158 *Dresult_ddepth = Dresult_dpoint * Dpoint_ddepth;
166 const Unit3 pc(pn.x(), pn.y(), 1.0);
206 template<
class CalibrationB>
215#if GTSAM_ENABLE_BOOST_SERIALIZATION
217 friend class boost::serialization::access;
218 template<
class Archive>
219 void serialize(Archive & ar,
const unsigned int ) {
221 & boost::serialization::make_nvp(
"PinholeBase",
222 boost::serialization::base_object<PinholeBase>(*
this));
235template<
typename CALIBRATION>
241 std::shared_ptr<CALIBRATION> K_;
245 inline constexpr static auto calibration_dimension =
246 FixedDimension<CALIBRATION>::value;
258 Base(
pose), K_(new CALIBRATION()) {
278 const Pose2& pose2,
double height) {
297 const Point3& upVector,
const std::shared_ptr<CALIBRATION>& K =
298 std::make_shared<CALIBRATION>()) {
308 Base(v), K_(new CALIBRATION()) {
313 Base(v), K_(new CALIBRATION(K)) {
318 Base(
pose), K_(new CALIBRATION(K)) {
326 bool equals(
const Base &camera,
double tol = 1e-9)
const {
337 GTSAM_EXPORT
friend std::ostream&
operator<<(std::ostream& os,
341 if (!camera.K_) os <<
", K: none";
342 else os <<
", K: " << *camera.K_;
348 void print(
const std::string& s =
"PinholePose")
const override {
351 std::cout <<
"s No calibration given" << std::endl;
353 K_->print(s +
".calibration");
397 static size_t Dim() {
424 return Eigen::Matrix<double,traits<Point2>::dimension,1>::Constant(2.0 * K_->fx());
430#if GTSAM_ENABLE_BOOST_SERIALIZATION
432 friend class boost::serialization::access;
433 template<
class Archive>
434 void serialize(Archive & ar,
const unsigned int ) {
436 & boost::serialization::make_nvp(
"PinholeBaseK",
437 boost::serialization::base_object<Base>(*
this));
438 ar & BOOST_SERIALIZATION_NVP(K_);
444template<
typename CALIBRATION>
446 PinholePose<CALIBRATION> > {
449template<
typename CALIBRATION>
451 PinholePose<CALIBRATION> > {
Calibrated camera for which only pose is unknown.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition Point3.h:38
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
TangentVector localCoordinates(const Class &g) const
localCoordinates as required by manifold concept: finds tangent vector between *this and g
Definition Lie.h:226
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
A pinhole camera class that has a Pose3, functions as base class for all pinhole cameras.
Definition CalibratedCamera.h:55
PinholeBase()
Default constructor.
Definition CalibratedCamera.h:126
static Matrix26 Dpose(const Point2 &pn, double d)
Calculate Jacobian with respect to pose.
Definition CalibratedCamera.cpp:28
virtual void print(const std::string &s="PinholeBase") const
print
Definition CalibratedCamera.cpp:75
std::pair< Point2, bool > projectSafe(const Point3 &pw) const
Project a point into the image and check depth.
Definition CalibratedCamera.cpp:109
Point2 project2(const Point3 &point, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 3 > Dpoint={}) const
Project point into the image Throws a CheiralityException if point behind image plane iff GTSAM_THROW...
Definition CalibratedCamera.cpp:116
const Pose3 & pose() const
return pose, constant version
Definition CalibratedCamera.h:155
static Pose3 LevelPose(const Pose2 &pose2, double height)
Create a level pose at the given 2D pose and height.
Definition CalibratedCamera.cpp:50
bool equals(const PinholeBase &camera, double tol=1e-9) const
assert equality up to a tolerance
Definition CalibratedCamera.cpp:70
static Matrix23 Dpoint(const Point2 &pn, double d, const Matrix3 &Rt)
Calculate Jacobian with respect to point.
Definition CalibratedCamera.cpp:38
static Pose3 LookatPose(const Point3 &eye, const Point3 &target, const Point3 &upVector)
Create a camera pose at the given eye position looking at a target point in the scene with the specif...
Definition CalibratedCamera.cpp:59
static Point3 BackprojectFromCamera(const Point2 &p, const double depth, OptionalJacobian< 3, 2 > Dpoint={}, OptionalJacobian< 3, 1 > Ddepth={})
backproject a 2-dimensional point to a 3-dimensional point at given depth
Definition CalibratedCamera.cpp:167
A Calibrated camera class [R|-R't], calibration K=I.
Definition CalibratedCamera.h:252
const Rot3 & rotation(ComponentJacobian H={}) const
Rotation component.
Definition ExtendedPose3-inl.h:76
std::pair< Point2, bool > projectSafe(const Point3 &pw) const
Project a point into the image and check depth.
Definition PinholePose.h:76
PinholeBaseK()
default constructor
Definition PinholePose.h:50
virtual const CALIBRATION & calibration() const =0
return calibration
PinholeBaseK(const Pose3 &pose)
constructor with pose
Definition PinholePose.h:54
double range(const CalibratedCamera &camera, OptionalJacobian< 1, 6 > Dcamera={}, OptionalJacobian< 1, 6 > Dother={}) const
Calculate range to a CalibratedCamera.
Definition PinholePose.h:196
double range(const Point3 &point, OptionalJacobian< 1, 6 > Dcamera={}, OptionalJacobian< 1, 3 > Dpoint={}) const
Calculate range to a landmark.
Definition PinholePose.h:175
double range(const PinholeBaseK< CalibrationB > &camera, OptionalJacobian< 1, 6 > Dcamera={}, OptionalJacobian< 1, 6 > Dother={}) const
Calculate range to a PinholePoseK derived class.
Definition PinholePose.h:207
Point2 reprojectionError(const Point3 &pw, const Point2 &measured, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 3 > Dpoint={}, OptionalJacobian< 2, DimK > Dcal={}) const
project a 3D point from world coordinates into the image
Definition PinholePose.h:119
Point2 project(const Unit3 &pw, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 2 > Dpoint={}, OptionalJacobian< 2, DimK > Dcal={}) const
project a point at infinity from world coordinates into the image
Definition PinholePose.h:126
double range(const Pose3 &pose, OptionalJacobian< 1, 6 > Dcamera={}, OptionalJacobian< 1, 6 > Dpose={}) const
Calculate range to another pose.
Definition PinholePose.h:186
Unit3 backprojectPointAtInfinity(const Point2 &p) const
backproject a 2-dimensional point to a 3-dimensional point at infinity
Definition PinholePose.h:164
Point2 _project(const POINT &pw, OptionalJacobian< 2, 6 > Dpose, OptionalJacobian< 2, FixedDimension< POINT >::value > Dpoint, OptionalJacobian< 2, DimK > Dcal) const
Templated projection of a point (possibly at infinity) from world coordinate to the image.
Definition PinholePose.h:90
Point3 backproject(const Point2 &p, double depth, OptionalJacobian< 3, 6 > Dresult_dpose={}, OptionalJacobian< 3, 2 > Dresult_dp={}, OptionalJacobian< 3, 1 > Dresult_ddepth={}, OptionalJacobian< 3, DimK > Dresult_dcal={}) const
backproject a 2-dimensional point to a 3-dimensional point at given depth
Definition PinholePose.h:133
Point2 project(const Point3 &pw, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 3 > Dpoint={}, OptionalJacobian< 2, DimK > Dcal={}) const
project a 3D point from world coordinates into the image
Definition PinholePose.h:112
A pinhole camera class that has a Pose3 and a fixed Calibration.
Definition PinholePose.h:236
PinholePose()
default constructor
Definition PinholePose.h:253
Matrix34 cameraProjectionMatrix() const
for Linear Triangulation
Definition PinholePose.h:417
const std::shared_ptr< CALIBRATION > & sharedCalibration() const
return shared pointer to calibration
Definition PinholePose.h:364
const CALIBRATION & calibration() const override
return calibration
Definition PinholePose.h:369
Vector defaultErrorWhenTriangulatingBehindCamera() const
for Nonlinear Triangulation
Definition PinholePose.h:423
bool equals(const PinholePose &camera, double tol=1e-9) const
Compare with another camera of the same concrete type.
Definition PinholePose.h:332
static PinholePose Identity()
for Canonical
Definition PinholePose.h:412
Point2 project2(const Unit3 &pw, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 2 > Dpoint={}) const
project2 version for point at infinity
Definition PinholePose.h:384
PinholePose(const Vector &v, const Vector &K)
Init from Vector and calibration.
Definition PinholePose.h:312
GTSAM_EXPORT friend std::ostream & operator<<(std::ostream &os, const PinholePose &camera)
stream operator
Definition PinholePose.h:337
Point2 project2(const Point3 &pw, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 3 > Dpoint={}) const
project a point from world coordinate to the image, 2 derivatives only
Definition PinholePose.h:378
PinholePose(const Pose3 &pose, const std::shared_ptr< CALIBRATION > &K)
constructor with pose and calibration
Definition PinholePose.h:262
PinholePose retract(const Vector6 &d) const
move a cameras according to d
Definition PinholePose.h:402
static PinholePose Lookat(const Point3 &eye, const Point3 &target, const Point3 &upVector, const std::shared_ptr< CALIBRATION > &K=std::make_shared< CALIBRATION >())
Create a camera at the given eye position looking at a target point in the scene with the specified u...
Definition PinholePose.h:296
PinholePose(const Vector &v)
Init from 6D vector.
Definition PinholePose.h:307
static PinholePose Level(const std::shared_ptr< CALIBRATION > &K, const Pose2 &pose2, double height)
Create a level camera at the given 2D pose and height.
Definition PinholePose.h:277
bool equals(const Base &camera, double tol=1e-9) const
assert equality up to a tolerance
Definition PinholePose.h:326
void print(const std::string &s="PinholePose") const override
print
Definition PinholePose.h:348
PinholePose(const Pose3 &pose)
constructor with pose, uses default calibration
Definition PinholePose.h:257
static PinholePose Level(const Pose2 &pose2, double height)
PinholePose::level with default calibration.
Definition PinholePose.h:283
Vector6 localCoordinates(const PinholePose &p) const
return canonical coordinate
Definition PinholePose.h:407
static constexpr auto dimension
Definition PinholePose.h:247
A 2D pose (Point2,Rot2).
Definition Pose2.h:39
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
Point3 transformFrom(const Point3 &point, OptionalJacobian< 3, 6 > Hself={}, OptionalJacobian< 3, 3 > Hpoint={}) const
takes point in Pose coordinates and transforms it to world coordinates
Definition Pose3.cpp:180
double range(const Point3 &point, OptionalJacobian< 1, 6 > Hself={}, OptionalJacobian< 1, 3 > Hpoint={}) const
Calculate range to a landmark.
Definition Pose3.cpp:232
const Point3 & translation(OptionalJacobian< 3, 6 > Hself={}) const
get translation
Definition Pose3.cpp:158
Point3 rotate(const Point3 &p, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
rotate point from rotated coordinate frame to world
Definition Rot3M.cpp:165
Vector3 rpy(OptionalJacobian< 3, 3 > H={}) const
Use RQ to calculate roll-pitch-yaw angle representation.
Definition Rot3.cpp:200
Represents a 3D point on a unit sphere.
Definition Unit3.h:44