[−][src]Struct cam_geom::Camera
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);
Methods
impl<R, I> Camera<R, I> where
I: IntrinsicParameters<R>,
R: RealField,
[src]
I: IntrinsicParameters<R>,
R: RealField,
pub fn new(intrinsics: I, extrinsics: ExtrinsicParameters<R>) -> Self
[src]
Create a new camera from intrinsic and extrinsic parameters.
Arguments
Intrinsic parameters and extrinsic parameters
pub fn extrinsics(&self) -> &ExtrinsicParameters<R>
[src]
Return a reference to the extrinsic parameters.
pub fn intrinsics(&self) -> &I
[src]
Return a reference to the intrinsic parameters.
pub fn world_to_pixel<NPTS, InStorage>(
&self,
world: &Points<WorldFrame, R, NPTS, InStorage>
) -> Pixels<R, NPTS, Owned<R, NPTS, U2>> where
NPTS: Dim,
InStorage: Storage<R, NPTS, U3>,
DefaultAllocator: Allocator<R, NPTS, U3>,
DefaultAllocator: Allocator<R, NPTS, U2>,
[src]
&self,
world: &Points<WorldFrame, R, NPTS, InStorage>
) -> Pixels<R, NPTS, Owned<R, NPTS, U2>> where
NPTS: Dim,
InStorage: Storage<R, NPTS, U3>,
DefaultAllocator: Allocator<R, NPTS, U3>,
DefaultAllocator: Allocator<R, NPTS, U2>,
take 3D coordinates in world frame and convert to pixel coordinates
pub fn pixel_to_world<IN, NPTS>(
&self,
pixels: &Pixels<R, NPTS, IN>
) -> RayBundle<WorldFrame, I::BundleType, R, NPTS, Owned<R, NPTS, U3>> where
I::BundleType: Bundle<R>,
IN: Storage<R, NPTS, U2>,
NPTS: Dim,
I::BundleType: Bundle<R>,
DefaultAllocator: Allocator<R, U1, U2>,
DefaultAllocator: Allocator<R, NPTS, U2>,
DefaultAllocator: Allocator<R, NPTS, U3>,
[src]
&self,
pixels: &Pixels<R, NPTS, IN>
) -> RayBundle<WorldFrame, I::BundleType, R, NPTS, Owned<R, NPTS, U3>> where
I::BundleType: Bundle<R>,
IN: Storage<R, NPTS, U2>,
NPTS: Dim,
I::BundleType: Bundle<R>,
DefaultAllocator: Allocator<R, U1, U2>,
DefaultAllocator: Allocator<R, NPTS, U2>,
DefaultAllocator: Allocator<R, NPTS, U3>,
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".
impl<R: RealField> Camera<R, IntrinsicParametersPerspective<R>>
[src]
pub fn from_perspective_matrix<S>(
pmat: &Matrix<R, U3, U4, S>
) -> Result<Self, Error> where
S: Storage<R, U3, U4> + Clone,
[src]
pmat: &Matrix<R, U3, U4, S>
) -> Result<Self, Error> where
S: Storage<R, U3, U4> + Clone,
Create a Camera
from a 3x4 perspective projection matrix.
pub fn as_camera_matrix(&self) -> MatrixMN<R, U3, U4>
[src]
Create a 3x4 perspective projection matrix modeling this camera.
Trait Implementations
impl<R: Clone, I: Clone> Clone for Camera<R, I> where
I: IntrinsicParameters<R>,
R: RealField,
[src]
I: IntrinsicParameters<R>,
R: RealField,
impl<R: Debug, I: Debug> Debug for Camera<R, I> where
I: IntrinsicParameters<R>,
R: RealField,
[src]
I: IntrinsicParameters<R>,
R: RealField,
impl<'de, R, I> Deserialize<'de> for Camera<R, I> where
I: IntrinsicParameters<R>,
R: RealField,
R: Deserialize<'de>,
I: Deserialize<'de>,
[src]
I: IntrinsicParameters<R>,
R: RealField,
R: Deserialize<'de>,
I: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<R: PartialEq, I: PartialEq> PartialEq<Camera<R, I>> for Camera<R, I> where
I: IntrinsicParameters<R>,
R: RealField,
[src]
I: IntrinsicParameters<R>,
R: RealField,
impl<R, I> Serialize for Camera<R, I> where
I: IntrinsicParameters<R>,
R: RealField,
R: Serialize,
I: Serialize,
[src]
I: IntrinsicParameters<R>,
R: RealField,
R: Serialize,
I: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<R, I> StructuralPartialEq for Camera<R, I> where
I: IntrinsicParameters<R>,
R: RealField,
[src]
I: IntrinsicParameters<R>,
R: RealField,
Auto Trait Implementations
impl<R, I> RefUnwindSafe for Camera<R, I> where
I: RefUnwindSafe,
R: RefUnwindSafe + Scalar,
I: RefUnwindSafe,
R: RefUnwindSafe + Scalar,
impl<R, I> Send for Camera<R, I> where
I: Send,
R: Scalar,
I: Send,
R: Scalar,
impl<R, I> Sync for Camera<R, I> where
I: Sync,
R: Scalar,
I: Sync,
R: Scalar,
impl<R, I> Unpin for Camera<R, I> where
I: Unpin,
R: Scalar + Unpin,
I: Unpin,
R: Scalar + Unpin,
impl<R, I> UnwindSafe for Camera<R, I> where
I: UnwindSafe,
R: Scalar + UnwindSafe,
I: UnwindSafe,
R: Scalar + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,