Struct ImageFrame

Source
pub struct ImageFrame<Kind> { /* private fields */ }
Expand description

Holds the raw data pointer and derived data for an RS2 Image frame.

This generic type isn’t particularly useful on it’s own. In all cases, you want a specialized version of this class (DepthFrame, ColorFrame, DisparityFrame).

Implementations§

Source§

impl ImageFrame<Depth>

Source

pub fn distance(&self, col: usize, row: usize) -> Result<f32, DepthError>

Given the 2D depth coordinate (x,y) provide the corresponding depth in metric units.

§Warning

It is fairly expensive to use this in practice as it will copy the underlying pixel into a f32 value that gives you the direct distance. In practice getting DepthFrame::depth_units and then applying that to the raw data with ImageFrame::get is a much more efficient way to handle this.

Source

pub fn depth_units(&self) -> Result<f32>

Get the metric units currently used for reporting depth information.

Source§

impl ImageFrame<Disparity>

Source

pub fn distance(&self, col: usize, row: usize) -> Result<f32, DepthError>

Given the 2D depth coordinate (x,y) provide the corresponding depth in metric units.

§Warning

Like with depth frames, this method is fairly expensive to use in practice. The disparity can be converted to depth fairly easily, but this will effectively copy every pixel if you loop through the data with this method for every index.

It is often much more efficient to directly stream the Rs2Format::Distance format if you want the distance directly, and access the frame data with ImageFrame::get.

Source

pub fn depth_units(&self) -> Result<f32>

Get the metric units currently used for reporting depth information.

Source

pub fn baseline(&self) -> Result<f32, DisparityError>

Get the baseline used during construction of the Disparity frame

Source§

impl<K> ImageFrame<K>

Source

pub fn iter(&self) -> Iter<'_, K>

Iterator through every pixel of an image frame.

Source

pub fn get_unchecked(&self, col: usize, row: usize) -> PixelKind<'_>

Get a pixel value from the Video Frame.

§Safety

This makes a call directly to the underlying data pointer inherited from the rs2_frame.

Source

pub fn stride(&self) -> usize

Get the stride of this Video frame’s pixel in bytes.

Source

pub fn bits_per_pixel(&self) -> usize

Get the bits per pixel.

Source

pub fn get_data_size(&self) -> usize

Get the size of the data in this Video frame in bytes.

Source

pub unsafe fn get_data(&self) -> &c_void

Get a reference to the raw data held by this Video frame.

§Safety

This is a raw pointer to the underlying data. This data has to be interpreted according to the format of the frame itself. In most scenarios you will probably want to just use the get_unchecked function associated with the FrameEx trait, but this can be useful if you need more immediate access to the underlying pixel data.

Source

pub fn width(&self) -> usize

Get the width of this Video frame in pixels

Source

pub fn height(&self) -> usize

Get the height of this Video frame in pixels

Source

pub fn get(&self, col: usize, row: usize) -> Option<PixelKind<'_>>

Given a row and column index, Get a pixel value from this frame.

Trait Implementations§

Source§

impl<Kind: Debug> Debug for ImageFrame<Kind>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

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

impl<K> Drop for ImageFrame<K>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> FrameEx for ImageFrame<T>

Source§

fn stream_profile(&self) -> &StreamProfile

Get the stream profile associated with the frame.
Source§

fn sensor(&self) -> Result<Sensor>

Get the sensor associated with the frame.
Source§

fn timestamp(&self) -> f64

Get the frame timestamp.
Source§

fn timestamp_domain(&self) -> Rs2TimestampDomain

Get the RealSense timestamp domain for the current timestamp.
Source§

fn frame_number(&self) -> u64

Get the frame number.
Source§

fn metadata(&self, metadata_kind: Rs2FrameMetadata) -> Option<c_longlong>

Get frame metadata. Read more
Source§

fn supports_metadata(&self, metadata_kind: Rs2FrameMetadata) -> bool

Test whether the metadata arguemnt is supported by the frame.
Source§

unsafe fn get_owned_raw(self) -> NonNull<rs2_frame>

Get (and own) the underlying frame pointer for this frame. Read more
Source§

impl<'a, K> IntoIterator for &'a ImageFrame<K>

Source§

type Item = <Iter<'a, K> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, K>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K> TryFrom<NonNull<rs2_frame>> for ImageFrame<K>

Source§

fn try_from(frame_ptr: NonNull<rs2_frame>) -> Result<Self, Self::Error>

Attempt to construct an Image frame of extension K from the raw rs2_frame.

All members of the ImageFrame struct are validated and populated during this call.

§Errors

There are a number of errors that may occur if the data in the rs2_frame is not valid, all of type FrameConstructionError.

See FrameConstructionError documentation for more details.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

impl<K> Send for ImageFrame<K>

Auto Trait Implementations§

§

impl<Kind> Freeze for ImageFrame<Kind>

§

impl<Kind> RefUnwindSafe for ImageFrame<Kind>
where Kind: RefUnwindSafe,

§

impl<Kind> !Sync for ImageFrame<Kind>

§

impl<Kind> Unpin for ImageFrame<Kind>
where Kind: Unpin,

§

impl<Kind> UnwindSafe for ImageFrame<Kind>
where Kind: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.