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
impl HostMem
Sourcepub fn new(alloc_type: HostMem_AllocType) -> Result<HostMem>
pub fn new(alloc_type: HostMem_AllocType) -> Result<HostMem>
§C++ default parameters
- alloc_type: HostMem::AllocType::PAGE_LOCKED
Sourcepub fn new_def() -> Result<HostMem>
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
pub fn copy(m: &impl HostMemTraitConst) -> Result<HostMem>
Sourcepub fn new_1(
rows: i32,
cols: i32,
typ: i32,
alloc_type: HostMem_AllocType,
) -> Result<HostMem>
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
Sourcepub fn new_def_1(rows: i32, cols: i32, typ: i32) -> Result<HostMem>
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
Sourcepub fn new_2(
size: Size,
typ: i32,
alloc_type: HostMem_AllocType,
) -> Result<HostMem>
pub fn new_2( size: Size, typ: i32, alloc_type: HostMem_AllocType, ) -> Result<HostMem>
§C++ default parameters
- alloc_type: HostMem::AllocType::PAGE_LOCKED
Sourcepub fn new_def_2(size: Size, typ: i32) -> Result<HostMem>
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
Sourcepub fn new_3(
arr: &impl ToInputArray,
alloc_type: HostMem_AllocType,
) -> Result<HostMem>
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
Trait Implementations§
Source§impl Boxed for HostMem
impl Boxed for HostMem
Source§unsafe fn from_raw(ptr: <HostMem as OpenCVFromExtern>::ExternReceive) -> Self
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
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
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
fn as_raw_mut( &mut self, ) -> <HostMem as OpenCVTypeExternContainer>::ExternSendMut
Return the underlying mutable raw pointer Read more
Source§impl HostMemTrait for HostMem
impl HostMemTrait for HostMem
fn as_raw_mut_HostMem(&mut self) -> *mut c_void
fn set_flags(&mut self, val: i32)
fn set_rows(&mut self, val: i32)
fn set_cols(&mut self, val: i32)
fn set_step(&mut self, val: size_t)
fn data_mut(&mut self) -> *mut u8
unsafe fn set_data(&mut self, val: *const u8)
fn refcount_mut(&mut self) -> *mut i32
unsafe fn set_refcount(&mut self, val: *const i32)
fn datastart_mut(&mut self) -> *mut u8
unsafe fn set_datastart(&mut self, val: *const u8)
fn set_alloc_type(&mut self, val: HostMem_AllocType)
fn set(&mut self, m: &impl HostMemTraitConst) -> Result<()>
Source§fn create(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()>
fn create(&mut self, rows: i32, cols: i32, typ: i32) -> Result<()>
allocates new matrix data unless the matrix already has specified size and type.
fn create_1(&mut self, size: Size, typ: i32) -> Result<()>
Source§impl HostMemTraitConst for HostMem
impl HostMemTraitConst for HostMem
fn as_raw_HostMem(&self) -> *const c_void
fn flags(&self) -> i32
fn rows(&self) -> i32
fn cols(&self) -> i32
fn step(&self) -> size_t
fn data(&self) -> *const u8
fn refcount(&self) -> *const i32
fn datastart(&self) -> *const u8
fn dataend(&self) -> *const u8
fn alloc_type(&self) -> HostMem_AllocType
Source§fn try_clone(&self) -> Result<HostMem>
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>
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>
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>
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>
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
fn is_continuous(&self) -> Result<bool>
fn elem_size(&self) -> Result<size_t>
fn elem_size1(&self) -> Result<size_t>
fn typ(&self) -> Result<i32>
fn depth(&self) -> Result<i32>
fn channels(&self) -> Result<i32>
fn step1(&self) -> Result<size_t>
fn size(&self) -> Result<Size>
fn empty(&self) -> Result<bool>
impl Send for HostMem
Auto Trait Implementations§
impl Freeze for HostMem
impl RefUnwindSafe for HostMem
impl !Sync for HostMem
impl Unpin for HostMem
impl UnwindSafe for HostMem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
Source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res,
) -> Res
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