Skip to main content

Camera

Struct Camera 

Source
pub struct Camera {
    pub camera_id: CameraId,
    pub model: CameraModelKind,
    pub width: u64,
    pub height: u64,
    pub params: Vec<f64>,
    pub focal_from_prior: bool,
}
Expand description

Camera (intrinsic parameters). focal_from_prior is memory-only (not stored in the model file).

Fields§

§camera_id: CameraId

Camera id.

§model: CameraModelKind

Camera model.

§width: u64

Image width (pixels).

§height: u64

Image height (pixels).

§params: Vec<f64>

Model parameters (order per CameraModelKind::params_info).

§focal_from_prior: bool

Whether the focal length came from prior information such as EXIF (for choosing the calibration path).

Implementations§

Source§

impl Camera

Source

pub fn new( camera_id: CameraId, model: CameraModelKind, width: u64, height: u64, params: Vec<f64>, ) -> Result<Self>

Creates after validating the parameter count.

Source

pub fn from_focal( model: CameraModelKind, focal: f64, width: u64, height: u64, ) -> Self

Initializes with focal length f: focal = f, principal point = (W/2, H/2), distortion 0.

Source

pub fn verify_params(&self) -> bool

Whether the parameter count matches the model.

Source

pub fn mean_focal(&self) -> f64

Mean focal length.

Source

pub fn focal_length_x(&self) -> f64

x focal length.

Source

pub fn focal_length_y(&self) -> f64

y focal length (same as x for single-focal models).

Source

pub fn set_focal_length(&mut self, f: f64)

Sets all focal parameters to f.

Source

pub fn principal_point_x(&self) -> f64

Principal point x.

Source

pub fn principal_point_y(&self) -> f64

Principal point y.

Source

pub fn set_principal_point(&mut self, cx: f64, cy: f64)

Sets the principal point.

Source

pub fn extra_params(&self) -> Vec<f64>

Copy of the distortion (extra) parameters.

Source

pub fn is_undistorted(&self) -> bool

No-distortion test: all extra parameters are 0.

Source

pub fn calibration_matrix(&self) -> Mat3

Calibration matrix K (distortion ignored).

Source

pub fn has_implausible_params( &self, min_focal_ratio: f64, max_focal_ratio: f64, max_extra_param: f64, ) -> bool

Abnormal-parameter test.

Source

pub fn rescale(&mut self, scale: f64)

Uniform resize: multiplies focal and principal point by s, size is rounded. Distortion coefficients unchanged.

Source

pub fn rescale_to(&mut self, new_width: u64, new_height: u64)

Resize to a new size: multiplies focal and principal point by per-axis sx = W’/W, sy = H’/H.

Source

pub fn img_to_cam_threshold(&self, threshold_px: f64) -> f64

Converts a pixel error threshold to a normalized-plane threshold: τ / mean focal length.

Source

pub fn normalized_to_img(&self, uv: &Vec2) -> Vec2

Normalized plane (u, v) -> pixel (with distortion).

Source

pub fn cam_to_img(&self, xc: &Vec3) -> Option<Vec2>

3D point in camera coordinates -> pixel. None if Z < f64 ε.

Source

pub fn img_to_normalized(&self, xy: &Vec2) -> Option<Vec2>

Pixel -> normalized plane (undistortion). None if Newton does not converge within 100 iterations.

Source

pub fn img_to_ray(&self, xy: &Vec2) -> Option<Vec3>

Pixel -> unit ray (u, v, 1)/‖·‖.

Source

pub fn cam_to_img_with_jacobian( &self, xc: &Vec3, d_params: Option<&mut [f64]>, ) -> Option<(Vec2, Matrix2x3<f64>)>

Projection and analytic Jacobian.

Returns: (pixel, ∂pixel/∂camera-coordinates 2×3). If d_params is given, fills ∂pixel/∂parameters as row-major 2×num_params (first row = x, second row = y, columns = parameter order). None if Z < ε (BA then sets the residual and Jacobian to 0).

Trait Implementations§

Source§

impl Clone for Camera

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Camera

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Camera

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Camera

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.