Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

ProjectionFactor

Open In Colab

GenericProjectionFactor<POSE, LANDMARK, CALIBRATION> is a versatile factor for monocular camera measurements. It models the reprojection error between the predicted projection of a 3D LANDMARK (usually Point3) onto the image plane of a camera defined by POSE (usually Pose3) and CALIBRATION (e.g., Cal3_S2, Cal3Bundler, Cal3DS2), and a measured 2D pixel coordinate measured_.

Key features:

  • Templated: Works with different pose, landmark, and calibration types.

  • Fixed Calibration: Assumes the CALIBRATION object (K_) is known and fixed (passed as a shared pointer).

  • Sensor Offset: Optionally handles a fixed body_P_sensor_ (Pose3) transform between the pose variable’s frame (body) and the camera’s sensor frame.

  • Cheirality Handling: Can be configured to throw an exception or return a large error if the landmark projects behind the camera.

The error is the 2D vector difference:

error(P,L)=project(P⋅S,L)−z\text{error}(P, L) = \text{project}(P \cdot S, L) - z

where PP is the pose variable, LL is the landmark variable, SS is the optional body_P_sensor transform, project is the camera projection function including calibration, and zz is the measured_ point.

Creating a GenericProjectionFactor

Instantiate by providing:

  1. The 2D measurement (Point2).

  2. The noise model (typically 2D isotropic).

  3. The key for the pose variable.

  4. The key for the landmark variable.

  5. A shared_ptr to the fixed calibration object.

  6. (Optional) The fixed Pose3 sensor offset body_P_sensor.

  7. (Optional) Cheirality handling flags.

Factor with offset: GenericProjectionFactor, z = [
	330;
	250
]
  sensor pose in body frame:  R: [
	6.12323e-17, 6.12323e-17, 1;
	-1, 3.7494e-33, 6.12323e-17;
	-0, -1, 6.12323e-17
]
t: 0.1   0 0.2
  keys = { x0 l1 }
  noise model: unit (2) 

Factor without offset: GenericProjectionFactor, z = [
	330;
	250
]
  keys = { x0 l1 }
  noise model: unit (2) 

Evaluating the Error

The error is the difference between the predicted projection and the measurement.

Error (no offset): 1175689.2145311693
Error (with offset): 50751.576015003826
Manual error calculation (no offset): [1370.63962025  687.55033305]