37 template <
class CAMERA,
class LANDMARK>
50 typedef boost::shared_ptr<This> shared_ptr;
69 virtual gtsam::NonlinearFactor::shared_ptr
clone()
const {
71 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
78 void print(
const std::string& s =
"SFMFactor",
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
87 const This* e =
dynamic_cast<const This*
>(&p);
93 boost::optional<Matrix&> H1=boost::none, boost::optional<Matrix&> H2=boost::none)
const {
97 return reprojError.
vector();
100 if (H1) *H1 =
zeros(2, camera.dim());
101 if (H2) *H2 =
zeros(2, point.
dim());
102 std::cout << e.what() <<
": Landmark "<< DefaultKeyFormatter(this->key2())
103 <<
" behind Camera " << DefaultKeyFormatter(this->
key1()) << std::endl;
116 template<
class Archive>
117 void serialize(Archive & ar,
const unsigned int version) {
118 ar & boost::serialization::make_nvp(
"NoiseModelFactor2",
119 boost::serialization::base_object<Base>(*
this));
128 template <
class CALIBRATION>
141 typedef boost::shared_ptr<This> shared_ptr;
152 Base(model, poseKey, landmarkKey, calibKey),
measured_(measured) {}
158 virtual gtsam::NonlinearFactor::shared_ptr
clone()
const {
160 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
167 void print(
const std::string& s =
"SFMFactor2",
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
176 const This* e =
dynamic_cast<const This*
>(&p);
182 boost::optional<Matrix&> H1=boost::none,
183 boost::optional<Matrix&> H2=boost::none,
184 boost::optional<Matrix&> H3=boost::none)
const
187 Camera camera(pose3,calib);
189 return reprojError.
vector();
192 if (H1) *H1 =
zeros(2, pose3.
dim());
193 if (H2) *H2 =
zeros(2, point.
dim());
194 if (H3) *H3 =
zeros(2, calib.dim());
195 std::cout << e.what() <<
": Landmark "<< DefaultKeyFormatter(this->key2())
196 <<
" behind Camera " << DefaultKeyFormatter(this->
key1()) << std::endl;
209 template<
class Archive>
210 void serialize(Archive & ar,
const unsigned int version) {
211 ar & boost::serialization::make_nvp(
"NoiseModelFactor3",
212 boost::serialization::base_object<Base>(*
this));
Non-linear factor base classes.
GeneralSFMFactor()
default constructor
Definition: GeneralSFMFactor.h:62
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: NonlinearFactor.h:239
PinholeCamera< CALIBRATION > Camera
typedef for camera type
Definition: GeneralSFMFactor.h:136
virtual ~GeneralSFMFactor()
destructor
Definition: GeneralSFMFactor.h:66
Point2 Measurement
typedef for the measurement
Definition: GeneralSFMFactor.h:138
void print(const std::string &s="") const
print with optional string
Definition: Point2.cpp:33
Definition: GeneralSFMFactor.h:38
virtual gtsam::NonlinearFactor::shared_ptr clone() const
Definition: GeneralSFMFactor.h:69
NoiseModelFactor3< Pose3, Point3, CALIBRATION > Base
typedef for the base class
Definition: GeneralSFMFactor.h:137
Vector evaluateError(const Pose3 &pose3, const Point3 &point, const CALIBRATION &calib, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const
h(x)-z
Definition: GeneralSFMFactor.h:181
const Point2 measured() const
return the measured
Definition: GeneralSFMFactor.h:202
virtual gtsam::NonlinearFactor::shared_ptr clone() const
Definition: GeneralSFMFactor.h:158
bool equals(const Point2 &q, double tol=1e-9) const
equals with an tolerance, prints out message if unequal
Definition: Point2.cpp:38
Vector evaluateError(const Cam &camera, const Point3 &point, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
h(x)-z
Definition: GeneralSFMFactor.h:92
Point2 project(const Point3 &pw, boost::optional< Matrix & > Dpose=boost::none, boost::optional< Matrix & > Dpoint=boost::none, boost::optional< Matrix & > Dcal=boost::none) const
project a point from world coordinate to the image
Definition: PinholeCamera.h:299
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:423
GeneralSFMFactor(const Point2 &measured, const SharedNoiseModel &model, Key cameraKey, Key landmarkKey)
Constructor.
Definition: GeneralSFMFactor.h:59
This is the base class for all factor types.
Definition: Factor.h:51
friend class boost::serialization::access
Serialization function.
Definition: GeneralSFMFactor.h:115
Vector2 vector() const
return vectorized form (column-wise). TODO: why does this function exist?
Definition: Point2.h:216
Point2 Measurement
typedef for the measurement
Definition: GeneralSFMFactor.h:47
void print(const std::string &s="SFMFactor", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: GeneralSFMFactor.h:78
Base class for all pinhole cameras.
bool zero(const Vector &v)
check if all zero
Definition: Vector.cpp:39
void print(const std::string &s="SFMFactor2", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: GeneralSFMFactor.h:167
Point2 measured_
the 2D measurement
Definition: GeneralSFMFactor.h:131
Definition: PinholeCamera.h:40
GeneralSFMFactor2()
default constructor
Definition: GeneralSFMFactor.h:153
GeneralSFMFactor(double x, double y)
constructor that takes doubles x,y to make a Point2
Definition: GeneralSFMFactor.h:64
GeneralSFMFactor2(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key landmarkKey, Key calibKey)
Constructor.
Definition: GeneralSFMFactor.h:151
Key key1() const
methods to retrieve both keys
Definition: NonlinearFactor.h:455
GeneralSFMFactor(const Point2 &p)
constructor that takes a Point2
Definition: GeneralSFMFactor.h:63
Definition: CalibratedCamera.h:27
size_t Key
Integer nonlinear key type.
Definition: types.h:59
bool equals(const NonlinearFactor &p, double tol=1e-9) const
equals
Definition: GeneralSFMFactor.h:175
Calibrated camera for which only pose is unknown.
Key key1() const
methods to retrieve keys
Definition: NonlinearFactor.h:532
Point2 measured_
the 2D measurement
Definition: GeneralSFMFactor.h:40
friend class boost::serialization::access
Serialization function.
Definition: GeneralSFMFactor.h:208
bool equals(const NonlinearFactor &p, double tol=1e-9) const
equals
Definition: GeneralSFMFactor.h:86
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print.
Definition: NonlinearFactor.h:231
CAMERA Cam
typedef for camera type
Definition: GeneralSFMFactor.h:44
virtual ~GeneralSFMFactor2()
destructor
Definition: GeneralSFMFactor.h:155
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:884
Nonlinear factor base class.
Definition: NonlinearFactor.h:54
Non-linear factor for a constraint derived from a 2D measurement.
Definition: GeneralSFMFactor.h:129
NoiseModelFactor2< CAMERA, LANDMARK > Base
typedef for the base class
Definition: GeneralSFMFactor.h:46
size_t dim() const
Dimensionality of the tangent space = 6 DOF.
Definition: Pose3.h:139
GeneralSFMFactor< CAMERA, LANDMARK > This
typedef for this object
Definition: GeneralSFMFactor.h:45
Matrix zeros(size_t m, size_t n)
Creates an zeros matrix, with matlab-like syntax.
Definition: Matrix.cpp:40
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62
size_t dim() const
return dimensionality of tangent space, DOF = 3
Definition: Point3.h:128
const Point2 measured() const
return the measured
Definition: GeneralSFMFactor.h:109
A convenient base class for creating your own NoiseModelFactor with 3 variables.
Definition: NonlinearFactor.h:498