opencv on mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

GpuMat Class Reference

Base storage class for GPU memory with reference counting. More...

#include <cuda.hpp>

Public Member Functions

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

Static Public Member Functions

static Allocator * defaultAllocator ()
 default allocator

Data Fields

int flags
int rows
 the number of rows and columns
size_t step
 a distance between successive rows in bytes; includes the gap if any
uchar * data
 pointer to the data
int * refcount
 pointer to the reference counter; when GpuMat points to user-allocated data, the pointer is NULL
uchar * datastart
 helper fields used in locateROI and adjustROI
Allocator * allocator
 allocator

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.

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.
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.
See also:
Mat

Definition at line 96 of file core/cuda.hpp.


Constructor & Destructor Documentation

GpuMat ( Allocator *  allocator = defaultAllocator() ) [explicit]

default constructor

GpuMat ( int  rows,
int  cols,
int  type,
Allocator *  allocator = defaultAllocator() 
)

constructs GpuMat of the specified size and type

GpuMat ( int  rows,
int  cols,
int  type,
Scalar  s,
Allocator *  allocator = defaultAllocator() 
)

constucts GpuMat and fills it with the specified value _s

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 ( const GpuMat m,
Range  rowRange,
Range  colRange 
)

creates a GpuMat header for a part of the bigger matrix

GpuMat ( InputArray  arr,
Allocator *  allocator = defaultAllocator() 
) [explicit]

builds GpuMat from host memory (Blocking call)

~GpuMat (  )

destructor - calls release()


Member Function Documentation

GpuMat& adjustROI ( int  dtop,
int  dbottom,
int  dleft,
int  dright 
)

moves/resizes the current GpuMat ROI inside the parent GpuMat

int channels (  ) const

returns number of channels

GpuMat clone (  ) const

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

GpuMat col ( int  x ) const

returns a new GpuMat header for the specified column

GpuMat colRange ( int  startcol,
int  endcol 
) const

... for the specified column span

void convertTo ( OutputArray  dst,
int  rtype 
) const

converts GpuMat to another datatype (Blocking call)

void convertTo ( OutputArray  dst,
int  rtype,
Stream stream 
) const

converts GpuMat to another datatype (Non-Blocking call)

void convertTo ( OutputArray  dst,
int  rtype,
double  alpha,
double  beta = 0.0 
) const

converts GpuMat to another datatype with scaling (Blocking call)

void convertTo ( OutputArray  dst,
int  rtype,
double  alpha,
Stream stream 
) const

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

void convertTo ( OutputArray  dst,
int  rtype,
double  alpha,
double  beta,
Stream stream 
) const

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

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)

void copyTo ( OutputArray  dst ) const

copies the GpuMat content to device memory (Blocking call)

void copyTo ( OutputArray  dst,
Stream stream 
) const

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

void copyTo ( OutputArray  dst,
InputArray  mask 
) const

copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call)

void create ( int  rows,
int  cols,
int  type 
)

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

static Allocator* defaultAllocator (  ) [static]

default allocator

int depth (  ) const

returns element type

void download ( OutputArray  dst ) const

pefroms download data from device to host memory (Blocking call)

void download ( OutputArray  dst,
Stream stream 
) const

pefroms download data from device to host memory (Non-Blocking call)

size_t elemSize (  ) const

returns element size in bytes

size_t elemSize1 (  ) const

returns the size of element channel in bytes

bool empty (  ) const

returns true if GpuMat data is NULL

bool isContinuous (  ) const

returns true iff the GpuMat data is continuous (i.e.

when there are no gaps between successive rows)

void locateROI ( Size wholeSize,
Point ofs 
) const

locates GpuMat header within a parent GpuMat

GpuMat operator() ( Range  rowRange,
Range  colRange 
) const

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

GpuMat& operator= ( const GpuMat m )

assignment operators

_Tp* ptr ( int  y = 0 )

template version of the above method

uchar* ptr ( int  y = 0 )

returns pointer to y-th row

void release (  )

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

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

GpuMat row ( int  y ) const

returns a new GpuMat header for the specified row

GpuMat rowRange ( int  startrow,
int  endrow 
) const

... for the specified row span

GpuMat& setTo ( Scalar  s,
InputArray  mask,
Stream stream 
)

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

GpuMat& setTo ( Scalar  s,
InputArray  mask 
)

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

GpuMat& setTo ( Scalar  s,
Stream stream 
)

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

GpuMat& setTo ( Scalar  s )

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

Size size (  ) const

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

size_t step1 (  ) const

returns step/elemSize1()

void swap ( GpuMat mat )

swaps with other smart pointer

int type (  ) const

returns element type

void upload ( InputArray  arr )

pefroms upload data to GpuMat (Blocking call)

void upload ( InputArray  arr,
Stream stream 
)

pefroms upload data to GpuMat (Non-Blocking call)


Field Documentation

Allocator* allocator

allocator

Definition at line 303 of file core/cuda.hpp.

uchar* data

pointer to the data

Definition at line 292 of file core/cuda.hpp.

uchar* datastart

helper fields used in locateROI and adjustROI

Definition at line 299 of file core/cuda.hpp.

int flags

includes several bit-fields:

  • the magic signature
  • continuity flag
  • depth
  • number of channels

Definition at line 283 of file core/cuda.hpp.

int* refcount

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

Definition at line 296 of file core/cuda.hpp.

int rows

the number of rows and columns

Definition at line 286 of file core/cuda.hpp.

size_t step

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

Definition at line 289 of file core/cuda.hpp.