pub struct UcmCamera {
pub pinhole: PinholeParams,
pub distortion: DistortionModel,
}Expand description
Unified Camera Model with 5 parameters.
Fields§
§pinhole: PinholeParams§distortion: DistortionModelImplementations§
Source§impl UcmCamera
impl UcmCamera
Sourcepub fn new(
pinhole: PinholeParams,
distortion: DistortionModel,
) -> Result<UcmCamera, CameraModelError>
pub fn new( pinhole: PinholeParams, distortion: DistortionModel, ) -> Result<UcmCamera, CameraModelError>
Create a new Unified Camera Model (UCM) camera.
§Arguments
pinhole- Pinhole parameters (fx, fy, cx, cy).distortion- MUST beDistortionModel::UCMwithalpha.
§Returns
Returns a new UcmCamera instance if the distortion model matches.
§Errors
Returns CameraModelError::InvalidParams if distortion is not DistortionModel::UCM.
Sourcepub fn linear_estimation(
&mut self,
points_3d: &Matrix<f64, Const<3>, Dyn, VecStorage<f64, Const<3>, Dyn>>,
points_2d: &Matrix<f64, Const<2>, Dyn, VecStorage<f64, Const<2>, Dyn>>,
) -> Result<(), CameraModelError>
pub fn linear_estimation( &mut self, points_3d: &Matrix<f64, Const<3>, Dyn, VecStorage<f64, Const<3>, Dyn>>, points_2d: &Matrix<f64, Const<2>, Dyn, VecStorage<f64, Const<2>, Dyn>>, ) -> Result<(), CameraModelError>
Performs linear estimation to initialize the alpha parameter from point correspondences.
This method estimates the alpha parameter using a linear least squares approach
given 3D-2D point correspondences. It assumes the intrinsic parameters (fx, fy, cx, cy)
are already set.
§Arguments
points_3d: Matrix3xX- 3D points in camera coordinates (each column is a point) points_2d: Matrix2xX- Corresponding 2D points in image coordinates
§Returns
Returns Ok(()) on success or a CameraModelError if the estimation fails.
Trait Implementations§
Source§impl CameraModel for UcmCamera
impl CameraModel for UcmCamera
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>
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 to 2D image coordinates.
§Mathematical Formula
d = √(x² + y² + z²)
denom = α·d + (1-α)·z
u = fx · (x/denom) + cx
v = fy · (y/denom) + cy§Arguments
p_cam- 3D point in camera coordinate frame.
§Returns
Ok(uv)- 2D image coordinates if valid.
§Errors
Returns CameraModelError::PointAtCameraCenter if the projection condition fails or the denominator is too small.
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>
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 3D ray.
§Algorithm
Algebraic solution for UCM inverse projection.
§Arguments
point_2d- 2D point in image coordinates.
§Returns
Ok(ray)- Normalized 3D ray direction.
§Errors
Returns CameraModelError::PointOutsideImage if the unprojection condition fails.
Source§fn jacobian_point(
&self,
p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
) -> <UcmCamera as CameraModel>::PointJacobian
fn jacobian_point( &self, p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, ) -> <UcmCamera as CameraModel>::PointJacobian
Checks if a 3D point can be validly projected.
Computes the Jacobian of the projection function with respect to the 3D point in camera frame.
§Mathematical Derivation
The UCM projection model maps a 3D point p = (x, y, z) to 2D pixel coordinates (u, v).
Projection:
ρ = √(x² + y² + z²)
D = α·ρ + (1-α)·z
u = fx · (x/D) + cx
v = fy · (y/D) + cyJacobian:
Derivatives of D with respect to (x, y, z):
∂D/∂x = α · (x/ρ)
∂D/∂y = α · (y/ρ)
∂D/∂z = α · (z/ρ) + (1-α)Using the quotient rule for u = fx · (x/D):
∂u/∂x = fx · (D - x·∂D/∂x) / D²
∂u/∂y = fx · (-x·∂D/∂y) / D²
∂u/∂z = fx · (-x·∂D/∂z) / D²Similarly for v:
∂v/∂x = fy · (-y·∂D/∂x) / D²
∂v/∂y = fy · (D - y·∂D/∂y) / D²
∂v/∂z = fy · (-y·∂D/∂z) / D²§Arguments
p_cam- 3D point in camera coordinate frame.
§Returns
Returns the 2x3 Jacobian matrix.
§References
- Geyer & Daniilidis, “A Unifying Theory for Central Panoramic Systems”, ICCV 2000
- Mei & Rives, “Single View Point Omnidirectional Camera Calibration from Planar Grids”, ICRA 2007
§Verification
This Jacobian is verified against numerical differentiation in tests.
Source§fn jacobian_intrinsics(
&self,
p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
) -> <UcmCamera as CameraModel>::IntrinsicJacobian
fn jacobian_intrinsics( &self, p_cam: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, ) -> <UcmCamera as CameraModel>::IntrinsicJacobian
Computes the Jacobian of the projection function with respect to intrinsic parameters.
§Mathematical Derivation
The UCM camera has 5 intrinsic parameters: θ = [fx, fy, cx, cy, α]
§Projection Model
u = fx · (x/D) + cx
v = fy · (y/D) + cyWhere D = α·ρ + (1-α)·z and ρ = √(x²+y²+z²)
§Jacobian Structure
Linear parameters (fx, fy, cx, cy):
∂u/∂fx = x/D, ∂u/∂fy = 0, ∂u/∂cx = 1, ∂u/∂cy = 0
∂v/∂fx = 0, ∂v/∂fy = y/D, ∂v/∂cx = 0, ∂v/∂cy = 1Projection parameter α:
∂D/∂α = ρ - z
∂u/∂α = -fx · (x/D²) · (ρ - z)
∂v/∂α = -fy · (y/D²) · (ρ - z)§Arguments
p_cam- 3D point in camera coordinate frame.
§Returns
Returns the 2x5 Intrinsic Jacobian matrix.
§References
- Geyer & Daniilidis, “A Unifying Theory for Central Panoramic Systems”, ICCV 2000
§Verification
This Jacobian is verified against numerical differentiation in tests.
Source§fn validate_params(&self) -> Result<(), CameraModelError>
fn validate_params(&self) -> Result<(), CameraModelError>
Validates camera parameters.
§Validation Rules
fx,fymust be positive.fx,fymust be finite.cx,cymust be finite.αmust be in [0, 1].
§Errors
Returns CameraModelError if any parameter violates validation rules.
Source§fn get_pinhole_params(&self) -> PinholeParams
fn get_pinhole_params(&self) -> PinholeParams
Returns the pinhole parameters of the camera.
§Returns
A PinholeParams struct containing the focal lengths (fx, fy) and principal point (cx, cy).
Source§fn get_distortion(&self) -> DistortionModel
fn get_distortion(&self) -> DistortionModel
Returns the distortion model and parameters of the camera.
§Returns
The DistortionModel associated with this camera (typically DistortionModel::UCM).
Source§fn get_model_name(&self) -> &'static str
fn get_model_name(&self) -> &'static str
Source§const INTRINSIC_DIM: usize = 5
const INTRINSIC_DIM: usize = 5
Source§type IntrinsicJacobian = Matrix<f64, Const<2>, Const<5>, ArrayStorage<f64, 2, 5>>
type IntrinsicJacobian = Matrix<f64, Const<2>, Const<5>, ArrayStorage<f64, 2, 5>>
Source§type PointJacobian = Matrix<f64, Const<2>, Const<3>, ArrayStorage<f64, 2, 3>>
type PointJacobian = Matrix<f64, Const<2>, Const<3>, ArrayStorage<f64, 2, 3>>
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>>)
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>>)
Source§impl From<&[f64]> for UcmCamera
Create camera from slice of intrinsic parameters.
impl From<&[f64]> for UcmCamera
Create camera from slice of intrinsic parameters.
Source§impl From<&UcmCamera> for [f64; 5]
Convert camera to fixed-size array of intrinsic parameters.
impl From<&UcmCamera> for [f64; 5]
Convert camera to fixed-size array of intrinsic parameters.
§Layout
The parameters are ordered as: [fx, fy, cx, cy, alpha]
Source§impl From<[f64; 5]> for UcmCamera
Create camera from fixed-size array of intrinsic parameters.
impl From<[f64; 5]> for UcmCamera
Create camera from fixed-size array of intrinsic parameters.
§Layout
Expected parameter order: [fx, fy, cx, cy, alpha]
impl Copy for UcmCamera
impl StructuralPartialEq for UcmCamera
Auto Trait Implementations§
impl Freeze for UcmCamera
impl RefUnwindSafe for UcmCamera
impl Send for UcmCamera
impl Sync for UcmCamera
impl Unpin for UcmCamera
impl UnsafeUnpin for UcmCamera
impl UnwindSafe for UcmCamera
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.