Skip to main content

CameraModel

Trait CameraModel 

Source
pub trait CameraModel:
    Copy
    + Send
    + Sync
    + 'static {
    const IS_RECTIFIED: bool;

    // Required methods
    fn distort(&self, xn: f64, yn: f64) -> [f64; 2];
    fn undistort(&self, xd: f64, yd: f64) -> [f64; 2];
    fn distort_jacobian(&self, xn: f64, yn: f64) -> [[f64; 2]; 2];
}
Expand description

A compile-time abstraction over camera distortion models.

Monomorphizing on this trait allows the compiler to completely eliminate all distortion code when IS_RECTIFIED = true (e.g., for PinholeModel), leaving zero overhead for the common rectified-image case.

Required Associated Constants§

Source

const IS_RECTIFIED: bool

True iff the camera produces a rectified (undistorted) image.

When true, the compiler can statically prove that distort and undistort are identity functions and will eliminate all branches guarded by !C::IS_RECTIFIED.

Required Methods§

Source

fn distort(&self, xn: f64, yn: f64) -> [f64; 2]

Map normalized ideal (undistorted) coordinates (xn, yn) to normalized distorted coordinates (xd, yd).

Source

fn undistort(&self, xd: f64, yd: f64) -> [f64; 2]

Map normalized distorted (observed) coordinates (xd, yd) back to normalized ideal (undistorted) coordinates (xu, yu).

Source

fn distort_jacobian(&self, xn: f64, yn: f64) -> [[f64; 2]; 2]

Compute the 2×2 Jacobian of the distortion map at (xn, yn).

Returns [[∂xd/∂xn, ∂xd/∂yn], [∂yd/∂xn, ∂yd/∂yn]].

Used in the LM Jacobian to correctly account for distortion derivatives.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§