Class cv::cuda::GpuMat#
Base storage class for GPU memory with reference counting. View details
#include <opencv2/core/cuda.hpp>Collaboration diagram for cv::cuda::GpuMat:
Detailed 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.
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
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.
Constructor & Destructor Documentation#
GpuMat()#
cv::cuda::GpuMat::GpuMat(const GpuMat & m)
Python:
copy constructor
GpuMat()#
cv::cuda::GpuMat::GpuMat(
const GpuMat & m,
Range rowRange,
Range colRange )
Python:
creates a GpuMat header for a part of the bigger matrix
GpuMat()#
cv::cuda::GpuMat::GpuMat(
const GpuMat & m,
Rect roi )
Python:
GpuMat()#
cv::cuda::GpuMat::GpuMat(GpuMat::Allocator * allocator = GpuMat::defaultAllocator())
Python:
default constructor
GpuMat()#
cv::cuda::GpuMat::GpuMat(
InputArray arr,
GpuMat::Allocator * allocator = GpuMat::defaultAllocator() )
Python:
builds GpuMat from host memory (Blocking call)
GpuMat()#
cv::cuda::GpuMat::GpuMat(
int rows,
int cols,
int type,
GpuMat::Allocator * allocator = GpuMat::defaultAllocator() )
Python:
constructs GpuMat of the specified size and type
GpuMat()#
cv::cuda::GpuMat::GpuMat(
int rows,
int cols,
int type,
Scalar s,
GpuMat::Allocator * allocator = GpuMat::defaultAllocator() )
Python:
constructs GpuMat and fills it with the specified value _s
GpuMat()#
cv::cuda::GpuMat::GpuMat(
int rows,
int cols,
int type,
void * data,
size_t step = Mat::AUTO_STEP )
Python:
constructor for GpuMat headers pointing to user-allocated data
GpuMat()#
cv::cuda::GpuMat::GpuMat(
Size size,
int type,
GpuMat::Allocator * allocator = GpuMat::defaultAllocator() )
Python:
GpuMat()#
cv::cuda::GpuMat::GpuMat(
Size size,
int type,
Scalar s,
GpuMat::Allocator * allocator = GpuMat::defaultAllocator() )
Python:
GpuMat()#
cv::cuda::GpuMat::GpuMat(
Size size,
int type,
void * data,
size_t step = Mat::AUTO_STEP )
Python:
~GpuMat()#
destructor - calls release()
Member Function Documentation#
defaultAllocator()#
static GpuMat::Allocator * cv::cuda::GpuMat::defaultAllocator()
Python:
cv.cuda.GpuMat.defaultAllocator() -> retval
cv.cuda.GpuMat_defaultAllocator() -> retval
default allocator
getStdAllocator()#
static GpuMat::Allocator * cv::cuda::GpuMat::getStdAllocator()
Python:
cv.cuda.GpuMat.getStdAllocator() -> retval
cv.cuda.GpuMat_getStdAllocator() -> retval
setDefaultAllocator()#
static void cv::cuda::GpuMat::setDefaultAllocator(GpuMat::Allocator * allocator)
Python:
cv.cuda.GpuMat.setDefaultAllocator(allocator)
cv.cuda.GpuMat_setDefaultAllocator(allocator)
adjustROI()#
GpuMat & cv::cuda::GpuMat::adjustROI(
int dtop,
int dbottom,
int dleft,
int dright )
Python:
cv.cuda.GpuMat.adjustROI(dtop, dbottom, dleft, dright) -> retval
moves/resizes the current GpuMat ROI inside the parent GpuMat
assignTo()#
void cv::cuda::GpuMat::assignTo(
GpuMat & m,
int type = -1 )
Python:
channels()#
int cv::cuda::GpuMat::channels()
Python:
cv.cuda.GpuMat.channels() -> retval
returns number of channels
clone()#
GpuMat cv::cuda::GpuMat::clone()
Python:
cv.cuda.GpuMat.clone() -> retval
returns deep copy of the GpuMat, i.e. the data is copied
col()#
GpuMat cv::cuda::GpuMat::col(int x)
Python:
cv.cuda.GpuMat.col(x) -> retval
returns a new GpuMat header for the specified column
colRange()#
GpuMat cv::cuda::GpuMat::colRange(
int startcol,
int endcol )
Python:
cv.cuda.GpuMat.colRange(startcol, endcol) -> retval
cv.cuda.GpuMat.colRange(r) -> retval
… for the specified column span
colRange()#
GpuMat cv::cuda::GpuMat::colRange(Range r)
Python:
cv.cuda.GpuMat.colRange(startcol, endcol) -> retval
cv.cuda.GpuMat.colRange(r) -> retval
convertTo()#
void cv::cuda::GpuMat::convertTo(
GpuMat & dst,
int rtype )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
bindings overload which converts GpuMat to another datatype (Blocking call)
convertTo()#
void cv::cuda::GpuMat::convertTo(
GpuMat & dst,
int rtype,
double alpha,
double beta,
Stream & stream )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
bindings overload which converts GpuMat to another datatype with scaling (Non-Blocking call)
convertTo()#
void cv::cuda::GpuMat::convertTo(
GpuMat & dst,
int rtype,
Stream & stream )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
bindings overload which converts GpuMat to another datatype (Non-Blocking call)
convertTo()#
void cv::cuda::GpuMat::convertTo(
OutputArray dst,
int rtype )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
converts GpuMat to another datatype (Blocking call)
convertTo()#
void cv::cuda::GpuMat::convertTo(
OutputArray dst,
int rtype,
double alpha,
double beta,
Stream & stream )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
converts GpuMat to another datatype with scaling (Non-Blocking call)
convertTo()#
void cv::cuda::GpuMat::convertTo(
OutputArray dst,
int rtype,
double alpha,
double beta = 0.0 )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
converts GpuMat to another datatype with scaling (Blocking call)
convertTo()#
void cv::cuda::GpuMat::convertTo(
OutputArray dst,
int rtype,
double alpha,
Stream & stream )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
bindings overload which converts GpuMat to another datatype with scaling(Blocking call)
converts GpuMat to another datatype with scaling (Non-Blocking call)
convertTo()#
void cv::cuda::GpuMat::convertTo(
OutputArray dst,
int rtype,
Stream & stream )
Python:
cv.cuda.GpuMat.convertTo(rtype[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype, stream[, dst]) -> dst
cv.cuda.GpuMat.convertTo(rtype[, dst[, alpha[, beta]]]) -> dst
cv.cuda.GpuMat.convertTo(rtype, alpha, beta, stream[, dst]) -> dst
converts GpuMat to another datatype (Non-Blocking call)
copyTo()#
void cv::cuda::GpuMat::copyTo(GpuMat & dst)
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
bindings overload which copies the GpuMat content to device memory (Blocking call)
Here is the call graph for this function:
copyTo()#
void cv::cuda::GpuMat::copyTo(
GpuMat & dst,
GpuMat & mask )
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
bindings overload which copies those GpuMat elements to “m” that are marked with non-zero mask elements (Blocking call)
Here is the call graph for this function:
copyTo()#
void cv::cuda::GpuMat::copyTo(
GpuMat & dst,
GpuMat & mask,
Stream & stream )
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
bindings overload which copies those GpuMat elements to “m” that are marked with non-zero mask elements (Non-Blocking call)
Here is the call graph for this function:
copyTo()#
void cv::cuda::GpuMat::copyTo(
GpuMat & dst,
Stream & stream )
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
bindings overload which copies the GpuMat content to device memory (Non-Blocking call)
Here is the call graph for this function:
copyTo()#
void cv::cuda::GpuMat::copyTo(OutputArray dst)
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
copies the GpuMat content to device memory (Blocking call)
copyTo()#
void cv::cuda::GpuMat::copyTo(
OutputArray dst,
InputArray mask )
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
copies those GpuMat elements to “m” that are marked with non-zero mask elements (Blocking call)
copyTo()#
void cv::cuda::GpuMat::copyTo(
OutputArray dst,
InputArray mask,
Stream & stream )
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
copies those GpuMat elements to “m” that are marked with non-zero mask elements (Non-Blocking call)
copyTo()#
void cv::cuda::GpuMat::copyTo(
OutputArray dst,
Stream & stream )
Python:
cv.cuda.GpuMat.copyTo([, dst]) -> dst
cv.cuda.GpuMat.copyTo(stream[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask[, dst]) -> dst
cv.cuda.GpuMat.copyTo(mask, stream[, dst]) -> dst
copies the GpuMat content to device memory (Non-Blocking call)
create()#
void cv::cuda::GpuMat::create(
int rows,
int cols,
int type )
Python:
allocates new GpuMat data unless the GpuMat already has specified size and type
create()#
void cv::cuda::GpuMat::create(
Size size,
int type )
Python:
cudaPtr()#
void * cv::cuda::GpuMat::cudaPtr()
Python:
cv.cuda.GpuMat.cudaPtr() -> retval
depth()#
int cv::cuda::GpuMat::depth()
Python:
cv.cuda.GpuMat.depth() -> retval
returns element type
download()#
void cv::cuda::GpuMat::download(OutputArray dst)
Python:
cv.cuda.GpuMat.download([, dst]) -> dst
cv.cuda.GpuMat.download(stream[, dst]) -> dst
Performs data download from GpuMat (Blocking call)
This function copies data from device memory to host memory. As being a blocking call, it is guaranteed that the copy operation is finished when this function returns.
download()#
void cv::cuda::GpuMat::download(
OutputArray dst,
Stream & stream )
Python:
cv.cuda.GpuMat.download([, dst]) -> dst
cv.cuda.GpuMat.download(stream[, dst]) -> dst
Performs data download from GpuMat (Non-Blocking call)
This function copies data from device memory to host memory. As being a non-blocking call, this function may return even if the copy operation is not finished.
The copy operation may be overlapped with operations in other non-default streams if stream is not the default stream and dst is HostMem allocated with HostMem::PAGE_LOCKED option.
elemSize()#
size_t cv::cuda::GpuMat::elemSize()
Python:
cv.cuda.GpuMat.elemSize() -> retval
returns element size in bytes
elemSize1()#
size_t cv::cuda::GpuMat::elemSize1()
Python:
cv.cuda.GpuMat.elemSize1() -> retval
returns the size of element channel in bytes
empty()#
bool cv::cuda::GpuMat::empty()
Python:
cv.cuda.GpuMat.empty() -> retval
returns true if GpuMat data is NULL
fit()#
void cv::cuda::GpuMat::fit(
int rows,
int cols,
int type )
allocates or reuses underlying storage to fit the requested 2D size and type (no-op if already compatible)
fit()#
isContinuous()#
bool cv::cuda::GpuMat::isContinuous()
Python:
cv.cuda.GpuMat.isContinuous() -> retval
returns true iff the GpuMat data is continuous (i.e. when there are no gaps between successive rows)
locateROI()#
void cv::cuda::GpuMat::locateROI(
Size & wholeSize,
Point & ofs )
Python:
cv.cuda.GpuMat.locateROI(wholeSize, ofs)
locates GpuMat header within a parent GpuMat
operator PtrStep< _Tp >()#
template<typename _Tp>
cv::cuda::GpuMat::operator PtrStep< _Tp >()
operator PtrStepSz< _Tp >()#
template<typename _Tp>
cv::cuda::GpuMat::operator PtrStepSz< _Tp >()
operator()()#
GpuMat cv::cuda::GpuMat::operator()(
Range rowRange,
Range colRange )
extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.)
operator()()#
operator=()#
GpuMat & cv::cuda::GpuMat::operator=(const GpuMat & m)
assignment operators
ptr()#
uchar * cv::cuda::GpuMat::ptr(int y = 0)
returns pointer to y-th row
ptr()#
template<typename _Tp>
_Tp * cv::cuda::GpuMat::ptr(int y = 0)
template version of the above method
ptr()#
ptr()#
template<typename _Tp>
const _Tp * cv::cuda::GpuMat::ptr(int y = 0)
release()#
void cv::cuda::GpuMat::release()
Python:
cv.cuda.GpuMat.release()
decreases reference counter, deallocate the data when reference counter reaches 0
reshape()#
GpuMat cv::cuda::GpuMat::reshape(
int cn,
int rows = 0 )
Python:
cv.cuda.GpuMat.reshape(cn[, rows]) -> retval
creates alternative GpuMat header for the same data, with different number of channels and/or different number of rows
row()#
GpuMat cv::cuda::GpuMat::row(int y)
Python:
cv.cuda.GpuMat.row(y) -> retval
returns a new GpuMat header for the specified row
rowRange()#
GpuMat cv::cuda::GpuMat::rowRange(
int startrow,
int endrow )
Python:
cv.cuda.GpuMat.rowRange(startrow, endrow) -> retval
cv.cuda.GpuMat.rowRange(r) -> retval
… for the specified row span
rowRange()#
GpuMat cv::cuda::GpuMat::rowRange(Range r)
Python:
cv.cuda.GpuMat.rowRange(startrow, endrow) -> retval
cv.cuda.GpuMat.rowRange(r) -> retval
setTo()#
GpuMat & cv::cuda::GpuMat::setTo(Scalar s)
Python:
cv.cuda.GpuMat.setTo(s) -> retval
cv.cuda.GpuMat.setTo(s, stream) -> retval
cv.cuda.GpuMat.setTo(s, mask) -> retval
cv.cuda.GpuMat.setTo(s, mask, stream) -> retval
sets some of the GpuMat elements to s (Blocking call)
setTo()#
GpuMat & cv::cuda::GpuMat::setTo(
Scalar s,
InputArray mask )
Python:
cv.cuda.GpuMat.setTo(s) -> retval
cv.cuda.GpuMat.setTo(s, stream) -> retval
cv.cuda.GpuMat.setTo(s, mask) -> retval
cv.cuda.GpuMat.setTo(s, mask, stream) -> retval
sets some of the GpuMat elements to s, according to the mask (Blocking call)
setTo()#
GpuMat & cv::cuda::GpuMat::setTo(
Scalar s,
InputArray mask,
Stream & stream )
Python:
cv.cuda.GpuMat.setTo(s) -> retval
cv.cuda.GpuMat.setTo(s, stream) -> retval
cv.cuda.GpuMat.setTo(s, mask) -> retval
cv.cuda.GpuMat.setTo(s, mask, stream) -> retval
sets some of the GpuMat elements to s, according to the mask (Non-Blocking call)
setTo()#
GpuMat & cv::cuda::GpuMat::setTo(
Scalar s,
Stream & stream )
Python:
cv.cuda.GpuMat.setTo(s) -> retval
cv.cuda.GpuMat.setTo(s, stream) -> retval
cv.cuda.GpuMat.setTo(s, mask) -> retval
cv.cuda.GpuMat.setTo(s, mask, stream) -> retval
sets some of the GpuMat elements to s (Non-Blocking call)
size()#
Python:
cv.cuda.GpuMat.size() -> retval
returns GpuMat size : width == number of columns, height == number of rows
step1()#
size_t cv::cuda::GpuMat::step1()
Python:
cv.cuda.GpuMat.step1() -> retval
returns step/elemSize1()
swap()#
void cv::cuda::GpuMat::swap(GpuMat & mat)
Python:
cv.cuda.GpuMat.swap(mat)
swaps with other smart pointer
type()#
Python:
returns element type
updateContinuityFlag()#
void cv::cuda::GpuMat::updateContinuityFlag()
Python:
cv.cuda.GpuMat.updateContinuityFlag()
internal use method: updates the continuity flag
upload()#
void cv::cuda::GpuMat::upload(InputArray arr)
Python:
cv.cuda.GpuMat.upload(arr)
cv.cuda.GpuMat.upload(arr, stream)
Performs data upload to GpuMat (Blocking call)
This function copies data from host memory to device memory. As being a blocking call, it is guaranteed that the copy operation is finished when this function returns.
upload()#
void cv::cuda::GpuMat::upload(
InputArray arr,
Stream & stream )
Python:
cv.cuda.GpuMat.upload(arr)
cv.cuda.GpuMat.upload(arr, stream)
Performs data upload to GpuMat (Non-Blocking call)
This function copies data from host memory to device memory. As being a non-blocking call, this function may return even if the copy operation is not finished.
The copy operation may be overlapped with operations in other non-default streams if stream is not the default stream and dst is HostMem allocated with HostMem::PAGE_LOCKED option.
Member Data Documentation#
allocator#
Allocator * cv::cuda::GpuMat::allocator
allocator
cols#
int cv::cuda::GpuMat::cols
data#
uchar * cv::cuda::GpuMat::data
pointer to the data
dataend#
datastart#
uchar * cv::cuda::GpuMat::datastart
helper fields used in locateROI and adjustROI
flags#
int cv::cuda::GpuMat::flags
includes several bit-fields:
the magic signature
continuity flag
depth
number of channels
refcount#
int * cv::cuda::GpuMat::refcount
pointer to the reference counter; when GpuMat points to user-allocated data, the pointer is NULL
rows#
int cv::cuda::GpuMat::rows
the number of rows and columns
step#
size_t cv::cuda::GpuMat::step
a distance between successive rows in bytes; includes the gap if any
Source file#
The documentation for this class was generated from the following file:
opencv2/core/cuda.hpp