Struct HostMem

Source
pub struct HostMem { /* private fields */ }
Expand description

Class with reference counting wrapping special memory type allocation functions from CUDA.

Its interface is also Mat-like but with additional memory type parameters.

  • PAGE_LOCKED sets a page locked memory type used commonly for fast and asynchronous uploading/downloading data from/to GPU.
  • SHARED specifies a zero copy memory allocation that enables mapping the host memory to GPU address space, if supported.
  • WRITE_COMBINED sets the write combined buffer that is not cached by CPU. Such buffers are used to supply GPU with data when GPU only reads it. The advantage is a better CPU cache utilization.

Note: Allocation size of such memory types is usually limited. For more details, see CUDA 2.2 Pinned Memory APIs document or CUDA C Programming Guide.

Implementations§

Source§

impl HostMem

Source

pub fn new(alloc_type: HostMem_AllocType) -> Result<HostMem>

§C++ default parameters
  • alloc_type: HostMem::AllocType::PAGE_LOCKED
Source

pub fn new_def() -> Result<HostMem>

§Note

This alternative version of [new] function uses the following default values for its arguments:

  • alloc_type: HostMem::AllocType::PAGE_LOCKED
Source

pub fn copy(m: &impl HostMemTraitConst) -> Result<HostMem>

Source

pub fn new_1( rows: i32, cols: i32, typ: i32, alloc_type: HostMem_AllocType, ) -> Result<HostMem>

§C++ default parameters
  • alloc_type: HostMem::AllocType::PAGE_LOCKED
Source

pub fn new_def_1(rows: i32, cols: i32, typ: i32) -> Result<HostMem>

§Note

This alternative version of [new] function uses the following default values for its arguments:

  • alloc_type: HostMem::AllocType::PAGE_LOCKED
Source

pub fn new_2( size: Size, typ: i32, alloc_type: HostMem_AllocType, ) -> Result<HostMem>

§C++ default parameters
  • alloc_type: HostMem::AllocType::PAGE_LOCKED
Source

pub fn new_def_2(size: Size, typ: i32) -> Result<HostMem>

§Note

This alternative version of [new] function uses the following default values for its arguments:

  • alloc_type: HostMem::AllocType::PAGE_LOCKED
Source

pub fn new_3( arr: &impl ToInputArray, alloc_type: HostMem_AllocType, ) -> Result<HostMem>

creates from host memory with coping data

§C++ default parameters
  • alloc_type: HostMem::AllocType::PAGE_LOCKED
Source

pub fn new_def_3(arr: &impl ToInputArray) -> Result<HostMem>

creates from host memory with coping data

§Note

This alternative version of [new] function uses the following default values for its arguments:

  • alloc_type: HostMem::AllocType::PAGE_LOCKED

Trait Implementations§

Source§

impl Boxed for HostMem

Source§

unsafe fn from_raw(ptr: <HostMem as OpenCVFromExtern>::ExternReceive) -> Self

Wrap the specified raw pointer Read more
Source§

fn into_raw(self) -> <HostMem as OpenCVTypeExternContainer>::ExternSendMut

Return the underlying raw pointer while consuming this wrapper. Read more
Source§

fn as_raw(&self) -> <HostMem as OpenCVTypeExternContainer>::ExternSend

Return the underlying raw pointer. Read more
Source§

fn as_raw_mut( &mut self, ) -> <HostMem as OpenCVTypeExternContainer>::ExternSendMut

Return the underlying mutable raw pointer Read more
Source§

impl Clone for HostMem

Source§

fn clone(&self) -> Self

Calls try_clone() and panics if that fails

1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for HostMem

Source§

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

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

impl Drop for HostMem

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl HostMemTrait for HostMem

Source§

fn as_raw_mut_HostMem(&mut self) -> *mut c_void

Source§

fn set_flags(&mut self, val: i32)

Source§

fn set_rows(&mut self, val: i32)

Source§

fn set_cols(&mut self, val: i32)

Source§

fn set_step(&mut self, val: size_t)

Source§

fn data_mut(&mut self) -> *mut u8

Source§

unsafe fn set_data(&mut self, val: *const u8)

Source§

fn refcount_mut(&mut self) -> *mut i32

Source§

unsafe fn set_refcount(&mut self, val: *const i32)

Source§

fn datastart_mut(&mut self) -> *mut u8

Source§

unsafe fn set_datastart(&mut self, val: *const u8)

Source§

fn set_alloc_type(&mut self, val: HostMem_AllocType)

Source§

fn set(&mut self, m: &impl HostMemTraitConst) -> Result<()>

Source§

fn swap(&mut self, b: &mut impl HostMemTrait) -> Result<()>

swaps with other smart pointer
Source§

fn create(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()>

allocates new matrix data unless the matrix already has specified size and type.
Source§

fn create_1(&mut self, size: Size, typ: i32) -> Result<()>

Source§

fn release(&mut self) -> Result<()>

decrements reference counter and released memory if needed.
Source§

impl HostMemTraitConst for HostMem

Source§

fn as_raw_HostMem(&self) -> *const c_void

Source§

fn flags(&self) -> i32

Source§

fn rows(&self) -> i32

Source§

fn cols(&self) -> i32

Source§

fn step(&self) -> size_t

Source§

fn data(&self) -> *const u8

Source§

fn refcount(&self) -> *const i32

Source§

fn datastart(&self) -> *const u8

Source§

fn dataend(&self) -> *const u8

Source§

fn alloc_type(&self) -> HostMem_AllocType

Source§

fn try_clone(&self) -> Result<HostMem>

returns deep copy of the matrix, i.e. the data is copied
Source§

fn reshape(&self, cn: i32, rows: i32) -> Result<HostMem>

creates alternative HostMem header for the same data, with different number of channels and/or different number of rows Read more
Source§

fn reshape_def(&self, cn: i32) -> Result<HostMem>

creates alternative HostMem header for the same data, with different number of channels and/or different number of rows Read more
Source§

fn create_mat_header(&self) -> Result<Mat>

returns matrix header with disabled reference counting for HostMem data.
Source§

fn create_gpu_mat_header(&self) -> Result<GpuMat>

Maps CPU memory to GPU address space and creates the cuda::GpuMat header without reference counting for it. Read more
Source§

fn is_continuous(&self) -> Result<bool>

Source§

fn elem_size(&self) -> Result<size_t>

Source§

fn elem_size1(&self) -> Result<size_t>

Source§

fn typ(&self) -> Result<i32>

Source§

fn depth(&self) -> Result<i32>

Source§

fn channels(&self) -> Result<i32>

Source§

fn step1(&self) -> Result<size_t>

Source§

fn size(&self) -> Result<Size>

Source§

fn empty(&self) -> Result<bool>

Source§

impl Send for HostMem

Auto Trait Implementations§

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<Mat> ModifyInplace for Mat
where Mat: Boxed,

Source§

unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res

Helper function to call OpenCV functions that allow in-place modification of a Mat or another similar object. By passing a mutable reference to the Mat to this function your closure will get called with the read reference and a write references to the same Mat. This is unsafe in a general case as it leads to having non-exclusive mutable access to the internal data, but it can be useful for some performance sensitive operations. One example of an OpenCV function that allows such in-place modification is imgproc::threshold. Read more
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.