Skip to main content

Camera

Struct Camera 

Source
pub struct Camera {
    pub id: u64,
    pub model: CameraModel,
    pub width: u32,
    pub height: u32,
    pub params: Vec<f64>,
}

Fields§

§id: u64§model: CameraModel§width: u32§height: u32§params: Vec<f64>

Implementations§

Source§

impl Camera

Source

pub fn equirectangular(id: u64, width: u32, height: u32) -> Camera

A CameraModel::Equirectangular panorama of width x height px.

Source

pub fn pinhole( id: u64, width: u32, height: u32, fx: f64, fy: f64, cx: f64, cy: f64, ) -> Camera

Source

pub fn pinhole_radial( id: u64, width: u32, height: u32, fx: f64, fy: f64, cx: f64, cy: f64, k1: f64, k2: f64, ) -> Camera

Construct a pinhole camera with two trailing radial-distortion coefficients (k1, k2). The intrinsics layout stays [fx, fy, cx, cy] (so Self::intrinsics is unchanged); the distortion lives in the two extra params slots and is read back by Self::radial_distortion.

Source

pub fn opencv_fisheye( id: u64, width: u32, height: u32, fx: f64, fy: f64, cx: f64, cy: f64, k: [f64; 4], ) -> Camera

Construct an OpenCV-fisheye (Kannala-Brandt equidistant) camera with [fx, fy, cx, cy, k1, k2, k3, k4].

Source

pub fn double_sphere( id: u64, width: u32, height: u32, fx: f64, fy: f64, cx: f64, cy: f64, xi: f64, alpha: f64, ) -> Camera

Construct a Double Sphere camera with [fx, fy, cx, cy, xi, alpha].

Source

pub fn radial_distortion(&self) -> Option<(f64, f64)>

Radial-distortion coefficients (k1, k2) carried alongside the pinhole intrinsics, if any. A plain 4-parameter pinhole returns None (distortion-free); Pinhole / OpenCv read the optional trailing [k1, k2] (an OpenCv camera’s (p1, p2) are reported separately by Self::tangential_distortion), while COLMAP SimpleRadial / Radial read their native [f, cx, cy, k1(, k2)] layout. The fisheye and Double Sphere models carry their own distortion and return None here.

Source

pub fn tangential_distortion(&self) -> Option<(f64, f64)>

Tangential-distortion coefficients (p1, p2) of a COLMAP OPENCV camera ([fx, fy, cx, cy, k1, k2, p1, p2]), or None when the model is not OpenCv, the slots are absent, or both are zero. When present, Self::project and Self::normalize_pixel apply the full Brown-Conrady model (radial + tangential); without them the radial-only path is used, unchanged.

Source

pub fn distortion_free(&self) -> bool

Whether this camera projects as an undistorted pinhole: a Brown-Conrady model (PINHOLE, SIMPLE_PINHOLE, SIMPLE_RADIAL, RADIAL, OPENCV, FULL_OPENCV) whose distortion coefficients, if any, are all zero.

Source

pub fn set_intrinsics(&mut self, fx: f64, fy: f64, cx: f64, cy: f64) -> bool

Sets the focal lengths and principal point (Self::intrinsics), keeping the distortion. A model with one focal length takes the mean of fx and fy. Returns false, changing nothing, for a model without them (a panorama) or a camera missing the slots.

Source

pub fn intrinsics(&self) -> Option<(f64, f64, f64, f64)>

Source

pub fn pixels_per_radian(&self) -> Option<f64>

Image pixels per radian of the camera’s rays near the image centre: the focal length of a perspective model ((fx + fy) / 2), w / 2π for an equirectangular one (COLMAP’s CamFromImgThreshold). Divides a pixel threshold into an angle.

Source

pub fn pixel_residual( &self, projected: &OPoint<f64, Const<2>>, observed: &OPoint<f64, Const<2>>, ) -> Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>

projected - observed in pixels; a panorama’s horizontal difference wrapped into [-w / 2, w / 2], its left and right edges being one meridian.

Source

pub fn sees_behind(&self) -> bool

Whether the image holds rays at or past 90° from the optical axis (z ≤ 0), which the normalized image plane (Self::normalize_pixel) cannot represent. True for a panorama, a Double Sphere camera, and an equidistant fisheye whose image corners lie past the radius its polynomial reaches at 90° (a lens wider than 180° across the diagonal). A polynomial that folds back before 90° ends the lens there. Geometry for such a camera goes through Self::unit_ray_from_pixel. Cheap: four corners and sixteen polynomial values.

Source

pub fn sees_in_front( &self, point_camera: &OPoint<f64, Const<3>>, observed: &OPoint<f64, Const<2>>, ) -> bool

Whether the camera-frame point point_camera lies ahead along the ray of its observation at pixel observed: in front of the image plane (z > 0) for a camera that cannot see behind it, on the ray’s side of the centre for one that can (Self::sees_behind).

Source

pub fn normalize_pixel( &self, point: &OPoint<f64, Const<2>>, ) -> Option<OPoint<f64, Const<2>>>

Back-project a pixel to a normalized (undistorted) bearing (x, y, 1).

Pinhole models with radial distortion are undistorted first (fixed-point inverse of 1 + k1·r² + k2·r⁴), so the returned coordinates match an ideal pinhole — what the geometric front-end (essential matrix, PnP, triangulation) expects. Fisheye/wide-angle models return the (x, y, 1) form of the recovered unit ray, which exists only while the ray still points forward (z > 0); use Self::unit_ray_from_pixel for the full field of view.

Source

pub fn project( &self, point_camera: &OPoint<f64, Const<3>>, ) -> Option<OPoint<f64, Const<2>>>

Source

pub fn project_with_point_jacobian( &self, point_camera: &OPoint<f64, Const<3>>, ) -> Option<(OPoint<f64, Const<2>>, Matrix<f64, Const<2>, Const<3>, ArrayStorage<f64, 2, 3>>)>

Self::project together with its analytic 2×3 Jacobian with respect to the camera-frame point.

The returned pixel is exactly Self::project’s (it is computed by that function), so a least-squares residual built from it matches a cost that calls project. The Jacobian is the derivative of that same lens model for every supported family: pinhole with radial 1 + k1 r² + k2 r⁴ (Pinhole, SimplePinhole, SimpleRadial, Radial, OpenCv), the full Brown-Conrady rational model with tangential (p1, p2) (OpenCv with non-zero tangential terms, FullOpenCv), the Kannala-Brandt equidistant fisheye (OpenCvFisheye, SimpleRadialFisheye, RadialFisheye), the FOV model and Double Sphere. Returns None wherever project does, for an Unknown model, or when the Jacobian is not finite.

Source

pub fn unit_ray_from_pixel( &self, point: &OPoint<f64, Const<2>>, ) -> Option<Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>>

Back-project a pixel to a unit camera-frame ray. Unlike Self::normalize_pixel this is defined for the full field of view, including rays at or behind the image plane, so it is the robust entry point for fisheye/wide-angle geometry.

Trait Implementations§

Source§

impl Clone for Camera

Source§

fn clone(&self) -> Camera

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<(), Error>

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

impl PartialEq for Camera

Source§

fn eq(&self, other: &Camera) -> 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§

§

impl Forget for Camera

§

impl Freeze for Camera

§

impl Move for Camera

§

impl RefUnwindSafe for Camera

§

impl Send for Camera

§

impl Sync for Camera

§

impl Unpin for Camera

§

impl UnsafeUnpin for Camera

§

impl UnwindSafe for Camera

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V