Struct opencv::core::GpuMat

source ·
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

source

pub fn default_allocator() -> Result<AbstractRefMut<'static, GpuMat_Allocator>>

default allocator

source

pub unsafe fn set_default_allocator( allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<()>

source

pub unsafe fn new(allocator: &mut impl GpuMat_AllocatorTrait) -> Result<GpuMat>

default constructor

§C++ default parameters
  • allocator: GpuMat::defaultAllocator()
source

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()
source

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()
source

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()
source

pub unsafe fn new_size( size: Size, typ: i32, allocator: &mut impl GpuMat_AllocatorTrait ) -> Result<GpuMat>

§C++ default parameters
  • allocator: GpuMat::defaultAllocator()
source

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()
source

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()
source

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()
source

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()
source

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()
source

pub fn copy(m: &impl GpuMatTraitConst) -> Result<GpuMat>

copy constructor

source

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
source

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
source

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
source

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
source

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

source

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

source

pub fn roi(m: &impl GpuMatTraitConst, roi: Rect) -> Result<BoxedRef<'_, GpuMat>>

source

pub fn roi_mut( m: &mut impl GpuMatTrait, roi: Rect ) -> Result<BoxedRefMut<'_, GpuMat>>

source

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()
source

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()

Trait Implementations§

source§

impl Boxed for GpuMat

source§

unsafe fn from_raw(ptr: <GpuMat as OpenCVType<'_>>::ExternReceive) -> Self

Wrap the specified raw pointer Read more
source§

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

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

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

Return the underlying raw pointer. Read more
source§

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

Return the underlying mutable raw pointer Read more
source§

impl Clone for GpuMat

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 GpuMat

source§

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

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

impl Drop for GpuMat

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl GpuMatTrait for GpuMat

source§

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

source§

fn set_flags(&mut self, val: i32)

! includes several bit-fields: Read more
source§

fn set_rows(&mut self, val: i32)

the number of rows and columns
source§

fn set_cols(&mut self, val: i32)

the number of rows and columns
source§

fn set_step(&mut self, val: size_t)

a distance between successive rows in bytes; includes the gap if any
source§

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

pointer to the data
source§

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

pointer to the data
source§

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

pointer to the reference counter; when GpuMat points to user-allocated data, the pointer is NULL
source§

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

pointer to the reference counter; when GpuMat points to user-allocated data, the pointer is NULL
source§

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

helper fields used in locateROI and adjustROI
source§

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

helper fields used in locateROI and adjustROI
source§

fn allocator(&mut self) -> AbstractRefMut<'_, GpuMat_Allocator>

allocator
source§

unsafe fn set_allocator(&mut self, val: &impl GpuMat_AllocatorTraitConst)

allocator
source§

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

assignment operators
source§

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

allocates new GpuMat data unless the GpuMat already has specified size and type
source§

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

source§

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

decreases reference counter, deallocate the data when reference counter reaches 0
source§

fn swap(&mut self, mat: &mut impl GpuMatTrait) -> Result<()>

swaps with other smart pointer
source§

fn upload(&mut self, arr: &impl ToInputArray) -> Result<()>

Performs data upload to GpuMat (Blocking call) Read more
source§

fn upload_async( &mut self, arr: &impl ToInputArray, stream: &mut impl StreamTrait ) -> Result<()>

Performs data upload to GpuMat (Non-Blocking call) Read more
source§

fn set_to(&mut self, s: Scalar) -> Result<GpuMat>

sets some of the GpuMat elements to s (Blocking call)
source§

fn set_to_1( &mut self, s: Scalar, stream: &mut impl StreamTrait ) -> Result<GpuMat>

sets some of the GpuMat elements to s (Non-Blocking call)
source§

fn set_to_2(&mut self, s: Scalar, mask: &impl ToInputArray) -> Result<GpuMat>

sets some of the GpuMat elements to s, according to the mask (Blocking call)
source§

fn set_to_3( &mut self, s: Scalar, mask: &impl ToInputArray, stream: &mut impl StreamTrait ) -> Result<GpuMat>

sets some of the GpuMat elements to s, according to the mask (Non-Blocking call)
source§

fn ptr_mut(&mut self, y: i32) -> Result<*mut u8>

returns pointer to y-th row Read more
source§

fn ptr_mut_def(&mut self) -> Result<*mut u8>

returns pointer to y-th row Read more
source§

fn row_mut(&mut self, y: i32) -> Result<BoxedRefMut<'_, GpuMat>>

returns a new GpuMat header for the specified row
source§

fn col_mut(&mut self, x: i32) -> Result<BoxedRefMut<'_, GpuMat>>

returns a new GpuMat header for the specified column
source§

fn row_bounds_mut( &mut self, startrow: i32, endrow: i32 ) -> Result<BoxedRefMut<'_, GpuMat>>

… for the specified row span
source§

fn row_range_mut( &mut self, r: impl RangeTrait ) -> Result<BoxedRefMut<'_, GpuMat>>

source§

fn col_bounds_mut( &mut self, startcol: i32, endcol: i32 ) -> Result<BoxedRefMut<'_, GpuMat>>

… for the specified column span
source§

fn col_range_mut( &mut self, r: impl RangeTrait ) -> Result<BoxedRefMut<'_, GpuMat>>

source§

fn rowscols_mut( &mut self, row_range: impl RangeTrait, col_range: impl RangeTrait ) -> Result<BoxedRefMut<'_, GpuMat>>

extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.)
source§

fn roi_mut(&mut self, roi: Rect) -> Result<BoxedRefMut<'_, GpuMat>>

source§

fn reshape_def_mut(&mut self, cn: i32) -> Result<BoxedRefMut<'_, GpuMat>>

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

fn reshape_mut(&mut self, cn: i32, rows: i32) -> Result<BoxedRefMut<'_, GpuMat>>

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

fn adjust_roi( &mut self, dtop: i32, dbottom: i32, dleft: i32, dright: i32 ) -> Result<GpuMat>

moves/resizes the current GpuMat ROI inside the parent GpuMat
source§

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

internal use method: updates the continuity flag
source§

impl GpuMatTraitConst for GpuMat

source§

fn as_raw_GpuMat(&self) -> *const c_void

source§

fn flags(&self) -> i32

! includes several bit-fields: Read more
source§

fn rows(&self) -> i32

the number of rows and columns
source§

fn cols(&self) -> i32

the number of rows and columns
source§

fn step(&self) -> size_t

a distance between successive rows in bytes; includes the gap if any
source§

fn data(&self) -> *const u8

pointer to the data
source§

fn refcount(&self) -> *const i32

pointer to the reference counter; when GpuMat points to user-allocated data, the pointer is NULL
source§

fn datastart(&self) -> *const u8

helper fields used in locateROI and adjustROI
source§

fn dataend(&self) -> *const u8

source§

fn download(&self, dst: &mut impl ToOutputArray) -> Result<()>

Performs data download from GpuMat (Blocking call) Read more
source§

fn download_async( &self, dst: &mut impl ToOutputArray, stream: &mut impl StreamTrait ) -> Result<()>

Performs data download from GpuMat (Non-Blocking call) Read more
source§

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

returns deep copy of the GpuMat, i.e. the data is copied
source§

fn copy_to(&self, dst: &mut impl ToOutputArray) -> Result<()>

copies the GpuMat content to device memory (Blocking call)
source§

fn copy_to_gpu_mat(&self, dst: &mut impl GpuMatTrait) -> Result<()>

bindings overload which copies the GpuMat content to device memory (Blocking call)
source§

fn copy_to_stream( &self, dst: &mut impl ToOutputArray, stream: &mut impl StreamTrait ) -> Result<()>

copies the GpuMat content to device memory (Non-Blocking call)
source§

fn copy_to_gpu_mat_stream( &self, dst: &mut impl GpuMatTrait, stream: &mut impl StreamTrait ) -> Result<()>

bindings overload which copies the GpuMat content to device memory (Non-Blocking call)
source§

fn copy_to_mask( &self, dst: &mut impl ToOutputArray, mask: &impl ToInputArray ) -> Result<()>

copies those GpuMat elements to “m” that are marked with non-zero mask elements (Blocking call)
source§

fn copy_to_gpu_mat_mask( &self, dst: &mut impl GpuMatTrait, mask: &mut impl GpuMatTrait ) -> Result<()>

bindings overload which copies those GpuMat elements to “m” that are marked with non-zero mask elements (Blocking call)
source§

fn copy_to_mask_stream( &self, dst: &mut impl ToOutputArray, mask: &impl ToInputArray, stream: &mut impl StreamTrait ) -> Result<()>

copies those GpuMat elements to “m” that are marked with non-zero mask elements (Non-Blocking call)
source§

fn copy_to_gpu_mat_mask_stream( &self, dst: &mut impl GpuMatTrait, mask: &mut impl GpuMatTrait, stream: &mut impl StreamTrait ) -> Result<()>

bindings overload which copies those GpuMat elements to “m” that are marked with non-zero mask elements (Non-Blocking call)
source§

fn convert_to(&self, dst: &mut impl ToOutputArray, rtype: i32) -> Result<()>

converts GpuMat to another datatype (Blocking call)
source§

fn convert_to_1( &self, dst: &mut impl ToOutputArray, rtype: i32, stream: &mut impl StreamTrait ) -> Result<()>

converts GpuMat to another datatype (Non-Blocking call)
source§

fn convert_to_2( &self, dst: &mut impl GpuMatTrait, rtype: i32, stream: &mut impl StreamTrait ) -> Result<()>

bindings overload which converts GpuMat to another datatype (Non-Blocking call)
source§

fn convert_to_3( &self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64 ) -> Result<()>

converts GpuMat to another datatype with scaling (Blocking call) Read more
source§

fn convert_to_def( &self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64 ) -> Result<()>

converts GpuMat to another datatype with scaling (Blocking call) Read more
source§

fn convert_to_4( &self, dst: &mut impl GpuMatTrait, rtype: i32, alpha: f64, beta: f64 ) -> Result<()>

bindings overload which converts GpuMat to another datatype with scaling(Blocking call) Read more
source§

fn convert_to_def_1(&self, dst: &mut impl GpuMatTrait, rtype: i32) -> Result<()>

bindings overload which converts GpuMat to another datatype with scaling(Blocking call) Read more
source§

fn convert_to_5( &self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, stream: &mut impl StreamTrait ) -> Result<()>

converts GpuMat to another datatype with scaling (Non-Blocking call)
source§

fn convert_to_6( &self, dst: &mut impl ToOutputArray, rtype: i32, alpha: f64, beta: f64, stream: &mut impl StreamTrait ) -> Result<()>

converts GpuMat to another datatype with scaling (Non-Blocking call)
source§

fn convert_to_7( &self, dst: &mut impl GpuMatTrait, rtype: i32, alpha: f64, beta: f64, stream: &mut impl StreamTrait ) -> Result<()>

bindings overload which converts GpuMat to another datatype with scaling (Non-Blocking call)
source§

fn assign_to(&self, m: &mut impl GpuMatTrait, typ: i32) -> Result<()>

C++ default parameters Read more
source§

fn assign_to_def(&self, m: &mut impl GpuMatTrait) -> Result<()>

source§

fn ptr(&self, y: i32) -> Result<*const u8>

C++ default parameters Read more
source§

fn ptr_def(&self) -> Result<*const u8>

source§

fn row(&self, y: i32) -> Result<BoxedRef<'_, GpuMat>>

returns a new GpuMat header for the specified row
source§

fn col(&self, x: i32) -> Result<BoxedRef<'_, GpuMat>>

returns a new GpuMat header for the specified column
source§

fn row_bounds(&self, startrow: i32, endrow: i32) -> Result<BoxedRef<'_, GpuMat>>

… for the specified row span
source§

fn row_range(&self, r: impl RangeTrait) -> Result<BoxedRef<'_, GpuMat>>

source§

fn col_bounds(&self, startcol: i32, endcol: i32) -> Result<BoxedRef<'_, GpuMat>>

… for the specified column span
source§

fn col_range(&self, r: impl RangeTrait) -> Result<BoxedRef<'_, GpuMat>>

source§

fn rowscols( &self, row_range: impl RangeTrait, col_range: impl RangeTrait ) -> Result<BoxedRef<'_, GpuMat>>

extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.)
source§

fn roi(&self, roi: Rect) -> Result<BoxedRef<'_, GpuMat>>

source§

fn reshape(&self, cn: i32, rows: i32) -> Result<BoxedRef<'_, GpuMat>>

creates alternative GpuMat 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<BoxedRef<'_, GpuMat>>

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

fn locate_roi(&self, whole_size: &mut Size, ofs: &mut Point) -> Result<()>

locates GpuMat header within a parent GpuMat
source§

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

returns true iff the GpuMat data is continuous (i.e. when there are no gaps between successive rows)
source§

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

returns element size in bytes
source§

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

returns the size of element channel in bytes
source§

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

returns element type
source§

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

returns element type
source§

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

returns number of channels
source§

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

returns step/elemSize1()
source§

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

returns GpuMat size : width == number of columns, height == number of rows
source§

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

returns true if GpuMat data is NULL
source§

fn cuda_ptr(&self) -> Result<*mut c_void>

source§

impl ToInputArray for &GpuMat

source§

impl ToInputArray for GpuMat

source§

impl ToInputOutputArray for &mut GpuMat

source§

impl ToInputOutputArray for GpuMat

source§

impl ToOutputArray for &mut GpuMat

source§

impl ToOutputArray for GpuMat

source§

impl Send for GpuMat

source§

impl VectorElement for GpuMat
where Vector<GpuMat>: VectorExtern<GpuMat>,

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> 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,

§

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>,

§

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>,

§

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.