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
impl Camera
Sourcepub fn equirectangular(id: u64, width: u32, height: u32) -> Camera
pub fn equirectangular(id: u64, width: u32, height: u32) -> Camera
A CameraModel::Equirectangular panorama of width x height px.
pub fn pinhole( id: u64, width: u32, height: u32, fx: f64, fy: f64, cx: f64, cy: f64, ) -> Camera
Sourcepub fn pinhole_radial(
id: u64,
width: u32,
height: u32,
fx: f64,
fy: f64,
cx: f64,
cy: f64,
k1: f64,
k2: f64,
) -> Camera
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.
Sourcepub fn opencv_fisheye(
id: u64,
width: u32,
height: u32,
fx: f64,
fy: f64,
cx: f64,
cy: f64,
k: [f64; 4],
) -> Camera
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].
Sourcepub fn double_sphere(
id: u64,
width: u32,
height: u32,
fx: f64,
fy: f64,
cx: f64,
cy: f64,
xi: f64,
alpha: f64,
) -> Camera
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].
Sourcepub fn radial_distortion(&self) -> Option<(f64, f64)>
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.
Sourcepub fn tangential_distortion(&self) -> Option<(f64, f64)>
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.
Sourcepub fn distortion_free(&self) -> bool
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.
Sourcepub fn set_intrinsics(&mut self, fx: f64, fy: f64, cx: f64, cy: f64) -> bool
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.
pub fn intrinsics(&self) -> Option<(f64, f64, f64, f64)>
Sourcepub fn pixels_per_radian(&self) -> Option<f64>
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.
Sourcepub fn pixel_residual(
&self,
projected: &OPoint<f64, Const<2>>,
observed: &OPoint<f64, Const<2>>,
) -> Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>
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.
Sourcepub fn sees_behind(&self) -> bool
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.
Sourcepub fn sees_in_front(
&self,
point_camera: &OPoint<f64, Const<3>>,
observed: &OPoint<f64, Const<2>>,
) -> bool
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).
Sourcepub fn normalize_pixel(
&self,
point: &OPoint<f64, Const<2>>,
) -> Option<OPoint<f64, Const<2>>>
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.
pub fn project( &self, point_camera: &OPoint<f64, Const<3>>, ) -> Option<OPoint<f64, Const<2>>>
Sourcepub 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>>)>
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.
Sourcepub fn unit_ray_from_pixel(
&self,
point: &OPoint<f64, Const<2>>,
) -> Option<Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>>
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§
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> 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> 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
impl<T> Scalar 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.