Template Class ProjectionFactor

Inheritance Relationships

Base Type

  • public gtsam::NoiseModelFactor2< TransformationType, gtsam::Point3 >

Class Documentation

template<typename TransformationType>
class ProjectionFactor : public gtsam::NoiseModelFactor2<TransformationType, gtsam::Point3>

Class for a factor representing the reprojection of a 3D point onto a 2D image plane using camera intrinsics.

This factor constrains a 3D point and a camera pose by measuring the difference between the observed 2D pixel coordinates and the projected coordinates of the 3D point onto the image plane using the camera model.

Template Parameters:

TransformationType – The type representing the camera pose (e.g., gtsam::Pose3, gtsam::Similarity3).

Public Types

using Base = gtsam::NoiseModelFactor2<TransformationType, gtsam::Point3>

Typedef for the base gtsam class.

using ProjectionFactorTyped = ProjectionFactor<TransformationType>

Typed alias for the ProjectionFactor class template.

using shared_ptr = std::shared_ptr<ProjectionFactorTyped>

Typedef for a std::shared_ptr of a ProjectionFactor.

Public Functions

inline ProjectionFactor(const keyframe_id_t keyframeId_, const point_id_t pointId_, const gtsam::Cal3_S2::shared_ptr &intrinsics_, gtsam::Point2 measured_, const gtsam::SharedNoiseModel &noiseModel_)

Construct a ProjectionFactor object.

Parameters:
  • keyframeId_ – ID of the keyframe where the keypoint was detected.

  • pointId_ – ID of the map point associated with the measurement.

  • intrinsics_ – The camera calibration (intrinsics).

  • measured_ – The keypoint pixel coordinates.

  • noiseModel_ – The noise model for the factor.

inline ProjectionFactor(const ProjectionFactor::shared_ptr &other_, const keyframe_id_t keyframeId_, const point_id_t pointId_)

Construct a ProjectionFactor object from a previously existing factor. It basically copies everything from the input factor, and updates the keys for the keyframe and point.

Parameters:
  • other_ – The factor to copy from.

  • keyframeId_ – The new keyframe ID.

  • pointId_ – The new map point ID.

inline void set_calibration(gtsam::Cal3_S2::shared_ptr intrinsics_)

Sets the calibration for be used by the factor.

Parameters:

intrinsics_ – camera intrinsics.

inline bool has_calibration() const

Checks if the factor has a calibration.

Returns:

true if calibration is set, false otherwise.

inline gtsam::Key get_key() const

Gets the gtsam::Key for the map point associated with this factor.

Returns:

Key of the map point associated with this factor.

inline gtsam::Vector evaluateError(const TransformationType &pose_, const gtsam::Point3 &point_, gtsam::OptionalMatrixType H1_, gtsam::OptionalMatrixType H2_) const override

Projection error evaluation function. This is the function that computes the reprojection error between the observed 2D point and the projected 3D point that is used inside gtsam optimization steps.

Parameters:
  • pose_ – The camera pose.

  • point_ – The 3D point in the world.

  • H1_ – Optional Jacobian with respect to the pose.

  • H2_ – Optional Jacobian with respect to the point.

Returns:

The reprojection error vector.

Public Members

gtsam::Point2 _measured

Observed 2D pixel coordinates (measurement)

gtsam::Cal3_S2::shared_ptr _intrinsics

Camera intrinsics.

Public Static Functions

static inline shared_ptr make_shared(const keyframe_id_t keyframeId_, const point_id_t pointId_, const gtsam::Cal3_S2::shared_ptr &intrinsics_, gtsam::Point2 measured_, const gtsam::SharedNoiseModel &noiseModel_)

Create a shared projection factor.

Parameters:
  • keyframeId_ – Keyframe ID associated with the observation.

  • pointId_ – Point ID associated with the observation.

  • intrinsics_ – Camera intrinsics used for reprojection.

  • measured_ – Measured 2D keypoint coordinates.

  • noiseModel_ – Noise model used for this factor.

Returns:

Shared pointer owning the created projection factor.

static inline shared_ptr make_shared(const ProjectionFactor::shared_ptr &other_, const keyframe_id_t keyframeId_, const point_id_t pointId_)

Make an object for a shared pointer for a ProjectionFactor from a previously existing factor.

Parameters:
  • other_ – The factor to copy from.

  • keyframeId_ – The new keyframe ID.

  • pointId_ – The new map point ID.

Returns:

Shared pointer owning the cloned projection factor.

Public Static Attributes

static const shared_ptr EMPTY = nullptr

A static empty pointer for ProjectionFactor, useful for initialization.