cv2.cuda

None

Attributes

cv2.cuda.DEVICE_INFO_COMPUTE_MODE_DEFAULT: int
cv2.cuda.DEVICE_INFO_COMPUTE_MODE_EXCLUSIVE: int
cv2.cuda.DEVICE_INFO_COMPUTE_MODE_EXCLUSIVE_PROCESS: int
cv2.cuda.DEVICE_INFO_COMPUTE_MODE_PROHIBITED: int
cv2.cuda.DYNAMIC_PARALLELISM: int
cv2.cuda.DeviceInfo_ComputeModeDefault: int
cv2.cuda.DeviceInfo_ComputeModeExclusive: int
cv2.cuda.DeviceInfo_ComputeModeExclusiveProcess: int
cv2.cuda.DeviceInfo_ComputeModeProhibited: int
cv2.cuda.EVENT_BLOCKING_SYNC: int
cv2.cuda.EVENT_DEFAULT: int
cv2.cuda.EVENT_DISABLE_TIMING: int
cv2.cuda.EVENT_INTERPROCESS: int
cv2.cuda.Event_BLOCKING_SYNC: int
cv2.cuda.Event_DEFAULT: int
cv2.cuda.Event_DISABLE_TIMING: int
cv2.cuda.Event_INTERPROCESS: int
cv2.cuda.FEATURE_SET_COMPUTE_10: int
cv2.cuda.FEATURE_SET_COMPUTE_11: int
cv2.cuda.FEATURE_SET_COMPUTE_12: int
cv2.cuda.FEATURE_SET_COMPUTE_13: int
cv2.cuda.FEATURE_SET_COMPUTE_20: int
cv2.cuda.FEATURE_SET_COMPUTE_21: int
cv2.cuda.FEATURE_SET_COMPUTE_30: int
cv2.cuda.FEATURE_SET_COMPUTE_32: int
cv2.cuda.FEATURE_SET_COMPUTE_35: int
cv2.cuda.FEATURE_SET_COMPUTE_50: int
cv2.cuda.GLOBAL_ATOMICS: int
cv2.cuda.HOST_MEM_PAGE_LOCKED: int
cv2.cuda.HOST_MEM_SHARED: int
cv2.cuda.HOST_MEM_WRITE_COMBINED: int
cv2.cuda.HostMem_PAGE_LOCKED: int
cv2.cuda.HostMem_SHARED: int
cv2.cuda.HostMem_WRITE_COMBINED: int
cv2.cuda.NATIVE_DOUBLE: int
cv2.cuda.SHARED_ATOMICS: int
cv2.cuda.WARP_SHUFFLE_FUNCTIONS: int

Classes

class cv2.cuda.BufferPool
getBuffer(rows, cols, type) retval
Parameters:
  • self

  • rows (int) –

  • cols (int) –

  • type (int) –

Return type:

GpuMat

getBuffer(rows, cols, type) retval
Parameters:
  • self

  • size (cv2.typing.Size) –

  • type (int) –

Return type:

GpuMat

__init__(self, stream: Stream)
Parameters:
  • self

  • stream (Stream) –

Return type:

None

getAllocator() retval
Parameters:

self

Return type:

GpuMat.Allocator

class cv2.cuda.DeviceInfo
__init__(self)
Parameters:

self

Return type:

None

__init__(self, device_id: int)
Parameters:
  • self

  • device_id (int) –

Return type:

None

deviceID() retval

Returns system index of the CUDA device starting with 0.

Parameters:

self

Return type:

int

totalGlobalMem() retval
Parameters:

self

Return type:

int

sharedMemPerBlock() retval
Parameters:

self

Return type:

int

regsPerBlock() retval
Parameters:

self

Return type:

int

warpSize() retval
Parameters:

self

Return type:

int

memPitch() retval
Parameters:

self

Return type:

int

maxThreadsPerBlock() retval
Parameters:

self

Return type:

int

maxThreadsDim() retval
Parameters:

self

Return type:

cv2.typing.Vec3i

maxGridSize() retval
Parameters:

self

Return type:

cv2.typing.Vec3i

clockRate() retval
Parameters:

self

Return type:

int

totalConstMem() retval
Parameters:

self

Return type:

int

majorVersion() retval
Parameters:

self

Return type:

int

minorVersion() retval
Parameters:

self

Return type:

int

textureAlignment() retval
Parameters:

self

Return type:

int

texturePitchAlignment() retval
Parameters:

self

Return type:

int

multiProcessorCount() retval
Parameters:

self

Return type:

int

kernelExecTimeoutEnabled() retval
Parameters:

self

Return type:

bool

integrated() retval
Parameters:

self

Return type:

bool

canMapHostMemory() retval
Parameters:

self

Return type:

bool

computeMode() retval
Parameters:

self

Return type:

DeviceInfo_ComputeMode

maxTexture1D() retval
Parameters:

self

Return type:

int

maxTexture1DMipmap() retval
Parameters:

self

Return type:

int

maxTexture1DLinear() retval
Parameters:

self

Return type:

int

maxTexture2D() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

maxTexture2DMipmap() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

maxTexture2DLinear() retval
Parameters:

self

Return type:

cv2.typing.Vec3i

maxTexture2DGather() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

maxTexture3D() retval
Parameters:

self

Return type:

cv2.typing.Vec3i

maxTextureCubemap() retval
Parameters:

self

Return type:

int

maxTexture1DLayered() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

maxTexture2DLayered() retval
Parameters:

self

Return type:

cv2.typing.Vec3i

maxTextureCubemapLayered() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

maxSurface1D() retval
Parameters:

self

Return type:

int

maxSurface2D() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

maxSurface3D() retval
Parameters:

self

Return type:

cv2.typing.Vec3i

maxSurface1DLayered() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

maxSurface2DLayered() retval
Parameters:

self

Return type:

cv2.typing.Vec3i

maxSurfaceCubemap() retval
Parameters:

self

Return type:

int

maxSurfaceCubemapLayered() retval
Parameters:

self

Return type:

cv2.typing.Vec2i

surfaceAlignment() retval
Parameters:

self

Return type:

int

concurrentKernels() retval
Parameters:

self

Return type:

bool

ECCEnabled() retval
Parameters:

self

Return type:

bool

pciBusID() retval
Parameters:

self

Return type:

int

pciDeviceID() retval
Parameters:

self

Return type:

int

pciDomainID() retval
Parameters:

self

Return type:

int

tccDriver() retval
Parameters:

self

Return type:

bool

asyncEngineCount() retval
Parameters:

self

Return type:

int

unifiedAddressing() retval
Parameters:

self

Return type:

bool

memoryClockRate() retval
Parameters:

self

Return type:

int

memoryBusWidth() retval
Parameters:

self

Return type:

int

l2CacheSize() retval
Parameters:

self

Return type:

int

maxThreadsPerMultiProcessor() retval
Parameters:

self

Return type:

int

queryMemory(totalMemory, freeMemory) None
Parameters:
  • self

  • totalMemory (int) –

  • freeMemory (int) –

Return type:

None

freeMemory() retval
Parameters:

self

Return type:

int

totalMemory() retval
Parameters:

self

Return type:

int

isCompatible() retval

Checks the CUDA module and device compatibility.

This function returns true if the CUDA module can be run on the specified device. Otherwise, it
returns false .
Parameters:

self

Return type:

bool

class cv2.cuda.Event
__init__(self, flags: Event_CreateFlags = ...)
Parameters:
  • self

  • flags (Event_CreateFlags) –

Return type:

None

record([stream]) None
Parameters:
  • self

  • stream (Stream) –

Return type:

None

queryIfComplete() retval
Parameters:

self

Return type:

bool

waitForCompletion() None
Parameters:

self

Return type:

None

static elapsedTime(start, end) retval
Parameters:
Return type:

float

class cv2.cuda.GpuData
class cv2.cuda.GpuMat
step()
Parameters:

self

Return type:

int

__init__(self, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, rows: int, cols: int, type: int, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • rows (int) –

  • cols (int) –

  • type (int) –

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, size: cv2.typing.Size, type: int, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • size (cv2.typing.Size) –

  • type (int) –

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, rows: int, cols: int, type: int, s: cv2.typing.Scalar, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • rows (int) –

  • cols (int) –

  • type (int) –

  • s (cv2.typing.Scalar) –

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, size: cv2.typing.Size, type: int, s: cv2.typing.Scalar, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • size (cv2.typing.Size) –

  • type (int) –

  • s (cv2.typing.Scalar) –

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, m: GpuMat)
Parameters:
Return type:

None

__init__(self, m: GpuMat, rowRange: cv2.typing.Range, colRange: cv2.typing.Range)
Parameters:
  • self

  • m (GpuMat) –

  • rowRange (cv2.typing.Range) –

  • colRange (cv2.typing.Range) –

Return type:

None

__init__(self, m: GpuMat, roi: cv2.typing.Rect)
Parameters:
  • self

  • m (GpuMat) –

  • roi (cv2.typing.Rect) –

Return type:

None

__init__(self, arr: cv2.typing.MatLike, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • arr (cv2.typing.MatLike) –

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, arr: GpuMat, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • arr (GpuMat) –

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, arr: cv2.UMat, allocator: GpuMat.Allocator = ...)
Parameters:
  • self

  • arr (cv2.UMat) –

  • allocator (GpuMat.Allocator) –

Return type:

None

create(rows, cols, type) None
Parameters:
  • self

  • rows (int) –

  • cols (int) –

  • type (int) –

Return type:

None

create(rows, cols, type) None
Parameters:
  • self

  • size (cv2.typing.Size) –

  • type (int) –

Return type:

None

upload(arr) None

Performs data upload to GpuMat (Non-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.

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.
Parameters:
  • self

  • arr (cv2.typing.MatLike) –

Return type:

None

upload(arr) None

Performs data upload to GpuMat (Non-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.

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.
Parameters:
Return type:

None

upload(arr) None

Performs data upload to GpuMat (Non-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.

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.
Parameters:
Return type:

None

upload(arr) None

Performs data upload to GpuMat (Non-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.

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.
Parameters:
  • self

  • arr (cv2.typing.MatLike) –

  • stream (Stream) –

Return type:

None

upload(arr) None

Performs data upload to GpuMat (Non-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.

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.
Parameters:
Return type:

None

upload(arr) None

Performs data upload to GpuMat (Non-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.

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.
Parameters:
Return type:

None

download([dst]) dst

Performs data download from GpuMat (Non-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.

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.
Parameters:
  • self

  • dst (cv2.typing.MatLike | None) –

Return type:

cv2.typing.MatLike

download([dst]) dst

Performs data download from GpuMat (Non-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.

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.
Parameters:
  • self

  • dst (GpuMat | None) –

Return type:

GpuMat

download([dst]) dst

Performs data download from GpuMat (Non-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.

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.
Parameters:
Return type:

cv2.UMat

download([dst]) dst

Performs data download from GpuMat (Non-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.

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.
Parameters:
  • self

  • stream (Stream) –

  • dst (cv2.typing.MatLike | None) –

Return type:

cv2.typing.MatLike

download([dst]) dst

Performs data download from GpuMat (Non-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.

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.
Parameters:
Return type:

GpuMat

download([dst]) dst

Performs data download from GpuMat (Non-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.

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.
Parameters:
Return type:

cv2.UMat

copyTo([dst]) dst
Parameters:
  • self

  • dst (GpuMat | None) –

Return type:

GpuMat

copyTo([dst]) dst
Parameters:
Return type:

GpuMat

copyTo([dst]) dst
Parameters:
Return type:

GpuMat

copyTo([dst]) dst
Parameters:
Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

  • stream (Stream) –

Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

  • mask (cv2.typing.MatLike) –

Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

  • mask (GpuMat) –

Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

  • mask (cv2.UMat) –

Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

  • mask (cv2.typing.MatLike) –

  • stream (Stream) –

Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

  • mask (GpuMat) –

  • stream (Stream) –

Return type:

GpuMat

setTo(s) retval
Parameters:
  • self

  • s (cv2.typing.Scalar) –

  • mask (cv2.UMat) –

  • stream (Stream) –

Return type:

GpuMat

convertTo(rtype, stream[, dst]) dst
Parameters:
Return type:

GpuMat

convertTo(rtype, stream[, dst]) dst
Parameters:
Return type:

GpuMat

convertTo(rtype, stream[, dst]) dst
Parameters:
Return type:

GpuMat

rowRange(startrow, endrow) retval
Parameters:
  • self

  • startrow (int) –

  • endrow (int) –

Return type:

GpuMat

rowRange(startrow, endrow) retval
Parameters:
  • self

  • r (cv2.typing.Range) –

Return type:

GpuMat

colRange(startcol, endcol) retval
Parameters:
  • self

  • startcol (int) –

  • endcol (int) –

Return type:

GpuMat

colRange(startcol, endcol) retval
Parameters:
  • self

  • r (cv2.typing.Range) –

Return type:

GpuMat

static defaultAllocator() retval
Return type:

GpuMat.Allocator

static setDefaultAllocator(allocator) None
Parameters:

allocator (GpuMat.Allocator) –

Return type:

None

release() None
Parameters:

self

Return type:

None

swap(mat) None
Parameters:
Return type:

None

clone() retval
Parameters:

self

Return type:

GpuMat

assignTo(m[, type]) None
Parameters:
Return type:

None

row(y) retval
Parameters:
  • self

  • y (int) –

Return type:

GpuMat

col(x) retval
Parameters:
  • self

  • x (int) –

Return type:

GpuMat

reshape(cn[, rows]) retval
Parameters:
  • self

  • cn (int) –

  • rows (int) –

Return type:

GpuMat

locateROI(wholeSize, ofs) None
Parameters:
  • self

  • wholeSize (cv2.typing.Size) –

  • ofs (cv2.typing.Point) –

Return type:

None

adjustROI(dtop, dbottom, dleft, dright) retval
Parameters:
  • self

  • dtop (int) –

  • dbottom (int) –

  • dleft (int) –

  • dright (int) –

Return type:

GpuMat

isContinuous() retval
Parameters:

self

Return type:

bool

elemSize() retval
Parameters:

self

Return type:

int

elemSize1() retval
Parameters:

self

Return type:

int

type() retval
Parameters:

self

Return type:

int

depth() retval
Parameters:

self

Return type:

int

channels() retval
Parameters:

self

Return type:

int

step1() retval
Parameters:

self

Return type:

int

size() retval
Parameters:

self

Return type:

cv2.typing.Size

empty() retval
Parameters:

self

Return type:

bool

cudaPtr() retval
Parameters:

self

Return type:

cv2.typing.IntPointer

updateContinuityFlag() None
Parameters:

self

Return type:

None

class cv2.cuda.GpuMatND
class cv2.cuda.HostMem
step()
Parameters:

self

Return type:

int

__init__(self, alloc_type: HostMem_AllocType = ...)
Parameters:
  • self

  • alloc_type (HostMem_AllocType) –

Return type:

None

__init__(self, rows: int, cols: int, type: int, alloc_type: HostMem_AllocType = ...)
Parameters:
  • self

  • rows (int) –

  • cols (int) –

  • type (int) –

  • alloc_type (HostMem_AllocType) –

Return type:

None

__init__(self, size: cv2.typing.Size, type: int, alloc_type: HostMem_AllocType = ...)
Parameters:
  • self

  • size (cv2.typing.Size) –

  • type (int) –

  • alloc_type (HostMem_AllocType) –

Return type:

None

__init__(self, arr: cv2.typing.MatLike, alloc_type: HostMem_AllocType = ...)
Parameters:
  • self

  • arr (cv2.typing.MatLike) –

  • alloc_type (HostMem_AllocType) –

Return type:

None

__init__(self, arr: GpuMat, alloc_type: HostMem_AllocType = ...)
Parameters:
  • self

  • arr (GpuMat) –

  • alloc_type (HostMem_AllocType) –

Return type:

None

__init__(self, arr: cv2.UMat, alloc_type: HostMem_AllocType = ...)
Parameters:
  • self

  • arr (cv2.UMat) –

  • alloc_type (HostMem_AllocType) –

Return type:

None

swap(b) None
Parameters:
Return type:

None

clone() retval
Parameters:

self

Return type:

HostMem

create(rows, cols, type) None
Parameters:
  • self

  • rows (int) –

  • cols (int) –

  • type (int) –

Return type:

None

reshape(cn[, rows]) retval
Parameters:
  • self

  • cn (int) –

  • rows (int) –

Return type:

HostMem

createMatHeader() retval
Parameters:

self

Return type:

cv2.typing.MatLike

isContinuous() retval

Maps CPU memory to GPU address space and creates the cuda::GpuMat header without reference counting for it.

This can be done only if memory was allocated with the SHARED flag and if it is supported by the
hardware. Laptops often share video and CPU memory, so address spaces can be mapped, which
eliminates an extra copy.
Parameters:

self

Return type:

bool

elemSize() retval
Parameters:

self

Return type:

int

elemSize1() retval
Parameters:

self

Return type:

int

type() retval
Parameters:

self

Return type:

int

depth() retval
Parameters:

self

Return type:

int

channels() retval
Parameters:

self

Return type:

int

step1() retval
Parameters:

self

Return type:

int

size() retval
Parameters:

self

Return type:

cv2.typing.Size

empty() retval
Parameters:

self

Return type:

bool

class cv2.cuda.Stream
classmethod Null() retval

Adds a callback to be called on the host after all currently enqueued items in the stream have completed.

@note Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization
that may depend on outstanding device work or other callbacks that are not mandated to run earlier.
Callbacks without a mandated order (in independent streams) execute in undefined order and may be
serialized.
Parameters:

cls

Return type:

Stream

__init__(self)
Parameters:

self

Return type:

None

__init__(self, allocator: GpuMat.Allocator)
Parameters:
  • self

  • allocator (GpuMat.Allocator) –

Return type:

None

__init__(self, cudaFlags: int)
Parameters:
  • self

  • cudaFlags (int) –

Return type:

None

queryIfComplete() retval

Returns true if the current stream queue is finished. Otherwise, it returns false.

Parameters:

self

Return type:

bool

waitForCompletion() None

Blocks the current CPU thread until all operations in the stream are complete.

Parameters:

self

Return type:

None

waitEvent(event) None

Makes a compute stream wait on an event.

Parameters:
  • self

  • event (Event) –

Return type:

None

cudaPtr() retval
Parameters:

self

Return type:

cv2.typing.IntPointer

class cv2.cuda.TargetArchs
static has(major, minor) retval

There is a set of methods to check whether the module contains intermediate (PTX) or binary CUDA code for the given architecture(s):

@param major Major compute capability version.
@param minor Minor compute capability version.
Parameters:
  • major (int) –

  • minor (int) –

Return type:

bool

static hasPtx(major, minor) retval
Parameters:
  • major (int) –

  • minor (int) –

Return type:

bool

static hasBin(major, minor) retval
Parameters:
  • major (int) –

  • minor (int) –

Return type:

bool

static hasEqualOrLessPtx(major, minor) retval
Parameters:
  • major (int) –

  • minor (int) –

Return type:

bool

static hasEqualOrGreater(major, minor) retval
Parameters:
  • major (int) –

  • minor (int) –

Return type:

bool

static hasEqualOrGreaterPtx(major, minor) retval
Parameters:
  • major (int) –

  • minor (int) –

Return type:

bool

static hasEqualOrGreaterBin(major, minor) retval
Parameters:
  • major (int) –

  • minor (int) –

Return type:

bool

Functions

cv2.cuda.Event_elapsedTime(start, end) retval
Return type:

object

cv2.cuda.GpuMat_defaultAllocator() retval
Return type:

object

cv2.cuda.GpuMat_setDefaultAllocator(allocator) None
Return type:

object

cv2.cuda.Stream_Null() retval

Adds a callback to be called on the host after all currently enqueued items in the stream have completed.

@note Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization
that may depend on outstanding device work or other callbacks that are not mandated to run earlier.
Callbacks without a mandated order (in independent streams) execute in undefined order and may be
serialized.
Return type:

object

cv2.cuda.TargetArchs_has(major, minor) retval

There is a set of methods to check whether the module contains intermediate (PTX) or binary CUDA code for the given architecture(s):

@param major Major compute capability version.
@param minor Minor compute capability version.
Return type:

object

cv2.cuda.TargetArchs_hasBin(major, minor) retval
Return type:

object

cv2.cuda.TargetArchs_hasEqualOrGreater(major, minor) retval
Return type:

object

cv2.cuda.TargetArchs_hasEqualOrGreaterBin(major, minor) retval
Return type:

object

cv2.cuda.TargetArchs_hasEqualOrGreaterPtx(major, minor) retval
Return type:

object

cv2.cuda.TargetArchs_hasEqualOrLessPtx(major, minor) retval
Return type:

object

cv2.cuda.TargetArchs_hasPtx(major, minor) retval
Return type:

object

cv2.cuda.createContinuous(rows, cols, type[, arr]) arr

Creates a continuous matrix.

Matrix is called continuous if its elements are stored continuously, that is, without gaps at the end of each row.

Parameters:
  • rows (int) – Row count.

  • cols (int) – Column count.

  • type (int) – Type of the matrix.

  • arr (cv2.typing.MatLike | None) – Destination matrix. This parameter changes only if it has a proper type and area (\(\texttt{rows} \times \texttt{cols}\) ).

Return type:

cv2.typing.MatLike

cv2.cuda.createGpuMatFromCudaMemory(rows, cols, type, cudaMemoryAddress[, step]) retval

Bindings overload to create a GpuMat from existing GPU memory.

Note

Overload for generation of bindings only, not exported or intended for use internally from C++.@overload

Note

Overload for generation of bindings only, not exported or intended for use internally from C++.

Parameters:
  • rows (int) – Row count.

  • cols (int) – Column count.

  • type (int) – Type of the matrix.

  • cudaMemoryAddress (int) – Address of the allocated GPU memory on the device. This does not allocate matrix data. Instead, it just initializes the matrix header that points to the specified \a cudaMemoryAddress, which means that no data is copied. This operation is very efficient and can be used to process external data using OpenCV functions. The external data is not automatically deallocated, so you should take care of it.

  • step (int) – Number of bytes each matrix row occupies. The value should include the padding bytes at the end of each row, if any. If the parameter is missing (set to Mat::AUTO_STEP ), no padding is assumed and the actual step is calculated as cols*elemSize(). See GpuMat::elemSize.

  • size – 2D array size: Size(cols, rows). In the Size() constructor, the number of rows and the number of columns go in the reverse order.

Return type:

GpuMat

cv2.cuda.ensureSizeIsEnough(rows, cols, type[, arr]) arr

Ensures that the size of a matrix is big enough and the matrix has a proper type.

The function does not reallocate memory if the matrix has proper attributes already.

Parameters:
  • rows (int) – Minimum desired number of rows.

  • cols (int) – Minimum desired number of columns.

  • type (int) – Desired matrix type.

  • arr (cv2.typing.MatLike | None) – Destination matrix.

Return type:

cv2.typing.MatLike

cv2.cuda.fastNlMeansDenoising(src, h[, dst[, search_window[, block_size[, stream]]]]) dst

Perform image denoising using Non-local Means Denoising algorithmhttp://www.ipol.im/pub/algo/bcm_non_local_means_denoising with several computational optimizations. Noise expected to be a gaussian white noise

This function expected to be applied to grayscale images. For colored images look at FastNonLocalMeansDenoising::labMethod.

@sa fastNlMeansDenoising

Parameters:
  • src (GpuMat) – Input 8-bit 1-channel, 2-channel or 3-channel image.

  • dst (GpuMat | None) – Output image with the same size and type as src .

  • h (float) – Parameter regulating filter strength. Big h value perfectly removes noise but alsoremoves image details, smaller h value preserves details but also preserves some noise

  • search_window (int) – Size in pixels of the window that is used to compute weighted average forgiven pixel. Should be odd. Affect performance linearly: greater search_window - greater denoising time. Recommended value 21 pixels

  • block_size (int) – Size in pixels of the template patch that is used to compute weights. Should beodd. Recommended value 7 pixels

  • stream (Stream) – Stream for the asynchronous invocations.

Return type:

GpuMat

cv2.cuda.fastNlMeansDenoisingColored(src, h_luminance, photo_render[, dst[, search_window[, block_size[, stream]]]]) dst

Modification of fastNlMeansDenoising function for colored images

The function converts image to CIELAB colorspace and then separately denoise L and AB components with given h parameters using FastNonLocalMeansDenoising::simpleMethod function.

@sa fastNlMeansDenoisingColored

Parameters:
  • src (GpuMat) – Input 8-bit 3-channel image.

  • dst (GpuMat | None) – Output image with the same size and type as src .

  • h_luminance (float) – Parameter regulating filter strength. Big h value perfectly removes noise butalso removes image details, smaller h value preserves details but also preserves some noise

  • photo_render (float) – float The same as h but for color components. For most images value equals 10 will beenough to remove colored noise and do not distort colors

  • search_window (int) – Size in pixels of the window that is used to compute weighted average forgiven pixel. Should be odd. Affect performance linearly: greater search_window - greater denoising time. Recommended value 21 pixels

  • block_size (int) – Size in pixels of the template patch that is used to compute weights. Should beodd. Recommended value 7 pixels

  • stream (Stream) – Stream for the asynchronous invocations.

Return type:

GpuMat

cv2.cuda.getCudaEnabledDeviceCount() retval

Returns the number of installed CUDA-enabled devices.

Use this function before any other CUDA functions calls. If OpenCV is compiled without CUDA support, this function returns 0. If the CUDA driver is not installed, or is incompatible, this function returns -1.

Return type:

int

cv2.cuda.getDevice() retval

Returns the current device index set by cuda::setDevice or initialized by default.

Return type:

int

cv2.cuda.nonLocalMeans(src, h[, dst[, search_window[, block_size[, borderMode[, stream]]]]]) dst

Performs pure non local means denoising without any simplification, and thus it is not fast.

@sa fastNlMeansDenoising

Parameters:
  • src (GpuMat) – Source image. Supports only CV_8UC1, CV_8UC2 and CV_8UC3.

  • dst (GpuMat | None) – Destination image.

  • h (float) – Filter sigma regulating filter strength for color.

  • search_window (int) – Size of search window.

  • block_size (int) – Size of block used for computing weights.

  • borderMode (int) – Border type. See borderInterpolate for details. BORDER_REFLECT101 ,BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now.

  • stream (Stream) – Stream for the asynchronous version.

Return type:

GpuMat

cv2.cuda.printCudaDeviceInfo(device) None
Parameters:

device (int) –

Return type:

None

cv2.cuda.printShortCudaDeviceInfo(device) None
Parameters:

device (int) –

Return type:

None

cv2.cuda.registerPageLocked(m) None

Page-locks the memory of matrix and maps it for the device(s).

Parameters:

m (cv2.typing.MatLike) – Input matrix.

Return type:

None

cv2.cuda.resetDevice() None

Explicitly destroys and cleans up all resources associated with the current device in the currentprocess.

Any subsequent API call to this device will reinitialize the device.

Return type:

None

cv2.cuda.setBufferPoolConfig(deviceId, stackSize, stackCount) None
Parameters:
  • deviceId (int) –

  • stackSize (int) –

  • stackCount (int) –

Return type:

None

cv2.cuda.setBufferPoolUsage(on) None
Parameters:

on (bool) –

Return type:

None

cv2.cuda.setDevice(device) None

Sets a device and initializes it for the current thread.

If the call of this function is omitted, a default device is initialized at the fist CUDA usage.

Parameters:

device (int) – System index of a CUDA device starting with 0.

Return type:

None

cv2.cuda.unregisterPageLocked(m) None

Unmaps the memory of matrix and makes it pageable again.

Parameters:

m (cv2.typing.MatLike) – Input matrix.

Return type:

None

cv2.cuda.wrapStream(cudaStreamMemoryAddress) retval

Bindings overload to create a Stream object from the address stored in an existing CUDA Runtime API stream pointer (cudaStream_t).

Note

Overload for generation of bindings only, not exported or intended for use internally from C++.

Parameters:

cudaStreamMemoryAddress (int) – Memory address stored in a CUDA Runtime API stream pointer (cudaStream_t). The created Stream object does not perform any allocation or deallocation and simply wraps existing raw CUDA Runtime API stream pointer.

Return type:

Stream