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>
impl ImageFrame<Depth>
Sourcepub fn distance(&self, col: usize, row: usize) -> Result<f32, DepthError>
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.
Sourcepub fn depth_units(&self) -> Result<f32>
pub fn depth_units(&self) -> Result<f32>
Get the metric units currently used for reporting depth information.
Source§impl ImageFrame<Disparity>
impl ImageFrame<Disparity>
Sourcepub fn distance(&self, col: usize, row: usize) -> Result<f32, DepthError>
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
.
Sourcepub fn depth_units(&self) -> Result<f32>
pub fn depth_units(&self) -> Result<f32>
Get the metric units currently used for reporting depth information.
Source§impl<K> ImageFrame<K>
impl<K> ImageFrame<K>
Sourcepub fn get_unchecked(&self, col: usize, row: usize) -> PixelKind<'_>
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
.
Sourcepub fn bits_per_pixel(&self) -> usize
pub fn bits_per_pixel(&self) -> usize
Get the bits per pixel.
Sourcepub fn get_data_size(&self) -> usize
pub fn get_data_size(&self) -> usize
Get the size of the data in this Video frame in bytes.
Sourcepub unsafe fn get_data(&self) -> &c_void
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.
Trait Implementations§
Source§impl<Kind: Debug> Debug for ImageFrame<Kind>
impl<Kind: Debug> Debug for ImageFrame<Kind>
Source§impl<K> Drop for ImageFrame<K>
impl<K> Drop for ImageFrame<K>
Source§impl<T> FrameEx for ImageFrame<T>
impl<T> FrameEx for ImageFrame<T>
Source§fn stream_profile(&self) -> &StreamProfile
fn stream_profile(&self) -> &StreamProfile
Source§fn timestamp_domain(&self) -> Rs2TimestampDomain
fn timestamp_domain(&self) -> Rs2TimestampDomain
Source§fn frame_number(&self) -> u64
fn frame_number(&self) -> u64
Source§fn metadata(&self, metadata_kind: Rs2FrameMetadata) -> Option<c_longlong>
fn metadata(&self, metadata_kind: Rs2FrameMetadata) -> Option<c_longlong>
Source§fn supports_metadata(&self, metadata_kind: Rs2FrameMetadata) -> bool
fn supports_metadata(&self, metadata_kind: Rs2FrameMetadata) -> bool
Source§impl<'a, K> IntoIterator for &'a ImageFrame<K>
impl<'a, K> IntoIterator for &'a ImageFrame<K>
Source§impl<K> TryFrom<NonNull<rs2_frame>> for ImageFrame<K>
impl<K> TryFrom<NonNull<rs2_frame>> for ImageFrame<K>
Source§fn try_from(frame_ptr: NonNull<rs2_frame>) -> Result<Self, Self::Error>
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
.
CouldNotGetWidth
CouldNotGetHeight
CouldNotGetBitsPerPixel
CouldNotGetStride
CouldNotGetTimestamp
CouldNotGetTimestampDomain
CouldNotGetFrameStreamProfile
CouldNotGetDataSize
CouldNotGetData
See FrameConstructionError
documentation for more details.