OpenCV453
クラス | 公開メンバ関数 | 静的公開メンバ関数 | 公開変数類 | 全メンバ一覧

Base storage class for GPU memory with reference counting. [詳解]

#include <cuda.hpp>

クラス

class  Allocator
 

公開メンバ関数

CV_WRAP GpuMat (GpuMat::Allocator *allocator=GpuMat::defaultAllocator())
 default constructor
 
CV_WRAP GpuMat (int rows, int cols, int type, GpuMat::Allocator *allocator=GpuMat::defaultAllocator())
 constructs GpuMat of the specified size and type
 
CV_WRAP GpuMat (Size size, int type, GpuMat::Allocator *allocator=GpuMat::defaultAllocator())
 
CV_WRAP GpuMat (int rows, int cols, int type, Scalar s, GpuMat::Allocator *allocator=GpuMat::defaultAllocator())
 constructs GpuMat and fills it with the specified value _s
 
CV_WRAP GpuMat (Size size, int type, Scalar s, GpuMat::Allocator *allocator=GpuMat::defaultAllocator())
 
CV_WRAP GpuMat (const GpuMat &m)
 copy constructor
 
 GpuMat (int rows, int cols, int type, void *data, size_t step=Mat::AUTO_STEP)
 constructor for GpuMat headers pointing to user-allocated data
 
 GpuMat (Size size, int type, void *data, size_t step=Mat::AUTO_STEP)
 
CV_WRAP GpuMat (const GpuMat &m, Range rowRange, Range colRange)
 creates a GpuMat header for a part of the bigger matrix
 
CV_WRAP GpuMat (const GpuMat &m, Rect roi)
 
CV_WRAP GpuMat (InputArray arr, GpuMat::Allocator *allocator=GpuMat::defaultAllocator())
 builds GpuMat from host memory (Blocking call)
 
 ~GpuMat ()
 destructor - calls release()
 
GpuMatoperator= (const GpuMat &m)
 assignment operators
 
CV_WRAP void create (int rows, int cols, int type)
 allocates new GpuMat data unless the GpuMat already has specified size and type
 
CV_WRAP void create (Size size, int type)
 
void release ()
 decreases reference counter, deallocate the data when reference counter reaches 0
 
CV_WRAP void swap (GpuMat &mat)
 swaps with other smart pointer
 
CV_WRAP void upload (InputArray arr)
 Performs data upload to GpuMat (Blocking call) [詳解]
 
CV_WRAP void upload (InputArray arr, Stream &stream)
 Performs data upload to GpuMat (Non-Blocking call) [詳解]
 
CV_WRAP void download (OutputArray dst) const
 Performs data download from GpuMat (Blocking call) [詳解]
 
CV_WRAP void download (OutputArray dst, Stream &stream) const
 Performs data download from GpuMat (Non-Blocking call) [詳解]
 
CV_WRAP GpuMat clone () const
 returns deep copy of the GpuMat, i.e. the data is copied
 
CV_WRAP void copyTo (OutputArray dst) const
 copies the GpuMat content to device memory (Blocking call)
 
CV_WRAP void copyTo (OutputArray dst, Stream &stream) const
 copies the GpuMat content to device memory (Non-Blocking call)
 
CV_WRAP void copyTo (OutputArray dst, InputArray mask) const
 copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call)
 
CV_WRAP void copyTo (OutputArray dst, InputArray mask, Stream &stream) const
 copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call)
 
CV_WRAP GpuMatsetTo (Scalar s)
 sets some of the GpuMat elements to s (Blocking call)
 
CV_WRAP GpuMatsetTo (Scalar s, Stream &stream)
 sets some of the GpuMat elements to s (Non-Blocking call)
 
CV_WRAP GpuMatsetTo (Scalar s, InputArray mask)
 sets some of the GpuMat elements to s, according to the mask (Blocking call)
 
CV_WRAP GpuMatsetTo (Scalar s, InputArray mask, Stream &stream)
 sets some of the GpuMat elements to s, according to the mask (Non-Blocking call)
 
CV_WRAP void convertTo (OutputArray dst, int rtype) const
 converts GpuMat to another datatype (Blocking call)
 
CV_WRAP void convertTo (OutputArray dst, int rtype, Stream &stream) const
 converts GpuMat to another datatype (Non-Blocking call)
 
CV_WRAP void convertTo (OutputArray dst, int rtype, double alpha, double beta=0.0) const
 converts GpuMat to another datatype with scaling (Blocking call)
 
CV_WRAP void convertTo (OutputArray dst, int rtype, double alpha, Stream &stream) const
 converts GpuMat to another datatype with scaling (Non-Blocking call)
 
CV_WRAP void convertTo (OutputArray dst, int rtype, double alpha, double beta, Stream &stream) const
 converts GpuMat to another datatype with scaling (Non-Blocking call)
 
CV_WRAP void assignTo (GpuMat &m, int type=-1) const
 
uchar * ptr (int y=0)
 returns pointer to y-th row
 
const uchar * ptr (int y=0) const
 
template<typename _Tp >
_Tp * ptr (int y=0)
 template version of the above method
 
template<typename _Tp >
const _Tp * ptr (int y=0) const
 
template<typename _Tp >
 operator PtrStepSz< _Tp > () const
 
template<typename _Tp >
 operator PtrStep< _Tp > () const
 
CV_WRAP GpuMat row (int y) const
 returns a new GpuMat header for the specified row
 
CV_WRAP GpuMat col (int x) const
 returns a new GpuMat header for the specified column
 
CV_WRAP GpuMat rowRange (int startrow, int endrow) const
 ... for the specified row span
 
CV_WRAP GpuMat rowRange (Range r) const
 
CV_WRAP GpuMat colRange (int startcol, int endcol) const
 ... for the specified column span
 
CV_WRAP GpuMat colRange (Range r) const
 
GpuMat operator() (Range rowRange, Range colRange) const
 extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.)
 
GpuMat operator() (Rect roi) const
 
CV_WRAP GpuMat reshape (int cn, int rows=0) const
 
CV_WRAP void locateROI (Size &wholeSize, Point &ofs) const
 locates GpuMat header within a parent GpuMat
 
CV_WRAP GpuMatadjustROI (int dtop, int dbottom, int dleft, int dright)
 moves/resizes the current GpuMat ROI inside the parent GpuMat
 
CV_WRAP bool isContinuous () const
 
CV_WRAP size_t elemSize () const
 returns element size in bytes
 
CV_WRAP size_t elemSize1 () const
 returns the size of element channel in bytes
 
CV_WRAP int type () const
 returns element type
 
CV_WRAP int depth () const
 returns element type
 
CV_WRAP int channels () const
 returns number of channels
 
CV_WRAP size_t step1 () const
 returns step/elemSize1()
 
CV_WRAP Size size () const
 returns GpuMat size : width == number of columns, height == number of rows
 
CV_WRAP bool empty () const
 returns true if GpuMat data is NULL
 
CV_WRAP void * cudaPtr () const
 
CV_WRAP void updateContinuityFlag ()
 internal use method: updates the continuity flag
 

静的公開メンバ関数

static CV_WRAP GpuMat::AllocatordefaultAllocator ()
 default allocator
 
static CV_WRAP void setDefaultAllocator (GpuMat::Allocator *allocator)
 

公開変数類

int flags
 
int rows
 the number of rows and columns
 
int cols
 
CV_PROP size_t step
 a distance between successive rows in bytes; includes the gap if any
 
uchar * data
 pointer to the data
 
int * refcount
 
uchar * datastart
 helper fields used in locateROI and adjustROI
 
const uchar * dataend
 
Allocatorallocator
 allocator
 

詳解

Base storage class for GPU memory with reference counting.

Its interface matches the Mat interface with the following limitations:

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.

覚え書き
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.
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.

参照
Mat

関数詳解

◆ download() [1/2]

CV_WRAP void cv::cuda::GpuMat::download ( OutputArray  dst) const

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() [2/2]

CV_WRAP void cv::cuda::GpuMat::download ( OutputArray  dst,
Stream stream 
) const

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.

◆ isContinuous()

CV_WRAP bool cv::cuda::GpuMat::isContinuous ( ) const

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

◆ reshape()

CV_WRAP GpuMat cv::cuda::GpuMat::reshape ( int  cn,
int  rows = 0 
) const

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

◆ upload() [1/2]

CV_WRAP void cv::cuda::GpuMat::upload ( InputArray  arr)

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() [2/2]

CV_WRAP void cv::cuda::GpuMat::upload ( InputArray  arr,
Stream 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.

メンバ詳解

◆ 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


このクラス詳解は次のファイルから抽出されました: