gtsam
Loading...
Searching...
No Matches
ProjectionFactorRollingShutter.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
17
18#pragma once
19
25#include <gtsam_unstable/dllexport.h>
26
27
28namespace gtsam {
29
43
44class GTSAM_UNSTABLE_EXPORT ProjectionFactorRollingShutter
45 : public NoiseModelFactorT<Vector2, Pose3, Pose3, Point3> {
46 protected:
47 // Keep a copy of measurement and calibration for I/O
49 double alpha_;
51 std::shared_ptr<Cal3_S2> K_;
52 std::optional<Pose3>
54
55 // verbosity handling for Cheirality Exceptions
60
61 public:
64
65 // Provide access to the Matrix& version of evaluateError:
67
68
71
73 typedef std::shared_ptr<This> shared_ptr;
74
81
96 const Point2& measured, double alpha, const SharedNoiseModel& model,
97 Key poseKey_a, Key poseKey_b, Key pointKey,
98 const std::shared_ptr<Cal3_S2>& K,
99 std::optional<Pose3> body_P_sensor = {})
100 : Base(model, poseKey_a, poseKey_b, pointKey),
101 measured_(measured),
102 alpha_(alpha),
103 K_(K),
104 body_P_sensor_(body_P_sensor),
105 throwCheirality_(false),
106 verboseCheirality_(false) {}
107
126 const Point2& measured, double alpha, const SharedNoiseModel& model,
127 Key poseKey_a, Key poseKey_b, Key pointKey,
128 const std::shared_ptr<Cal3_S2>& K, bool throwCheirality,
130 std::optional<Pose3> body_P_sensor = {})
131 : Base(model, poseKey_a, poseKey_b, pointKey),
132 measured_(measured),
133 alpha_(alpha),
134 K_(K),
135 body_P_sensor_(body_P_sensor),
136 throwCheirality_(throwCheirality),
137 verboseCheirality_(verboseCheirality) {}
138
141
143 gtsam::NonlinearFactor::shared_ptr clone() const override {
144 return std::static_pointer_cast<gtsam::NonlinearFactor>(
145 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
146 }
147
153 void print(
154 const std::string& s = "",
155 const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override {
156 std::cout << s << "ProjectionFactorRollingShutter, z = ";
158 std::cout << " rolling shutter interpolation param = " << alpha_;
159 if (this->body_P_sensor_)
160 this->body_P_sensor_->print(" sensor pose in body frame: ");
161 Base::print("", keyFormatter);
162 }
163
165 bool equals(const NonlinearFactor& p, double tol = 1e-9) const override {
166 const This* e = dynamic_cast<const This*>(&p);
167 return e && Base::equals(p, tol) && (alpha_ == e->alpha()) &&
168 traits<Point2>::Equals(this->measured_, e->measured_, tol) &&
169 this->K_->equals(*e->K_, tol) &&
170 (this->throwCheirality_ == e->throwCheirality_) &&
171 (this->verboseCheirality_ == e->verboseCheirality_) &&
172 ((!body_P_sensor_ && !e->body_P_sensor_) ||
174 body_P_sensor_->equals(*e->body_P_sensor_)));
175 }
176
178 Vector2 evaluateError(
179 const Pose3& pose_a, const Pose3& pose_b, const Point3& point,
181
183 const Point2& measured() const { return measured_; }
184
186 inline const std::shared_ptr<Cal3_S2> calibration() const { return K_; }
187
189 inline double alpha() const { return alpha_; }
190
192 inline bool verboseCheirality() const { return verboseCheirality_; }
193
195 inline bool throwCheirality() const { return throwCheirality_; }
196
197 private:
198#if GTSAM_ENABLE_BOOST_SERIALIZATION
200 friend class boost::serialization::access;
201 template <class ARCHIVE>
202 void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
203 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
204 ar& BOOST_SERIALIZATION_NVP(measured_);
205 ar& BOOST_SERIALIZATION_NVP(alpha_);
206 ar& BOOST_SERIALIZATION_NVP(K_);
207 ar& BOOST_SERIALIZATION_NVP(body_P_sensor_);
208 ar& BOOST_SERIALIZATION_NVP(throwCheirality_);
209 ar& BOOST_SERIALIZATION_NVP(verboseCheirality_);
210 }
211#endif
212};
213
215template <>
217 : public Testable<ProjectionFactorRollingShutter> {};
218
219} // namespace gtsam
The most common 5DOF 3D->2D calibration.
Calibrated camera for which only pose is unknown.
Base class for all pinhole cameras.
Base class for noise model factors with N variables.
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
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
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
virtual void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition Factor.cpp:29
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector2 evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Nonlinear factor base class.
Definition NonlinearFactor.h:70
Non-linear factor for 2D projection measurement obtained using a rolling shutter camera.
Definition ProjectionFactorRollingShutter.h:45
ProjectionFactorRollingShutter(const Point2 &measured, double alpha, const SharedNoiseModel &model, Key poseKey_a, Key poseKey_b, Key pointKey, const std::shared_ptr< Cal3_S2 > &K, std::optional< Pose3 > body_P_sensor={})
Constructor.
Definition ProjectionFactorRollingShutter.h:95
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition ProjectionFactorRollingShutter.h:153
bool throwCheirality() const
return flag for throwing cheirality exceptions
Definition ProjectionFactorRollingShutter.h:195
const Point2 & measured() const
return the measurement
Definition ProjectionFactorRollingShutter.h:183
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition ProjectionFactorRollingShutter.h:143
ProjectionFactorRollingShutter(const Point2 &measured, double alpha, const SharedNoiseModel &model, Key poseKey_a, Key poseKey_b, Key pointKey, const std::shared_ptr< Cal3_S2 > &K, bool throwCheirality, bool verboseCheirality, std::optional< Pose3 > body_P_sensor={})
Constructor with exception-handling flags.
Definition ProjectionFactorRollingShutter.h:125
ProjectionFactorRollingShutter This
shorthand for this class
Definition ProjectionFactorRollingShutter.h:70
bool verboseCheirality() const
return verbosity
Definition ProjectionFactorRollingShutter.h:192
ProjectionFactorRollingShutter()
Default constructor.
Definition ProjectionFactorRollingShutter.h:76
double alpha() const
returns the rolling shutter interp param
Definition ProjectionFactorRollingShutter.h:189
Point2 measured_
2D measurement
Definition ProjectionFactorRollingShutter.h:48
std::shared_ptr< Cal3_S2 > K_
shared pointer to calibration object
Definition ProjectionFactorRollingShutter.h:51
double alpha_
interpolation parameter in [0,1] corresponding to the point2 measurement
Definition ProjectionFactorRollingShutter.h:49
std::optional< Pose3 > body_P_sensor_
The pose of the sensor in the body frame.
Definition ProjectionFactorRollingShutter.h:53
NoiseModelFactorT< Vector2, Pose3, Pose3, Point3 > Base
shorthand for base class type
Definition ProjectionFactorRollingShutter.h:63
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition ProjectionFactorRollingShutter.h:73
bool throwCheirality_
If true, rethrows Cheirality exceptions (default: false).
Definition ProjectionFactorRollingShutter.h:56
virtual ~ProjectionFactorRollingShutter()
Virtual destructor.
Definition ProjectionFactorRollingShutter.h:140
const std::shared_ptr< Cal3_S2 > calibration() const
return the calibration object
Definition ProjectionFactorRollingShutter.h:186
bool verboseCheirality_
If true, prints text for Cheirality exceptions (default: false).
Definition ProjectionFactorRollingShutter.h:58
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Definition ProjectionFactorRollingShutter.h:165