@Namespace(value="cv::cuda") @NoOffset @Properties(inherit=opencv_core.class) public class GpuMat extends Pointer
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.
Mat
Modifier and Type | Class and Description |
---|---|
static class |
GpuMat.Allocator |
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
GpuMat() |
GpuMat(GpuMat.Allocator allocator)
default constructor
|
GpuMat(GpuMat m)
copy constructor
|
GpuMat(GpuMat arr,
GpuMat.Allocator allocator) |
GpuMat(GpuMat m,
Range rowRange,
Range colRange)
creates a GpuMat header for a part of the bigger matrix
|
GpuMat(GpuMat m,
Rect roi) |
GpuMat(int rows,
int cols,
int type) |
GpuMat(int rows,
int cols,
int type,
GpuMat.Allocator allocator)
constructs GpuMat of the specified size and type
|
GpuMat(int rows,
int cols,
int type,
Pointer data) |
GpuMat(int rows,
int cols,
int type,
Pointer data,
long step)
constructor for GpuMat headers pointing to user-allocated data
|
GpuMat(int rows,
int cols,
int type,
Scalar s) |
GpuMat(int rows,
int cols,
int type,
Scalar s,
GpuMat.Allocator allocator)
constructs GpuMat and fills it with the specified value _s
|
GpuMat(long size)
Native array allocator.
|
GpuMat(Mat arr) |
GpuMat(Mat arr,
GpuMat.Allocator allocator)
builds GpuMat from host memory (Blocking call)
|
GpuMat(Pointer p)
Pointer cast constructor.
|
GpuMat(Size size,
int type) |
GpuMat(Size size,
int type,
GpuMat.Allocator allocator) |
GpuMat(Size size,
int type,
Pointer data) |
GpuMat(Size size,
int type,
Pointer data,
long step) |
GpuMat(Size size,
int type,
Scalar s) |
GpuMat(Size size,
int type,
Scalar s,
GpuMat.Allocator allocator) |
GpuMat(UMat arr) |
GpuMat(UMat arr,
GpuMat.Allocator allocator) |
Modifier and Type | Method and Description |
---|---|
GpuMat |
adjustROI(int dtop,
int dbottom,
int dleft,
int dright)
moves/resizes the current GpuMat ROI inside the parent GpuMat
|
GpuMat.Allocator |
allocator()
allocator
|
GpuMat |
allocator(GpuMat.Allocator setter) |
GpuMat |
apply(Range rowRange,
Range colRange)
extracts a rectangular sub-GpuMat (this is a generalized form of row, rowRange etc.)
|
GpuMat |
apply(Rect roi) |
void |
assignTo(GpuMat m) |
void |
assignTo(GpuMat m,
int type) |
int |
channels()
returns number of channels
|
GpuMat |
clone()
returns deep copy of the GpuMat, i.e.
|
GpuMat |
col(int x)
returns a new GpuMat header for the specified column
|
GpuMat |
colRange(int startcol,
int endcol)
...
|
GpuMat |
colRange(Range r) |
int |
cols() |
GpuMat |
cols(int setter) |
void |
convertTo(GpuMat dst,
int rtype) |
void |
convertTo(GpuMat dst,
int rtype,
double alpha) |
void |
convertTo(GpuMat dst,
int rtype,
double alpha,
double beta) |
void |
convertTo(GpuMat dst,
int rtype,
double alpha,
double beta,
Stream stream) |
void |
convertTo(GpuMat dst,
int rtype,
double alpha,
Stream stream) |
void |
convertTo(GpuMat dst,
int rtype,
Stream stream) |
void |
convertTo(Mat dst,
int rtype)
converts GpuMat to another datatype (Blocking call)
|
void |
convertTo(Mat dst,
int rtype,
double alpha) |
void |
convertTo(Mat dst,
int rtype,
double alpha,
double beta)
converts GpuMat to another datatype with scaling (Blocking call)
|
void |
convertTo(Mat dst,
int rtype,
double alpha,
double beta,
Stream stream)
converts GpuMat to another datatype with scaling (Non-Blocking call)
|
void |
convertTo(Mat dst,
int rtype,
double alpha,
Stream stream)
converts GpuMat to another datatype with scaling (Non-Blocking call)
|
void |
convertTo(Mat dst,
int rtype,
Stream stream)
converts GpuMat to another datatype (Non-Blocking call)
|
void |
convertTo(UMat dst,
int rtype) |
void |
convertTo(UMat dst,
int rtype,
double alpha) |
void |
convertTo(UMat dst,
int rtype,
double alpha,
double beta) |
void |
convertTo(UMat dst,
int rtype,
double alpha,
double beta,
Stream stream) |
void |
convertTo(UMat dst,
int rtype,
double alpha,
Stream stream) |
void |
convertTo(UMat dst,
int rtype,
Stream stream) |
void |
copyTo(GpuMat dst) |
void |
copyTo(GpuMat dst,
GpuMat mask) |
void |
copyTo(GpuMat dst,
GpuMat mask,
Stream stream) |
void |
copyTo(GpuMat dst,
Stream stream) |
void |
copyTo(Mat dst)
copies the GpuMat content to device memory (Blocking call)
|
void |
copyTo(Mat dst,
Mat mask)
copies those GpuMat elements to "m" that are marked with non-zero mask elements (Blocking call)
|
void |
copyTo(Mat dst,
Mat mask,
Stream stream)
copies those GpuMat elements to "m" that are marked with non-zero mask elements (Non-Blocking call)
|
void |
copyTo(Mat dst,
Stream stream)
copies the GpuMat content to device memory (Non-Blocking call)
|
void |
copyTo(UMat dst) |
void |
copyTo(UMat dst,
Stream stream) |
void |
copyTo(UMat dst,
UMat mask) |
void |
copyTo(UMat dst,
UMat mask,
Stream stream) |
void |
create(int rows,
int cols,
int type)
allocates new GpuMat data unless the GpuMat already has specified size and type
|
void |
create(Size size,
int type) |
Pointer |
cudaPtr() |
BytePointer |
data()
pointer to the data
|
GpuMat |
data(BytePointer setter) |
BytePointer |
dataend() |
GpuMat |
dataend(BytePointer setter) |
BytePointer |
datastart()
helper fields used in locateROI and adjustROI
|
GpuMat |
datastart(BytePointer setter) |
static GpuMat.Allocator |
defaultAllocator()
default allocator
|
int |
depth()
returns element type
|
void |
download(GpuMat dst) |
void |
download(GpuMat dst,
Stream stream) |
void |
download(Mat dst)
\brief Performs data download from GpuMat (Blocking call)
|
void |
download(Mat dst,
Stream stream)
\brief Performs data download from GpuMat (Non-Blocking call)
|
void |
download(UMat dst) |
void |
download(UMat dst,
Stream stream) |
long |
elemSize()
returns element size in bytes
|
long |
elemSize1()
returns the size of element channel in bytes
|
boolean |
empty()
returns true if GpuMat data is NULL
|
int |
flags()
includes several bit-fields:
- the magic signature
- continuity flag
- depth
- number of channels
|
GpuMat |
flags(int setter) |
boolean |
isContinuous()
returns true iff the GpuMat data is continuous
(i.e.
|
void |
locateROI(Size wholeSize,
Point ofs)
locates GpuMat header within a parent GpuMat
|
GpuMat |
position(long position) |
BytePointer |
ptr() |
BytePointer |
ptr(int y)
returns pointer to y-th row
|
GpuMat |
put(GpuMat m)
assignment operators
|
IntPointer |
refcount()
pointer to the reference counter;
when GpuMat points to user-allocated data, the pointer is NULL
|
GpuMat |
refcount(IntPointer setter) |
void |
release()
decreases reference counter, deallocate the data when reference counter reaches 0
|
GpuMat |
reshape(int cn) |
GpuMat |
reshape(int cn,
int rows)
creates alternative GpuMat header for the same data, with different
number of channels and/or different number of rows
|
GpuMat |
row(int y)
returns a new GpuMat header for the specified row
|
GpuMat |
rowRange(int startrow,
int endrow)
...
|
GpuMat |
rowRange(Range r) |
int |
rows()
the number of rows and columns
|
GpuMat |
rows(int setter) |
static void |
setDefaultAllocator(GpuMat.Allocator allocator) |
GpuMat |
setTo(Scalar s)
sets some of the GpuMat elements to s (Blocking call)
|
GpuMat |
setTo(Scalar s,
GpuMat mask) |
GpuMat |
setTo(Scalar s,
GpuMat mask,
Stream stream) |
GpuMat |
setTo(Scalar s,
Mat mask)
sets some of the GpuMat elements to s, according to the mask (Blocking call)
|
GpuMat |
setTo(Scalar s,
Mat mask,
Stream stream)
sets some of the GpuMat elements to s, according to the mask (Non-Blocking call)
|
GpuMat |
setTo(Scalar s,
Stream stream)
sets some of the GpuMat elements to s (Non-Blocking call)
|
GpuMat |
setTo(Scalar s,
UMat mask) |
GpuMat |
setTo(Scalar s,
UMat mask,
Stream stream) |
Size |
size()
returns GpuMat size : width == number of columns, height == number of rows
|
long |
step()
a distance between successive rows in bytes; includes the gap if any
|
GpuMat |
step(long setter) |
long |
step1()
returns step/elemSize1()
|
void |
swap(GpuMat mat)
swaps with other smart pointer
|
int |
type()
returns element type
|
void |
updateContinuityFlag()
internal use method: updates the continuity flag
|
void |
upload(GpuMat arr) |
void |
upload(GpuMat arr,
Stream stream) |
void |
upload(Mat arr)
\brief Performs data upload to GpuMat (Blocking call)
|
void |
upload(Mat arr,
Stream stream)
\brief Performs data upload to GpuMat (Non-Blocking call)
|
void |
upload(UMat arr) |
void |
upload(UMat arr,
Stream stream) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zero
public GpuMat(Pointer p)
Pointer.Pointer(Pointer)
.public GpuMat(long size)
Pointer.position(long)
.public GpuMat(GpuMat.Allocator allocator)
public GpuMat()
public GpuMat(int rows, int cols, int type, GpuMat.Allocator allocator)
public GpuMat(int rows, int cols, int type)
public GpuMat(@ByVal Size size, int type, GpuMat.Allocator allocator)
public GpuMat(int rows, int cols, int type, @ByVal Scalar s, GpuMat.Allocator allocator)
public GpuMat(@ByVal Size size, int type, @ByVal Scalar s, GpuMat.Allocator allocator)
public GpuMat(int rows, int cols, int type, Pointer data, @Cast(value="size_t") long step)
public GpuMat(int rows, int cols, int type, Pointer data)
public GpuMat(@Const @ByRef GpuMat m, @ByVal Range rowRange, @ByVal Range colRange)
public GpuMat(@ByVal Mat arr, GpuMat.Allocator allocator)
public GpuMat(@ByVal UMat arr, GpuMat.Allocator allocator)
public GpuMat(@ByVal GpuMat arr, GpuMat.Allocator allocator)
public static GpuMat.Allocator defaultAllocator()
public static void setDefaultAllocator(GpuMat.Allocator allocator)
public void create(int rows, int cols, int type)
public void release()
public void upload(@ByVal Mat arr)
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.
public void upload(@ByVal Mat arr, @ByRef Stream stream)
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 \p stream is not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option.
public void download(@ByVal Mat dst)
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.
public void download(@ByVal Mat dst, @ByRef Stream stream)
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 \p stream is not the default stream and \p dst is HostMem allocated with HostMem::PAGE_LOCKED option.
public void copyTo(@ByVal Mat dst)
public void copyTo(@ByVal Mat dst, @ByRef Stream stream)
public void copyTo(@ByVal Mat dst, @ByVal Mat mask)
public void copyTo(@ByVal Mat dst, @ByVal Mat mask, @ByRef Stream stream)
@ByRef public GpuMat setTo(@ByVal Scalar s)
@ByRef public GpuMat setTo(@ByVal Scalar s, @ByRef Stream stream)
@ByRef public GpuMat setTo(@ByVal Scalar s, @ByVal Mat mask)
@ByRef public GpuMat setTo(@ByVal Scalar s, @ByVal Mat mask, @ByRef Stream stream)
public void convertTo(@ByVal Mat dst, int rtype)
public void convertTo(@ByVal Mat dst, int rtype, @ByRef Stream stream)
public void convertTo(@ByVal Mat dst, int rtype, double alpha, double beta)
public void convertTo(@ByVal Mat dst, int rtype, double alpha, @ByRef Stream stream)
public void convertTo(@ByVal Mat dst, int rtype, double alpha, double beta, @ByRef Stream stream)
public void convertTo(@ByVal UMat dst, int rtype, double alpha, double beta, @ByRef Stream stream)
public void convertTo(@ByVal GpuMat dst, int rtype, double alpha, double beta, @ByRef Stream stream)
@Cast(value="uchar*") public BytePointer ptr(int y)
@Cast(value="uchar*") public BytePointer ptr()
@ByVal @Name(value="operator ()") public GpuMat apply(@ByVal Range rowRange, @ByVal Range colRange)
@ByVal public GpuMat reshape(int cn, int rows)
public void locateROI(@ByRef Size wholeSize, @ByRef Point ofs)
@ByRef public GpuMat adjustROI(int dtop, int dbottom, int dleft, int dright)
@Cast(value="bool") public boolean isContinuous()
@Cast(value="size_t") public long elemSize1()
public int type()
public int depth()
public int channels()
@ByVal public Size size()
public Pointer cudaPtr()
public void updateContinuityFlag()
public int flags()
public GpuMat flags(int setter)
public int rows()
public GpuMat rows(int setter)
public int cols()
public GpuMat cols(int setter)
@Cast(value="size_t") public long step()
public GpuMat step(long setter)
@Cast(value="uchar*") public BytePointer data()
public GpuMat data(BytePointer setter)
public IntPointer refcount()
public GpuMat refcount(IntPointer setter)
@Cast(value="uchar*") public BytePointer datastart()
public GpuMat datastart(BytePointer setter)
@Cast(value="const uchar*") public BytePointer dataend()
public GpuMat dataend(BytePointer setter)
public GpuMat.Allocator allocator()
public GpuMat allocator(GpuMat.Allocator setter)
Copyright © 2020. All rights reserved.