Skip to main content

CameraModel

Trait CameraModel 

Source
pub trait CameraModel:
    Send
    + Sync
    + Clone
    + Debug
    + 'static {
    type IntrinsicJacobian: Clone + Debug + Default + Index<(usize, usize), Output = f64>;
    type PointJacobian: Clone + Debug + Default + Mul<Matrix<f64, Const<3>, Const<6>, ArrayStorage<f64, 3, 6>>, Output = Matrix<f64, Const<2>, Const<6>, ArrayStorage<f64, 2, 6>>, Output = Matrix<f64, Const<2>, Const<3>, ArrayStorage<f64, 2, 3>>> + Mul<Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>> + Index<(usize, usize), Output = f64>;

    const INTRINSIC_DIM: usize;

    // Required methods
    fn project(
        &self,
        p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
    ) -> Result<Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>, CameraModelError>;
    fn unproject(
        &self,
        point_2d: &Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>,
    ) -> Result<Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, CameraModelError>;
    fn jacobian_point(
        &self,
        p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
    ) -> Self::PointJacobian;
    fn jacobian_intrinsics(
        &self,
        p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
    ) -> Self::IntrinsicJacobian;
    fn validate_params(&self) -> Result<(), CameraModelError>;
    fn get_pinhole_params(&self) -> PinholeParams;
    fn get_distortion(&self) -> DistortionModel;
    fn get_model_name(&self) -> &'static str;

    // Provided methods
    fn jacobian_pose(
        &self,
        p_world: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
        pose: &SE3,
    ) -> (Self::PointJacobian, Matrix<f64, Const<3>, Const<6>, ArrayStorage<f64, 3, 6>>) { ... }
    fn project_batch(
        &self,
        points_cam: &Matrix<f64, Const<3>, Dyn, VecStorage<f64, Const<3>, Dyn>>,
    ) -> Matrix<f64, Const<2>, Dyn, VecStorage<f64, Const<2>, Dyn>> { ... }
}
Expand description

Trait for camera projection models.

Defines the interface for camera models used in bundle adjustment and SfM.

§Type Parameters

  • INTRINSIC_DIM: Number of intrinsic parameters
  • IntrinsicJacobian: Jacobian type for intrinsics (2 × INTRINSIC_DIM)
  • PointJacobian: Jacobian type for 3D point (2 × 3)

Required Associated Constants§

Source

const INTRINSIC_DIM: usize

Number of intrinsic parameters (compile-time constant).

Required Associated Types§

Source

type IntrinsicJacobian: Clone + Debug + Default + Index<(usize, usize), Output = f64>

Jacobian type for intrinsics: 2 × INTRINSIC_DIM.

Source

type PointJacobian: Clone + Debug + Default + Mul<Matrix<f64, Const<3>, Const<6>, ArrayStorage<f64, 3, 6>>, Output = Matrix<f64, Const<2>, Const<6>, ArrayStorage<f64, 2, 6>>, Output = Matrix<f64, Const<2>, Const<3>, ArrayStorage<f64, 2, 3>>> + Mul<Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>> + Index<(usize, usize), Output = f64>

Jacobian type for 3D point: 2 × 3.

Required Methods§

Source

fn project( &self, p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, ) -> Result<Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>, CameraModelError>

Projects a 3D point in camera coordinates to 2D image coordinates. See the cookbook introduction for the projection pipeline, and the per-model page for the formula.

§Errors

Returns PointBehindCamera, PointAtCameraCenter, DenominatorTooSmall, or ProjectionOutOfBounds depending on the model.

Source

fn unproject( &self, point_2d: &Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>, ) -> Result<Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, CameraModelError>

Unprojects a 2D image point to a normalized 3D ray in camera frame. Some models use Newton-Raphson for undistortion. See the per-model cookbook page for the algorithm.

§Errors

Returns PointOutsideImage or NumericalError (e.g. when the iterative solver fails to converge).

Source

fn jacobian_point( &self, p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, ) -> Self::PointJacobian

∂(u,v)/∂(x,y,z) — 2×3 Jacobian of projection w.r.t. the 3D point. Used for structure optimisation, triangulation, and bundle adjustment. See the per-model cookbook page for the formula.

Source

fn jacobian_intrinsics( &self, p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, ) -> Self::IntrinsicJacobian

∂(u,v)/∂(params) — 2×N Jacobian of projection w.r.t. intrinsic parameters, where N = INTRINSIC_DIM. The parameter order is model-specific; see the per-model cookbook page.

Source

fn validate_params(&self) -> Result<(), CameraModelError>

Validates camera intrinsic and distortion parameters. The exact rules are model-specific; see the per-model cookbook page under “Validation Rules”.

Source

fn get_pinhole_params(&self) -> PinholeParams

Returns the linear intrinsics (f_x, f_y, c_x, c_y).

Source

fn get_distortion(&self) -> DistortionModel

Returns the distortion model and its parameters.

Source

fn get_model_name(&self) -> &'static str

Returns the camera model identifier ("pinhole", "rad_tan", …).

Provided Methods§

Source

fn jacobian_pose( &self, p_world: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, pose: &SE3, ) -> (Self::PointJacobian, Matrix<f64, Const<3>, Const<6>, ArrayStorage<f64, 3, 6>>)

∂(u,v)/∂(δξ) — 2×6 Jacobian of projection w.r.t. the camera pose.

The pose is a world-to-camera transform T_wc with right perturbation T' = T · Exp(δξ). Returns a pair (J_uv_pcam, J_pcam_pose) where the caller multiplies to get the full 2×6 Jacobian. See the cookbook introduction for the SE(3) conventions.

Source

fn project_batch( &self, points_cam: &Matrix<f64, Const<3>, Dyn, VecStorage<f64, Const<3>, Dyn>>, ) -> Matrix<f64, Const<2>, Dyn, VecStorage<f64, Const<2>, Dyn>>

Projects N 3D points in one call. Invalid projections are replaced by the sentinel (1e6, 1e6). Models may override with a vectorised implementation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CameraModel for BALPinholeCameraStrict

Source§

impl CameraModel for DoubleSphereCamera

Source§

impl CameraModel for EucmCamera

Source§

impl CameraModel for FThetaCamera

Source§

impl CameraModel for FovCamera

Source§

impl CameraModel for KannalaBrandtCamera

Source§

impl CameraModel for PinholeCamera

Source§

impl CameraModel for RadTanCamera

Source§

impl CameraModel for UcmCamera