24 #include <boost/optional.hpp> 33 template<
class POSE,
class LANDMARK,
class CALIBRATION = Cal3_S2>
39 boost::shared_ptr<CALIBRATION>
K_;
72 Key poseKey,
Key transformKey,
Key pointKey,
73 const boost::shared_ptr<CALIBRATION>& K) :
89 Key poseKey,
Key transformKey,
Key pointKey,
90 const boost::shared_ptr<CALIBRATION>& K,
99 virtual NonlinearFactor::shared_ptr
clone()
const {
100 return boost::static_pointer_cast<NonlinearFactor>(
101 NonlinearFactor::shared_ptr(
new This(*
this))); }
108 void print(
const std::string& s =
"",
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
109 std::cout << s <<
"ProjectionFactorPPP, z = ";
116 const This *e = dynamic_cast<const This*>(&p);
120 && this->K_->equals(*e->K_, tol);
125 boost::optional<Matrix&> H1 = boost::none,
126 boost::optional<Matrix&> H2 = boost::none,
127 boost::optional<Matrix&> H3 = boost::none)
const {
132 Point2 reprojectionError(camera.project(point, H1, H3, boost::none) -
measured_);
135 return reprojectionError;
141 if (H1) *H1 = Matrix::Zero(2,6);
142 if (H2) *H2 = Matrix::Zero(2,6);
143 if (H3) *H3 = Matrix::Zero(2,3);
145 std::cout << e.what() <<
": Landmark "<< DefaultKeyFormatter(this->key2()) <<
146 " moved behind camera " << DefaultKeyFormatter(this->
key1()) << std::endl;
150 return Vector::Ones(2) * 2.0 *
K_->fx();
173 template<
class ARCHIVE>
174 void serialize(ARCHIVE & ar,
const unsigned int ) {
175 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
177 ar & BOOST_SERIALIZATION_NVP(
K_);
184 template<
class POSE,
class LANDMARK,
class CALIBRATION>
186 public Testable<ProjectionFactorPPP<POSE, LANDMARK, CALIBRATION> > {
virtual NonlinearFactor::shared_ptr clone() const
Definition: ProjectionFactorPPP.h:99
This is the base class for all factor types.
Definition: Factor.h:54
The most common 5DOF 3D->2D calibration.
Definition: PinholeCamera.h:33
const Point2 & measured() const
return the measurement
Definition: ProjectionFactorPPP.h:154
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print.
Definition: NonlinearFactor.cpp:63
boost::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition: ProjectionFactorPPP.h:54
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
bool verboseCheirality() const
return verbosity
Definition: ProjectionFactorPPP.h:164
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
ProjectionFactorPPP< POSE, LANDMARK, CALIBRATION > This
shorthand for this class
Definition: ProjectionFactorPPP.h:51
virtual ~ProjectionFactorPPP()
Virtual destructor.
Definition: ProjectionFactorPPP.h:96
Definition: ProjectionFactorPPP.h:34
Definition: CalibratedCamera.h:32
bool throwCheirality() const
return flag for throwing cheirality exceptions
Definition: ProjectionFactorPPP.h:167
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
Base class for all pinhole cameras.
Nonlinear factor base class.
Definition: NonlinearFactor.h:50
Point2 measured_
2D measurement
Definition: ProjectionFactorPPP.h:38
A convenient base class for creating your own NoiseModelFactor with 3 variables.
Definition: NonlinearFactor.h:420
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
Non-linear factor base classes.
ProjectionFactorPPP()
Default constructor.
Definition: ProjectionFactorPPP.h:57
boost::shared_ptr< CALIBRATION > K_
shared pointer to calibration object
Definition: ProjectionFactorPPP.h:39
bool verboseCheirality_
If true, prints text for Cheirality exceptions (default: false)
Definition: ProjectionFactorPPP.h:43
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Key key1() const
methods to retrieve keys
Definition: NonlinearFactor.h:454
ProjectionFactorPPP(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, const boost::shared_ptr< CALIBRATION > &K, bool throwCheirality, bool verboseCheirality)
Constructor with exception-handling flags TODO: Mark argument order standard (keys,...
Definition: ProjectionFactorPPP.h:88
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:1072
ProjectionFactorPPP(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, const boost::shared_ptr< CALIBRATION > &K)
Constructor TODO: Mark argument order standard (keys, measurement, parameters)
Definition: ProjectionFactorPPP.h:71
Point2 project(const Point3 &pw, OptionalJacobian< 2, 6 > Dpose=boost::none, OptionalJacobian< 2, 3 > Dpoint=boost::none, OptionalJacobian< 2, DimK > Dcal=boost::none) const
project a 3D point from world coordinates into the image
Definition: PinholePose.h:118
virtual bool equals(const NonlinearFactor &p, double tol=1e-9) const
equals
Definition: ProjectionFactorPPP.h:115
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: ProjectionFactorPPP.h:108
bool throwCheirality_
If true, rethrows Cheirality exceptions (default: false)
Definition: ProjectionFactorPPP.h:42
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: NonlinearFactor.cpp:71
const boost::shared_ptr< CALIBRATION > calibration() const
return the calibration object
Definition: ProjectionFactorPPP.h:159
NoiseModelFactor3< POSE, POSE, LANDMARK > Base
shorthand for base class type
Definition: ProjectionFactorPPP.h:48
friend class boost::serialization::access
Serialization function.
Definition: ProjectionFactorPPP.h:172
Vector evaluateError(const Pose3 &pose, const Pose3 &transform, const Point3 &point, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const
Evaluate error h(x)-z and optionally derivatives.
Definition: ProjectionFactorPPP.h:124