VPI - Vision Programming Interface

3.0 Release

Convolution

Convolves an image with a 2D kernel. More...

Functions

VPIStatus vpiSubmitConvolution (VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, const float *kernelData, int32_t kernelWidth, int32_t kernelHeight, VPIBorderExtension border)
 Runs a generic 2D convolution over an image. More...
 
VPIStatus vpiSubmitSeparableConvolution (VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, const float *kernelXData, int32_t kernelXSize, const float *kernelYData, int32_t kernelYSize, VPIBorderExtension border)
 Runs a generic 2D convolution operation over an image, optimized for separable kernels. More...
 

Detailed Description

Convolves an image with a 2D kernel.

Refer to Convolution for more details and usage examples regarding Convolution. Refer to Separable Convolution for more details and usage examples regarding Separable Convolution.

vpiSubmitConvolution is used for generic 2D kernels, separable or not. For separable kernels, it's usually more efficient to use vpiSubmitSeparableConvolution.

Function Documentation

◆ vpiSubmitConvolution()

VPIStatus vpiSubmitConvolution ( VPIStream  stream,
uint64_t  backend,
VPIImage  input,
VPIImage  output,
const float *  kernelData,
int32_t  kernelWidth,
int32_t  kernelHeight,
VPIBorderExtension  border 
)

#include </opt/nvidia/vpi3/include/vpi/algo/Convolution.h>

Runs a generic 2D convolution over an image.

Parameters
[in]streamThe stream handle where the operation will be queued in.
  • Must not be NULL.
  • Stream must have enabled the backends that will execute the algorithm.
[in]backendBackend that will execute the algorithm.
[in]inputInput image to be convolved with the kernel.
[out]outputOutput image where the result is written to.
  • Must not be NULL.
  • Must have same dimensions as input image.
  • Image must have enabled the backends that will execute the algorithm.
  • With PVA, it must have same format as input image.
  • With other backends, format may be:
[in]kernelWidth,kernelHeightKernel dimensions.
  • Must be between 1x1 and 11x11 and can be non-square.
[in]kernelDataConvolution kernel coefficients, in row-major layout. The kernel elements are copied to an internal buffer. The buffers passed can be deallocated after the call.
  • It cannot be NULL.
  • It must point to a buffer with kernelWidth * kernelHeight elements, if not it'll lead to undefined behavior
  • On PVA backend, kernel weights are restricted to |weight|<=1.
[in]borderHow to handle pixels outside image boundaries.
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENTinput or output are NULL.
VPI_ERROR_INVALID_ARGUMENTkernelWidth or kernelHeight are outside valid range.
VPI_ERROR_INVALID_ARGUMENTkernelData is NULL.
VPI_ERROR_INVALID_ARGUMENTSome weight in kernelData is outside valid range.
VPI_ERROR_INVALID_ARGUMENTinput or output dimensions outside valid range.
VPI_ERROR_INVALID_ARGUMENTinput and output image must have same dimensions.
VPI_ERROR_INVALID_ARGUMENTborder not supported.
VPI_ERROR_INVALID_ARGUMENTbackend is invalid or unknown.
VPI_ERROR_INVALID_IMAGE_FORMATinput or output format not supported.
VPI_ERROR_INVALID_IMAGE_FORMATinput and output formats are not compatible.
VPI_ERROR_NOT_IMPLEMENTEDConvolution algorithm is not supported by given backend.
VPI_ERROR_INVALID_OPERATIONBackend hardware not available.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream, input or output.
VPI_SUCCESSOperation executed successfully.

◆ vpiSubmitSeparableConvolution()

VPIStatus vpiSubmitSeparableConvolution ( VPIStream  stream,
uint64_t  backend,
VPIImage  input,
VPIImage  output,
const float *  kernelXData,
int32_t  kernelXSize,
const float *  kernelYData,
int32_t  kernelYSize,
VPIBorderExtension  border 
)

#include </opt/nvidia/vpi3/include/vpi/algo/Convolution.h>

Runs a generic 2D convolution operation over an image, optimized for separable kernels.

Parameters
[in]streamThe stream handle where the operation will be queued in.
  • Must not be NULL.
  • Stream must have enabled the backends that will execute the algorithm.
[in]backendBackend that will execute the algorithm.
[in]inputInput image to be convolved with the kernel.
[out]outputOutput image where the result is written to.
  • Must not be NULL.
  • Must have same dimensions and format as input image.
  • Image must have enabled the backends that will execute the algorithm.
[in]kernelXSize,kernelYSizeKernel dimensions in X and Y directions.
  • Must be between 1x1 and 11x11.
[in]kernelXData,kernelYDataConvolution kernel coefficients, in both X and Y directions respectively. The kernel elements are copied to an internal buffer. The buffers passed can be deallocated after the call.
  • kernelXData and kernelYData must point to a buffer with kernelXSize and kernelYSize elements respectively.
  • They can't be NULL.
  • On PVA backend, kernel weights are restricted to |weight|<1.
[in]borderHow to handle pixels outside image boundaries.
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENTinput or output are NULL.
VPI_ERROR_INVALID_ARGUMENTkernelXData or kernelYData are NULL.
VPI_ERROR_INVALID_ARGUMENTkernelXSize or kernelYSize outside valid range.
VPI_ERROR_INVALID_ARGUMENTSome weight in kernelData is outside valid range.
VPI_ERROR_INVALID_ARGUMENTinput or output image dimensions outside valid range..
VPI_ERROR_INVALID_ARGUMENTborder not supported.
VPI_ERROR_INVALID_ARGUMENTinput and output image dimensions and format do not match.
VPI_ERROR_INVALID_ARGUMENTbackend is invalid or unknown.
VPI_ERROR_INVALID_IMAGE_FORMATinput and output formats aren't supported
VPI_ERROR_NOT_IMPLEMENTEDSeparable Convolution algorithm is not supported by given backend.
VPI_ERROR_INVALID_OPERATIONBackend hardware not available.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream, input or output.
VPI_SUCCESSOperation executed successfully.