VPI - Vision Programming Interface

3.1 Release

Crop Scaler

Crops rectangular regions from the input image, rescale them to uniform dimensions and writes them in a single image to be used in further batched image processing. More...

Functions

VPIStatus vpiCreateCropScaler (uint64_t backends, int maxFrames, int maxObjects, VPIPayload *payload)
 Creates payload instance for the Crop Scale algorithm. More...
 
VPIStatus vpiSubmitCropScalerBatch (VPIStream stream, uint64_t backend, VPIPayload payload, VPIImage *frameList, int32_t numFrames, VPIArray objects, int32_t patchWidth, int32_t patchHeight, VPIImage outPatches)
 Crops rectangular regions from the input frames and rescale them all to the same dimensions. More...
 

Detailed Description

Crops rectangular regions from the input image, rescale them to uniform dimensions and writes them in a single image to be used in further batched image processing.

Function Documentation

◆ vpiCreateCropScaler()

VPIStatus vpiCreateCropScaler ( uint64_t  backends,
int  maxFrames,
int  maxObjects,
VPIPayload payload 
)

#include <vpi/algo/CropScaler.h>

Creates payload instance for the Crop Scale algorithm.

Parameters
[in]backendsVPI backends that are eligible to execute the algorithm.
[in]maxFramesMaximum number of frames.
  • Must be >= 1 and <= 128.
[in]maxObjectsMaximum number of objects.
  • Must be >= 1.
[out]payloadPointer to the payload variable that receives the created handle.
Return values
VPI_ERROR_INVALID_OPERATIONBackend isn't enabled in current context.
VPI_ERROR_NOT_IMPLEMENTEDCrop Scaler algorithm is not supported by given backend.
VPI_ERROR_INVALID_CONTEXTCurrent context is destroyed.
VPI_ERROR_OUT_OF_MEMORYCannot allocate required resources.
VPI_SUCCESSOperation executed successfully.

◆ vpiSubmitCropScalerBatch()

VPIStatus vpiSubmitCropScalerBatch ( VPIStream  stream,
uint64_t  backend,
VPIPayload  payload,
VPIImage frameList,
int32_t  numFrames,
VPIArray  objects,
int32_t  patchWidth,
int32_t  patchHeight,
VPIImage  outPatches 
)

#include <vpi/algo/CropScaler.h>

Crops rectangular regions from the input frames and rescale them all to the same dimensions.

Parameters
[in]streamThe stream 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.
  • Must be the backend specified during payload creation or 0 as a shorthand to use this backend.
[in]payloadPayload created by vpiCreateCropScaler.
[in]frameListList of image frames. If an image within frameList is NULL, its correponding objects won't be processed.
  • Must not be NULL.
  • Must point to an array of at least numFrames images.
  • Each image must have enabled the backends that will execute the algorithm.
  • All frames must have the same image format, size, and pitch.
  • The pitch must be a multiple of the element size.
  • Valid image formats:
    Formats CUDA
    VPI_IMAGE_FORMAT_RGBA8 *
    VPI_IMAGE_FORMAT_NV12_ER *
    VPI_IMAGE_FORMAT_NV12 *
[in]numFramesNumber of input frames in the batch.
[in]objectsInput array with bounding boxes associated with each input frame via its index.
  • Must not be NULL.
  • Must have enabled the backends that will execute the algorithm.
  • The index of the input frame for each object must be >= 0 and < numFrames. An out-of-bounds index is undefined behavior.
  • Valid array types:
[in]patchWidthThe width of the patch to be written to outPatches.
  • Must be positive.
[in]patchHeightThe height of the patch to be written to outPatches.
  • Must be positive.
[out]outPatchesImage where the cropped and rescale patches will be written to. The width of each patch will be equal to patchWidth. The height of each patch will be equal to patchHeight. The patch for an object 'o' will then start at row o * patchHeight and have height 'patchHeight'. If image format is different from input frame's, an image format conversion will be performed on the fly.
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENTframeList, objects or outPatches are NULL.
VPI_ERROR_INVALID_ARGUMENTpayload not created by vpiCreateCropScaler.
VPI_ERROR_INVALID_ARGUMENToutPatches' height not divisible by the number of objects.
VPI_ERROR_INVALID_ARGUMENTInput frames have different image size.
VPI_ERROR_INVALID_IMAGE_FORMATInput frames have different image format.
VPI_ERROR_INVALID_ARRAY_TYPEUnsupported array type in objects.
VPI_ERROR_INVALID_PAYLOAD_TYPEpayload is invalid.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream, some image in frameList, outPatches or objects.
VPI_SUCCESSOperation executed successfully.