gtsam
Loading...
Searching...
No Matches
gtsam::SmartProjectionFactor< CAMERA > Class Template Reference

Detailed Description

template<class CAMERA>
class gtsam::SmartProjectionFactor< CAMERA >

Smart factor for monocular cameras whose pose and calibration are variables.

Values must contain the involved cameras. When calibration is fixed, use SmartProjectionPoseFactor instead.

Inheritance diagram for gtsam::SmartProjectionFactor< CAMERA >:

Public Member Functions

 SmartProjectionFactor ()=default
 Default constructor, only for serialization.
 SmartProjectionFactor (const SharedNoiseModel &sharedNoiseModel, const SmartProjectionParams &params=SmartProjectionParams())
 Construct from an isotropic measurement noise model and parameters.
bool equals (const NonlinearFactor &factor, double tol=1e-9) const override
 Compare with another camera-variable smart projection factor.
Public Member Functions inherited from gtsam::SmartProjectionFactorBase< CAMERA >
 SmartProjectionFactorBase ()
 Default constructor, only for serialization.
 SmartProjectionFactorBase (const SharedNoiseModel &sharedNoiseModel, const SmartProjectionParams &params=SmartProjectionParams())
 Constructor.
 ~SmartProjectionFactorBase () override
 Virtual destructor.
void print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
 print
bool equals (const NonlinearFactor &p, double tol=1e-9) const override
 equals
bool decideIfTriangulate (const Cameras &cameras) const
 Check if the new linearization point is the same as the one used for previous triangulation.
TriangulationResult triangulateSafe (const Cameras &cameras) const
 Call gtsam::triangulateSafe iff we need to re-triangulate.
bool triangulateForLinearize (const Cameras &cameras) const
 Possibly re-triangulate before calculating Jacobians.
std::shared_ptr< RegularHessianFactor< Base::Dim > > createHessianFactor (const Cameras &cameras, const double _lambda=0.0, bool diagonalDamping=false) const
 Create a Hessianfactor that is an approximation of error(p).
std::shared_ptr< RegularImplicitSchurFactor< CAMERA > > createRegularImplicitSchurFactor (const Cameras &cameras, double _lambda) const
std::shared_ptr< JacobianFactorQ< Base::Dim, 2 > > createJacobianQFactor (const Cameras &cameras, double _lambda) const
 Create JacobianFactorQ factor.
std::shared_ptr< JacobianFactorQ< Base::Dim, 2 > > createJacobianQFactor (const Values &values, double _lambda) const
 Create JacobianFactorQ factor, takes values.
std::shared_ptr< JacobianFactorcreateJacobianSVDFactor (const Cameras &cameras, double _lambda) const
 Different (faster) way to compute a JacobianFactorSVD factor.
virtual std::shared_ptr< RegularHessianFactor< Base::Dim > > linearizeToHessian (const Values &values, double _lambda=0.0) const
 Linearize to a Hessianfactor.
virtual std::shared_ptr< RegularImplicitSchurFactor< CAMERA > > linearizeToImplicit (const Values &values, double _lambda=0.0) const
 Linearize to an Implicit Schur factor.
virtual std::shared_ptr< JacobianFactorQ< Base::Dim, 2 > > linearizeToJacobian (const Values &values, double _lambda=0.0) const
 Linearize to a JacobianfactorQ.
std::shared_ptr< GaussianFactor > linearizeDamped (const Cameras &cameras, const double _lambda=0.0) const
 Linearize to Gaussian Factor.
std::shared_ptr< GaussianFactor > linearizeDamped (const Values &values, const double _lambda=0.0) const
 Linearize to Gaussian Factor.
std::shared_ptr< GaussianFactor > linearize (const Values &values) const override
 linearize
bool triangulateAndComputeE (Matrix &E, const Cameras &cameras) const
 Triangulate and compute derivative of error with respect to point.
bool triangulateAndComputeE (Matrix &E, const Values &values) const
 Triangulate and compute derivative of error with respect to point.
void computeJacobiansWithTriangulatedPoint (typename Base::FBlocks &Fs, Matrix &E, Vector &b, const Cameras &cameras) const
 Compute F, E only (called below in both vanilla and SVD versions) Assumes the point has been computed Note E can be 2m*3 or 2m*2, in case point is degenerate.
bool triangulateAndComputeJacobians (typename Base::FBlocks &Fs, Matrix &E, Vector &b, const Values &values) const
 Version that takes values, and creates the point.
bool triangulateAndComputeJacobiansSVD (typename Base::FBlocks &Fs, Matrix &Enull, Vector &b, const Values &values) const
 takes values
Vector reprojectionErrorAfterTriangulation (const Values &values) const
 Calculate vector of re-projection errors, before applying noise model.
double totalReprojectionError (const Cameras &cameras, std::optional< Point3 > externalPoint={}) const
 Calculate the error of the factor.
double error (const Values &values) const override
 Calculate total reprojection error.
TriangulationResult point () const
 return the landmark
TriangulationResult point (const Values &values) const
 COMPUTE the landmark.
bool isValid () const
 Is result valid?
bool isDegenerate () const
 return the degenerate state
bool isPointBehindCamera () const
 return the cheirality status flag
bool isOutlier () const
 return the outlier state
bool isFarPoint () const
 return the farPoint state
Public Member Functions inherited from gtsam::SmartFactorBase< CAMERA >
 SmartFactorBase ()
 Default Constructor, for serialization.
 SmartFactorBase (const SharedNoiseModel &sharedNoiseModel, std::optional< Pose3 > body_P_sensor={}, size_t expectedNumberCameras=10)
 Construct with given noise model and optional arguments.
 ~SmartFactorBase () override
 Virtual destructor, subclasses from NonlinearFactor.
void add (const Z &measured, const Key &key)
 Add a new measurement and pose/camera key.
void add (const ZVector &measurements, const KeyVector &cameraKeys)
 Add a bunch of measurements, together with the camera keys.
template<class SFM_TRACK>
void add (const SFM_TRACK &trackToAdd)
 Add an entire SfM_track (collection of cameras observing a single point).
size_t dim () const override
 Return the dimension (number of rows!) of the factor.
const ZVector & measured () const
 Return the 2D measurements (ZDim, in general).
virtual Cameras cameras (const Values &values) const
 Collect all cameras: important that in key order.
template<class POINT>
Vector unwhitenedError (const Cameras &cameras, const POINT &point, typename Cameras::FBlocks *Fs=nullptr, Matrix *E=nullptr) const
 Compute reprojection errors [h(x)-z] = [cameras.project(p)-z] and derivatives.
template<class POINT, class ... OptArgs, typename = std::enable_if_t<sizeof...(OptArgs)!=0>>
Vector unwhitenedError (const Cameras &cameras, const POINT &point, OptArgs &&... optArgs) const
 An overload of unwhitenedError.
virtual void correctForMissingMeasurements (const Cameras &cameras, Vector &ue, typename Cameras::FBlocks *Fs=nullptr, Matrix *E=nullptr) const
 This corrects the Jacobians for the case in which some 2D measurement is missing (nan).
template<class ... OptArgs>
void correctForMissingMeasurements (const Cameras &cameras, Vector &ue, OptArgs &&... optArgs) const
 An overload of correctForMissingMeasurements.
template<class POINT>
Vector whitenedError (const Cameras &cameras, const POINT &point) const
 Calculate vector of re-projection errors [h(x)-z] = [cameras.project(p) - z], with the noise model applied.
template<class POINT>
double totalReprojectionError (const Cameras &cameras, const POINT &point) const
 Calculate the error of the factor.
template<class POINT>
void computeJacobians (FBlocks &Fs, Matrix &E, Vector &b, const Cameras &cameras, const POINT &point) const
 Compute F, E, and b (called below in both vanilla and SVD versions), where F is a vector of derivatives wrpt the cameras, and E the stacked derivatives with respect to the point.
template<class POINT>
void computeJacobiansSVD (FBlocks &Fs, Matrix &Enull, Vector &b, const Cameras &cameras, const POINT &point) const
 SVD version that produces smaller Jacobian matrices by doing an SVD decomposition on E, and returning the left nulkl-space of E.
std::shared_ptr< RegularHessianFactor< Dim > > createHessianFactor (const Cameras &cameras, const Point3 &point, const double lambda=0.0, bool diagonalDamping=false) const
 Linearize to a Hessianfactor.
void updateAugmentedHessian (const Cameras &cameras, const Point3 &point, const double lambda, bool diagonalDamping, SymmetricBlockMatrix &augmentedHessian, const KeyVector allKeys) const
 Add the contribution of the smart factor to a pre-allocated Hessian, using sparse linear algebra.
void whitenJacobians (FBlocks &F, Matrix &E, Vector &b) const
 Whiten the Jacobians computed by computeJacobians using noiseModel_.
std::shared_ptr< RegularImplicitSchurFactor< CAMERA > > createRegularImplicitSchurFactor (const Cameras &cameras, const Point3 &point, double lambda=0.0, bool diagonalDamping=false) const
 Return Jacobians as RegularImplicitSchurFactor with raw access.
std::shared_ptr< JacobianFactorQ< Dim, ZDim > > createJacobianQFactor (const Cameras &cameras, const Point3 &point, double lambda=0.0, bool diagonalDamping=false) const
 Return Jacobians as JacobianFactorQ.
std::shared_ptr< JacobianFactorcreateJacobianSVDFactor (const Cameras &cameras, const Point3 &point, double lambda=0.0) const
 Return Jacobians as JacobianFactorSVD.
Pose3 body_P_sensor () const
 NonlinearFactor ()
 Default constructor for I/O only.
template<typename CONTAINER>
 NonlinearFactor (const CONTAINER &keys)
 Constructor from a collection of the keys involved in this factor.
double error (const HybridValues &c) const override
 All factor types need to implement an error function.
virtual bool active (const Values &c) const
 Checks whether a factor should be used based on a set of values.
virtual void qcqpFactors (NonlinearFactorGraph *costs, NonlinearEqualityConstraints *constraints, size_t columnDimension=1) const
 Add this factor's QCQP cost and constraints over matrix-valued QCQP variables with the given column dimension.
virtual shared_ptr clone () const
 Creates a shared_ptr clone of the factor - needs to be specialized to allow for subclasses.
virtual shared_ptr rekey (const std::map< Key, Key > &rekey_mapping) const
 Creates a shared_ptr clone of the factor with different keys using a map from old->new keys.
virtual shared_ptr rekey (const KeyVector &new_keys) const
 Clones a factor and fully replaces its keys.
virtual bool sendable () const
 Should the factor be evaluated in the same thread as the caller This is to enable factors that has shared states (like the Python GIL lock).
Public Member Functions inherited from gtsam::Factor
virtual ~Factor ()=default
 Default destructor.
bool empty () const
 Whether the factor is empty (involves zero variables).
Key front () const
 First key.
Key back () const
 Last key.
const_iterator find (Key key) const
 find
const KeyVectorkeys () const
 Access the factor's involved variable keys.
const_iterator begin () const
 Iterator at beginning of involved variable keys.
const_iterator end () const
 Iterator at end of involved variable keys.
size_t size () const
virtual void printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print only keys
bool equals (const This &other, double tol=1e-9) const
 check equality
KeyVectorkeys ()
iterator begin ()
 Iterator at beginning of involved variable keys.
iterator end ()
 Iterator at end of involved variable keys.

Public Types

using shared_ptr = std::shared_ptr<This>
 Shorthand for a smart pointer to this factor.
Public Types inherited from gtsam::SmartProjectionFactorBase< CAMERA >
typedef std::shared_ptr< This > shared_ptr
 Shorthand for a smart pointer to a factor.
typedef CAMERA Camera
 Shorthand for a set of cameras.
typedef CameraSet< CAMERA > Cameras
using HessianFactorType = RegularHessianFactor<Base::Dim>
 Exact linear-factor types produced by this camera specialization.
using JacobianFactorType = JacobianFactorQ<Base::Dim, 2>
using SharedHessianFactor = std::shared_ptr<HessianFactorType>
using SharedJacobianFactor = std::shared_ptr<JacobianFactorType>
Public Types inherited from gtsam::SmartFactorBase< CAMERA >
typedef Eigen::Matrix< double, ZDim, DimMatrixZD
typedef std::vector< MatrixZD, Eigen::aligned_allocator< MatrixZD > > FBlocks
typedef std::shared_ptr< This > shared_ptr
 shorthand for a smart pointer to a factor.
typedef CameraSet< CAMERA > Cameras
 The CameraSet data structure is used to refer to a set of cameras.
Public Types inherited from gtsam::NonlinearFactor
typedef std::shared_ptr< This > shared_ptr
Public Types inherited from gtsam::Factor
typedef KeyVector::iterator iterator
 Iterator over keys.
typedef KeyVector::const_iterator const_iterator
 Const iterator over keys.

Additional Inherited Members

Static Public Member Functions inherited from gtsam::SmartFactorBase< CAMERA >
static Matrix PointCov (const Matrix &E)
 Computes Point Covariance P from the "point Jacobian" E.
static void FillDiagonalF (const FBlocks &Fs, Matrix &F)
 Create BIG block-diagonal matrix F from Fblocks.
Static Public Attributes inherited from gtsam::SmartFactorBase< CAMERA >
static const int Dim = traits<CAMERA>::dimension
 Camera dimension.
static const int ZDim = traits<Z>::dimension
 Measurement dimension.
Protected Types inherited from gtsam::NonlinearFactor
typedef Factor Base
typedef NonlinearFactor This
 Factor ()
 Default constructor for I/O.
template<typename CONTAINER>
 Factor (const CONTAINER &keys)
 Construct factor from container of keys.
template<typename ITERATOR>
 Factor (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys.
template<typename CONTAINER>
static Factor FromKeys (const CONTAINER &keys)
 Construct factor from container of keys.
template<typename ITERATOR>
static Factor FromIterators (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys.
Protected Attributes inherited from gtsam::SmartProjectionFactorBase< CAMERA >
SmartProjectionParams params_
TriangulationResult result_
 result from triangulateSafe
std::vector< Pose3, Eigen::aligned_allocator< Pose3 > > cameraPosesTriangulation_
 current triangulation poses
Protected Attributes inherited from gtsam::SmartFactorBase< CAMERA >
SharedIsotropic noiseModel_
 As of Feb 22, 2015, the noise model is the same for all measurements and is isotropic.
ZVector measured_
 Measurements for each of the m views.
std::optional< Pose3body_P_sensor_
 Pose of the camera in the body frame.
FBlocks Fs
Protected Attributes inherited from gtsam::Factor
KeyVector keys_
 The keys involved in this factor.

Member Function Documentation

◆ equals()

template<class CAMERA>
bool gtsam::SmartProjectionFactor< CAMERA >::equals ( const NonlinearFactor & factor,
double tol = 1e-9 ) const
inlineoverridevirtual

Compare with another camera-variable smart projection factor.

Reimplemented from gtsam::SmartFactorBase< CAMERA >.

Reimplemented in gtsam::SmartProjectionPoseFactorRollingShutter< CAMERA >, and gtsam::SmartProjectionRigFactor< CAMERA >.


The documentation for this class was generated from the following file: