pub trait CameraModel:
Send
+ Sync
+ Clone
+ Debug
+ 'static {
type IntrinsicJacobian: Clone + Debug + Default + Index<(usize, usize), Output = f64>;
type PointJacobian: Clone + Debug + Default + Mul<SMatrix<f64, 3, 6>, Output = SMatrix<f64, 2, 6>> + Mul<Matrix3<f64>, Output = SMatrix<f64, 2, 3>> + Index<(usize, usize), Output = f64>;
const INTRINSIC_DIM: usize;
// Required methods
fn project(
&self,
p_cam: &Vector3<f64>,
) -> Result<Vector2<f64>, CameraModelError>;
fn unproject(
&self,
point_2d: &Vector2<f64>,
) -> Result<Vector3<f64>, CameraModelError>;
fn jacobian_point(&self, p_cam: &Vector3<f64>) -> Self::PointJacobian;
fn jacobian_intrinsics(
&self,
p_cam: &Vector3<f64>,
) -> 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: &Vector3<f64>,
pose: &SE3,
) -> (Self::PointJacobian, SMatrix<f64, 3, 6>) { ... }
fn project_batch(&self, points_cam: &Matrix3xX<f64>) -> Matrix2xX<f64> { ... }
}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 parametersIntrinsicJacobian: Jacobian type for intrinsics (2 × INTRINSIC_DIM)PointJacobian: Jacobian type for 3D point (2 × 3)
Required Associated Constants§
Sourceconst INTRINSIC_DIM: usize
const INTRINSIC_DIM: usize
Number of intrinsic parameters (compile-time constant).
Required Associated Types§
Required Methods§
Sourcefn project(
&self,
p_cam: &Vector3<f64>,
) -> Result<Vector2<f64>, CameraModelError>
fn project( &self, p_cam: &Vector3<f64>, ) -> Result<Vector2<f64>, 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.
Sourcefn unproject(
&self,
point_2d: &Vector2<f64>,
) -> Result<Vector3<f64>, CameraModelError>
fn unproject( &self, point_2d: &Vector2<f64>, ) -> Result<Vector3<f64>, 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).
Sourcefn jacobian_point(&self, p_cam: &Vector3<f64>) -> Self::PointJacobian
fn jacobian_point(&self, p_cam: &Vector3<f64>) -> 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.
Sourcefn jacobian_intrinsics(&self, p_cam: &Vector3<f64>) -> Self::IntrinsicJacobian
fn jacobian_intrinsics(&self, p_cam: &Vector3<f64>) -> 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.
Sourcefn validate_params(&self) -> Result<(), CameraModelError>
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”.
Sourcefn get_pinhole_params(&self) -> PinholeParams
fn get_pinhole_params(&self) -> PinholeParams
Returns the linear intrinsics (f_x, f_y, c_x, c_y).
Sourcefn get_distortion(&self) -> DistortionModel
fn get_distortion(&self) -> DistortionModel
Returns the distortion model and its parameters.
Sourcefn get_model_name(&self) -> &'static str
fn get_model_name(&self) -> &'static str
Returns the camera model identifier ("pinhole", "rad_tan", …).
Provided Methods§
Sourcefn jacobian_pose(
&self,
p_world: &Vector3<f64>,
pose: &SE3,
) -> (Self::PointJacobian, SMatrix<f64, 3, 6>)
fn jacobian_pose( &self, p_world: &Vector3<f64>, pose: &SE3, ) -> (Self::PointJacobian, SMatrix<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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".