Struct cam_geom::Camera

source ·
pub struct Camera<R, I>where
    I: IntrinsicParameters<R>,
    R: RealField,
{ /* private fields */ }
Expand description

A camera model that can convert world coordinates into pixel coordinates.

Examples

Creates a new perspective camera:

use cam_geom::*;
use nalgebra::*;

// perepective parameters - focal length of 100, no skew, pixel center at (640,480)
let intrinsics = IntrinsicParametersPerspective::from(PerspectiveParams {
    fx: 100.0,
    fy: 100.0,
    skew: 0.0,
    cx: 640.0,
    cy: 480.0,
});

// Set extrinsic parameters - camera at (10,0,10), looing at (0,0,0), up (0,0,1)
let camcenter = Vector3::new(10.0, 0.0, 10.0);
let lookat = Vector3::new(0.0, 0.0, 0.0);
let up = Unit::new_normalize(Vector3::new(0.0, 0.0, 1.0));
let pose = ExtrinsicParameters::from_view(&camcenter, &lookat, &up);

// Create camera with both intrinsic and extrinsic parameters.
let cam = Camera::new(intrinsics, pose);

Creates a new orthographic camera:

use cam_geom::*;
use nalgebra::*;

// orthographic parameters - scale of 100, pixel center at (640,480)
let intrinsics = IntrinsicParametersOrthographic::from(OrthographicParams {
    sx: 100.0,
    sy: 100.0,
    cx: 640.0,
    cy: 480.0,
});

// Set extrinsic parameters - camera at (10,0,10), looing at (0,0,0), up (0,0,1)
let camcenter = Vector3::new(10.0, 0.0, 10.0);
let lookat = Vector3::new(0.0, 0.0, 0.0);
let up = Unit::new_normalize(Vector3::new(0.0, 0.0, 1.0));
let pose = ExtrinsicParameters::from_view(&camcenter, &lookat, &up);

// Create camera with both intrinsic and extrinsic parameters.
let cam = Camera::new(intrinsics, pose);

Implementations§

Create a new camera from intrinsic and extrinsic parameters.

Arguments

Intrinsic parameters and extrinsic parameters

Return a reference to the extrinsic parameters.

Return a reference to the intrinsic parameters.

take 3D coordinates in world frame and convert to pixel coordinates

take pixel coordinates and project to 3D in world frame

output arguments: camera - camera frame coordinate rays world - world frame coordinate rays

Note that the camera frame coordinates are returned as they must be computed anyway, so this additional data is “free”.

Create a Camera from a 3x4 perspective projection matrix.

Create a 3x4 perspective projection matrix modeling this camera.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.