pub struct GpuMat { /* private fields */ }
Expand description
Base storage class for GPU memory with reference counting.
Its interface matches the Mat interface with the following limitations:
- no arbitrary dimensions support (only 2D)
- no functions that return references to their data (because references on GPU are not valid for CPU)
- no expression templates technique support
Beware that the latter limitation may lead to overloaded matrix operators that cause memory allocations. The GpuMat class is convertible to cuda::PtrStepSz and cuda::PtrStep so it can be passed directly to the kernel.
Note: In contrast with Mat, in most cases GpuMat::isContinuous() == false . This means that rows are aligned to a size depending on the hardware. Single-row GpuMat is always a continuous matrix.
Note: You are not recommended to leave static or global GpuMat variables allocated, that is, to rely on its destructor. The destruction order of such variables and CUDA context is undefined. GPU memory release function returns error if the CUDA context has been destroyed before.
Some member functions are described as a “Blocking Call” while some are described as a “Non-Blocking Call”. Blocking functions are synchronous to host. It is guaranteed that the GPU operation is finished when the function returns. However, non-blocking functions are asynchronous to host. Those functions may return even if the GPU operation is not finished.
Compared to their blocking counterpart, non-blocking functions accept Stream as an additional argument. If a non-default stream is passed, the GPU operation may overlap with operations in other streams.
§See also
Mat
Implementations§
source§impl GpuMat
impl GpuMat
sourcepub fn default_allocator() -> Result<AbstractRefMut<'static, GpuMat_Allocator>>
pub fn default_allocator() -> Result<AbstractRefMut<'static, GpuMat_Allocator>>
default allocator
pub unsafe fn set_default_allocator( allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<()>
sourcepub unsafe fn new(allocator: &mut impl GpuMat_AllocatorTrait) -> Result<GpuMat>
pub unsafe fn new(allocator: &mut impl GpuMat_AllocatorTrait) -> Result<GpuMat>
sourcepub fn new_def() -> Result<GpuMat>
pub fn new_def() -> Result<GpuMat>
default constructor
§Note
This alternative version of [new] function uses the following default values for its arguments:
- allocator: GpuMat::defaultAllocator()
sourcepub unsafe fn new_rows_cols(
rows: i32,
cols: i32,
typ: i32,
allocator: &mut impl GpuMat_AllocatorTrait
) -> Result<GpuMat>
pub unsafe fn new_rows_cols( rows: i32, cols: i32, typ: i32, allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<GpuMat>
constructs GpuMat of the specified size and type
§C++ default parameters
- allocator: GpuMat::defaultAllocator()
sourcepub fn new_rows_cols_def(rows: i32, cols: i32, typ: i32) -> Result<GpuMat>
pub fn new_rows_cols_def(rows: i32, cols: i32, typ: i32) -> Result<GpuMat>
constructs GpuMat of the specified size and type
§Note
This alternative version of [new_rows_cols] function uses the following default values for its arguments:
- allocator: GpuMat::defaultAllocator()
sourcepub unsafe fn new_size(
size: Size,
typ: i32,
allocator: &mut impl GpuMat_AllocatorTrait
) -> Result<GpuMat>
pub unsafe fn new_size( size: Size, typ: i32, allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<GpuMat>
§C++ default parameters
- allocator: GpuMat::defaultAllocator()
sourcepub fn new_size_def(size: Size, typ: i32) -> Result<GpuMat>
pub fn new_size_def(size: Size, typ: i32) -> Result<GpuMat>
§Note
This alternative version of [new_size] function uses the following default values for its arguments:
- allocator: GpuMat::defaultAllocator()
sourcepub unsafe fn new_rows_cols_with_default(
rows: i32,
cols: i32,
typ: i32,
s: Scalar,
allocator: &mut impl GpuMat_AllocatorTrait
) -> Result<GpuMat>
pub unsafe fn new_rows_cols_with_default( rows: i32, cols: i32, typ: i32, s: Scalar, allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<GpuMat>
constructs GpuMat and fills it with the specified value _s
§C++ default parameters
- allocator: GpuMat::defaultAllocator()
sourcepub fn new_rows_cols_with_default_def(
rows: i32,
cols: i32,
typ: i32,
s: Scalar
) -> Result<GpuMat>
pub fn new_rows_cols_with_default_def( rows: i32, cols: i32, typ: i32, s: Scalar ) -> Result<GpuMat>
constructs GpuMat and fills it with the specified value _s
§Note
This alternative version of [new_rows_cols_with_default] function uses the following default values for its arguments:
- allocator: GpuMat::defaultAllocator()
sourcepub unsafe fn new_size_with_default(
size: Size,
typ: i32,
s: Scalar,
allocator: &mut impl GpuMat_AllocatorTrait
) -> Result<GpuMat>
pub unsafe fn new_size_with_default( size: Size, typ: i32, s: Scalar, allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<GpuMat>
§C++ default parameters
- allocator: GpuMat::defaultAllocator()
sourcepub fn new_size_with_default_def(
size: Size,
typ: i32,
s: Scalar
) -> Result<GpuMat>
pub fn new_size_with_default_def( size: Size, typ: i32, s: Scalar ) -> Result<GpuMat>
§Note
This alternative version of [new_size_with_default] function uses the following default values for its arguments:
- allocator: GpuMat::defaultAllocator()
sourcepub fn copy(m: &impl GpuMatTraitConst) -> Result<GpuMat>
pub fn copy(m: &impl GpuMatTraitConst) -> Result<GpuMat>
copy constructor
sourcepub unsafe fn new_rows_cols_with_data(
rows: i32,
cols: i32,
typ: i32,
data: *mut c_void,
step: size_t
) -> Result<GpuMat>
pub unsafe fn new_rows_cols_with_data( rows: i32, cols: i32, typ: i32, data: *mut c_void, step: size_t ) -> Result<GpuMat>
constructor for GpuMat headers pointing to user-allocated data
§C++ default parameters
- step: Mat::AUTO_STEP
sourcepub unsafe fn new_rows_cols_with_data_def(
rows: i32,
cols: i32,
typ: i32,
data: *mut c_void
) -> Result<GpuMat>
pub unsafe fn new_rows_cols_with_data_def( rows: i32, cols: i32, typ: i32, data: *mut c_void ) -> Result<GpuMat>
constructor for GpuMat headers pointing to user-allocated data
§Note
This alternative version of [new_rows_cols_with_data] function uses the following default values for its arguments:
- step: Mat::AUTO_STEP
sourcepub unsafe fn new_size_with_data(
size: Size,
typ: i32,
data: *mut c_void,
step: size_t
) -> Result<GpuMat>
pub unsafe fn new_size_with_data( size: Size, typ: i32, data: *mut c_void, step: size_t ) -> Result<GpuMat>
§C++ default parameters
- step: Mat::AUTO_STEP
sourcepub unsafe fn new_size_with_data_def(
size: Size,
typ: i32,
data: *mut c_void
) -> Result<GpuMat>
pub unsafe fn new_size_with_data_def( size: Size, typ: i32, data: *mut c_void ) -> Result<GpuMat>
§Note
This alternative version of [new_size_with_data] function uses the following default values for its arguments:
- step: Mat::AUTO_STEP
sourcepub fn rowscols(
m: &impl GpuMatTraitConst,
row_range: impl RangeTrait,
col_range: impl RangeTrait
) -> Result<BoxedRef<'_, GpuMat>>
pub fn rowscols( m: &impl GpuMatTraitConst, row_range: impl RangeTrait, col_range: impl RangeTrait ) -> Result<BoxedRef<'_, GpuMat>>
creates a GpuMat header for a part of the bigger matrix
sourcepub fn rowscols_mut(
m: &mut impl GpuMatTrait,
row_range: impl RangeTrait,
col_range: impl RangeTrait
) -> Result<BoxedRefMut<'_, GpuMat>>
pub fn rowscols_mut( m: &mut impl GpuMatTrait, row_range: impl RangeTrait, col_range: impl RangeTrait ) -> Result<BoxedRefMut<'_, GpuMat>>
creates a GpuMat header for a part of the bigger matrix
pub fn roi(m: &impl GpuMatTraitConst, roi: Rect) -> Result<BoxedRef<'_, GpuMat>>
pub fn roi_mut( m: &mut impl GpuMatTrait, roi: Rect ) -> Result<BoxedRefMut<'_, GpuMat>>
sourcepub unsafe fn from_hostmem(
arr: &impl ToInputArray,
allocator: &mut impl GpuMat_AllocatorTrait
) -> Result<GpuMat>
pub unsafe fn from_hostmem( arr: &impl ToInputArray, allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<GpuMat>
builds GpuMat from host memory (Blocking call)
§C++ default parameters
- allocator: GpuMat::defaultAllocator()
sourcepub fn from_hostmem_def(arr: &impl ToInputArray) -> Result<GpuMat>
pub fn from_hostmem_def(arr: &impl ToInputArray) -> Result<GpuMat>
builds GpuMat from host memory (Blocking call)
§Note
This alternative version of [from_hostmem] function uses the following default values for its arguments:
- allocator: GpuMat::defaultAllocator()