Struct Image

Source
pub struct Image(pub k4a_image_t);
Expand description

Adapted from k4a-sys. Represents an image within a capture.

Tuple Fields§

§0: k4a_image_t

Implementations§

Source§

impl Image

Source

pub fn create( format: ImageFormat, width: u32, height: u32, stride_bytes: u32, ) -> Result<Self, CreateImageError>

Create a blank image.

This function is used to create images of formats that have consistent stride. The function is not suitable for compressed formats that may not be represented by the same number of bytes per line.

For most image formats, the function will allocate an image buffer of size height_pixels * stride_bytes. Buffers K4A_IMAGE_FORMAT_COLOR_NV12 format will allocate an additional height_pixels / 2 set of lines (each of stride_bytes). This function cannot be used to allocate K4A_IMAGE_FORMAT_COLOR_MJPG buffers.

To create an image object without the API allocating memory, or to represent an image that has a non-deterministic stride, use k4a_image_create_from_buffer().

The k4a_image_t is created with a reference count of 1.

When finished using the created image, release it with k4a_image_release.

stride_bytes - The number of bytes per horizontal line of the image. If set to 0, the stride will be set to the minimum size given the format and width_pixels.

Source

pub fn get_height_pixels(&self) -> usize

Source

pub fn get_width_pixels(&self) -> usize

Source

pub fn get_stride_bytes(&self) -> usize

Source

pub fn get_size(&self) -> usize

Source

pub fn get_buffer(&self) -> *mut u8

Source

pub fn get_format(&self) -> ImageFormat

Use this function to determine the format of the image buffer. This function is not expected to fail, all k4a_image_t’s are created with a known format. If the image_handle is invalid, the function will return K4A_IMAGE_FORMAT_CUSTOM.

Source

pub fn get_handle(&self) -> k4a_image_t

Returns the underlying opaque handle without an additional refcount. Do not deallocate it.

Trait Implementations§

Source§

impl Clone for Image

Handles are refcounted by libk4a. The final reference is destroyed

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Image

Source§

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

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

impl Drop for Image

Remove a libk4a image refcount on every drop. When the refcount drops to zero, the image goes away.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Image

§

impl RefUnwindSafe for Image

§

impl !Send for Image

§

impl !Sync for Image

§

impl Unpin for Image

§

impl UnwindSafe for Image

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.