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: CameraIdCamera id.
model: CameraModelKindCamera model.
width: u64Image width (pixels).
height: u64Image height (pixels).
params: Vec<f64>Model parameters (order per CameraModelKind::params_info).
focal_from_prior: boolWhether the focal length came from prior information such as EXIF (for choosing the calibration path).
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn new(
camera_id: CameraId,
model: CameraModelKind,
width: u64,
height: u64,
params: Vec<f64>,
) -> Result<Self>
pub fn new( camera_id: CameraId, model: CameraModelKind, width: u64, height: u64, params: Vec<f64>, ) -> Result<Self>
Creates after validating the parameter count.
Sourcepub fn from_focal(
model: CameraModelKind,
focal: f64,
width: u64,
height: u64,
) -> Self
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.
Sourcepub fn verify_params(&self) -> bool
pub fn verify_params(&self) -> bool
Whether the parameter count matches the model.
Sourcepub fn mean_focal(&self) -> f64
pub fn mean_focal(&self) -> f64
Mean focal length.
Sourcepub fn focal_length_x(&self) -> f64
pub fn focal_length_x(&self) -> f64
x focal length.
Sourcepub fn focal_length_y(&self) -> f64
pub fn focal_length_y(&self) -> f64
y focal length (same as x for single-focal models).
Sourcepub fn set_focal_length(&mut self, f: f64)
pub fn set_focal_length(&mut self, f: f64)
Sets all focal parameters to f.
Sourcepub fn principal_point_x(&self) -> f64
pub fn principal_point_x(&self) -> f64
Principal point x.
Sourcepub fn principal_point_y(&self) -> f64
pub fn principal_point_y(&self) -> f64
Principal point y.
Sourcepub fn set_principal_point(&mut self, cx: f64, cy: f64)
pub fn set_principal_point(&mut self, cx: f64, cy: f64)
Sets the principal point.
Sourcepub fn extra_params(&self) -> Vec<f64>
pub fn extra_params(&self) -> Vec<f64>
Copy of the distortion (extra) parameters.
Sourcepub fn is_undistorted(&self) -> bool
pub fn is_undistorted(&self) -> bool
No-distortion test: all extra parameters are 0.
Sourcepub fn calibration_matrix(&self) -> Mat3
pub fn calibration_matrix(&self) -> Mat3
Calibration matrix K (distortion ignored).
Sourcepub fn has_implausible_params(
&self,
min_focal_ratio: f64,
max_focal_ratio: f64,
max_extra_param: f64,
) -> bool
pub fn has_implausible_params( &self, min_focal_ratio: f64, max_focal_ratio: f64, max_extra_param: f64, ) -> bool
Abnormal-parameter test.
Sourcepub fn rescale(&mut self, scale: f64)
pub fn rescale(&mut self, scale: f64)
Uniform resize: multiplies focal and principal point by s, size is rounded. Distortion coefficients unchanged.
Sourcepub fn rescale_to(&mut self, new_width: u64, new_height: u64)
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.
Sourcepub fn img_to_cam_threshold(&self, threshold_px: f64) -> f64
pub fn img_to_cam_threshold(&self, threshold_px: f64) -> f64
Converts a pixel error threshold to a normalized-plane threshold: τ / mean focal length.
Sourcepub fn normalized_to_img(&self, uv: &Vec2) -> Vec2
pub fn normalized_to_img(&self, uv: &Vec2) -> Vec2
Normalized plane (u, v) -> pixel (with distortion).
Sourcepub fn cam_to_img(&self, xc: &Vec3) -> Option<Vec2>
pub fn cam_to_img(&self, xc: &Vec3) -> Option<Vec2>
3D point in camera coordinates -> pixel. None if Z < f64 ε.
Sourcepub fn img_to_normalized(&self, xy: &Vec2) -> Option<Vec2>
pub fn img_to_normalized(&self, xy: &Vec2) -> Option<Vec2>
Pixel -> normalized plane (undistortion). None if Newton does not converge within 100 iterations.
Sourcepub fn img_to_ray(&self, xy: &Vec2) -> Option<Vec3>
pub fn img_to_ray(&self, xy: &Vec2) -> Option<Vec3>
Pixel -> unit ray (u, v, 1)/‖·‖.
Sourcepub fn cam_to_img_with_jacobian(
&self,
xc: &Vec3,
d_params: Option<&mut [f64]>,
) -> Option<(Vec2, Matrix2x3<f64>)>
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§
impl StructuralPartialEq for Camera
Auto Trait Implementations§
impl Freeze 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.