cv2.cuda
¶
None
Attributes¶
Classes¶
- class cv2.cuda.BufferPool¶
- getBuffer(rows, cols, type) retval ¶
- getBuffer(rows, cols, type) retval ¶
- getAllocator() retval ¶
- Parameters:
self –
- Return type:
GpuMat.Allocator
- class cv2.cuda.DeviceInfo¶
- __init__(self)¶
- Parameters:
self –
- Return type:
None
- deviceID() retval ¶
Returns system index of the CUDA device starting with 0.
- Parameters:
self –
- Return type:
- Parameters:
self –
- Return type:
- maxThreadsDim() retval ¶
- Parameters:
self –
- Return type:
cv2.typing.Vec3i
- maxGridSize() retval ¶
- Parameters:
self –
- Return type:
cv2.typing.Vec3i
- computeMode() retval ¶
- Parameters:
self –
- Return type:
DeviceInfo_ComputeMode
- 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
- 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
- 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
- maxSurfaceCubemapLayered() retval ¶
- Parameters:
self –
- Return type:
cv2.typing.Vec2i
- class cv2.cuda.Event¶
- __init__(self, flags: Event_CreateFlags = ...)¶
- Parameters:
self –
flags (Event_CreateFlags) –
- Return type:
None
- class cv2.cuda.GpuData¶
- class cv2.cuda.GpuMat¶
-
- __init__(self, allocator: GpuMat.Allocator = ...)¶
- Parameters:
self –
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 = ...)¶
- __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, 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 –
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:
self –
arr (GpuMat) –
- 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.UMat) –
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- copyTo([dst]) dst ¶
- setTo(s) retval ¶
- Parameters:
self –
s (cv2.typing.Scalar) –
mask (cv2.typing.MatLike) –
- Return type:
- setTo(s) retval ¶
- setTo(s) retval ¶
- setTo(s) retval ¶
- convertTo(rtype, stream[, dst]) dst ¶
- convertTo(rtype, stream[, dst]) dst ¶
- convertTo(rtype, stream[, dst]) dst ¶
- rowRange(startrow, endrow) retval ¶
- colRange(startcol, endcol) retval ¶
- static defaultAllocator() retval ¶
- Return type:
GpuMat.Allocator
- static setDefaultAllocator(allocator) None ¶
- Parameters:
allocator (GpuMat.Allocator) –
- Return type:
None
- locateROI(wholeSize, ofs) None ¶
- Parameters:
self –
wholeSize (cv2.typing.Size) –
ofs (cv2.typing.Point) –
- Return type:
None
- adjustROI(dtop, dbottom, dleft, dright) retval ¶
- size() retval ¶
- Parameters:
self –
- Return type:
cv2.typing.Size
- cudaPtr() retval ¶
- Parameters:
self –
- Return type:
cv2.typing.IntPointer
- class cv2.cuda.GpuMatND¶
- class cv2.cuda.HostMem¶
-
- __init__(self, alloc_type: HostMem_AllocType = ...)¶
- Parameters:
self –
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
- 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:
- size() retval ¶
- Parameters:
self –
- Return type:
cv2.typing.Size
- 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:
- __init__(self)¶
- Parameters:
self –
- Return type:
None
- __init__(self, allocator: GpuMat.Allocator)¶
- Parameters:
self –
allocator (GpuMat.Allocator) –
- Return type:
None
- queryIfComplete() retval ¶
Returns true if the current stream queue is finished. Otherwise, it returns false.
- Parameters:
self –
- Return type:
- 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.
- static hasEqualOrLessPtx(major, minor) retval ¶
- static hasEqualOrGreater(major, minor) retval ¶
- static hasEqualOrGreaterPtx(major, minor) retval ¶
Functions¶
- 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:
- 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:
- 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.
- 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:
- 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.
- 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:
- 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:
- 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:
- cv2.cuda.getDevice() retval ¶
Returns the current device index set by cuda::setDevice or initialized by default.
- Return type:
- 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:
- 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.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++.