Remap#

Functions#

NVCVStatus pvaRemapCreate(NVCVOperatorHandle *handle, NVCVImageRequirements const *const inRequirements, NVCVImageRequirements const *const outRequirements, NVCVTensorRequirements const *const warpMapRequirements, PVAInterpolationType const interpType, NVCVBorderType const borderMode)

Constructs an instance of the Remap operator.

NVCVStatus pvaRemapSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageHandle in, NVCVImageHandle out, NVCVTensorHandle warpMap)

Submits the Remap operator to a CUDA stream.

NVCVStatus pvaRemapSubmit(NVCVOperatorHandle handle, cupvaStream_t stream, NVCVImageHandle in, NVCVImageHandle out, NVCVTensorHandle warpMap)

Submits the Remap operator to a cuPVA stream.

NVCVStatus pvaRemapValidate(NVCVTensorHandle warpMapHandle, int32_t inWidth, int32_t inHeight, int32_t outWidth, int32_t outHeight)

Validates the warp map.

Functions#

NVCVStatus pvaRemapCreate(
NVCVOperatorHandle *handle,
NVCVImageRequirements const *const inRequirements,
NVCVImageRequirements const *const outRequirements,
NVCVTensorRequirements const *const warpMapRequirements,
PVAInterpolationType const interpType,
NVCVBorderType const borderMode,
)#

Constructs an instance of the Remap operator.

The Remap algorithm applies a generic geometric transformation to an image using a warp map. For each pixel in the output image, the warp map specifies the corresponding (possibly non-integer) source location in the input image.

Specifically, for output[i][j], the warp map provides a float coordinate warpMap[i][j] = {inX, inY}

  • When using nearest neighbor interpolation, the output pixel is computed by rounding the float coordinate to the nearest integer: output[i][j] = input[round(inY)][round(inX)] where round(inX) = floor(inX + 0.5) and round(inY) = floor(inY + 0.5)

  • When using bilinear interpolation, the output pixel is computed by bilinearly interpolating the four neighboring input pixels surrounding the float coordinate: output[i][j] = top + (bottom - top) * fracY top = topLeft + (topRight - topLeft) * fracX bottom = bottomLeft + (bottomRight - bottomLeft) * fracX where the four neighboring input pixels are:

    • topLeft = input[floor(inY)][floor(inX)]

    • topRight = input[floor(inY)][ceil(inX)]

    • bottomLeft = input[ceil(inY)][floor(inX)]

    • bottomRight = input[ceil(inY)][ceil(inX)] The interpolation weights {fracX, fracY} are determined by the fractional part of inX and inY.

Limitations: Remap is often used to perform a geometric transformation to an image using a smoothly varying warp map. To do this efficiently on PVA, we process in a regular fixed-size raster scan tile sequence across the output image (the output tile size is 64x30). For each output tile, the size of the required input tile is defined by the minimal and maximal X and Y values of the warp map within that tile. The entire input tile is brought into VMEM at once, and is double buffered for efficient pipelining. We define the space for one input tile in VMEM to be as large as possible, which comes out to 32kB. Therefore, the warp map contents must meet the following constraint for each tile: (maxX - minX + 1) * (maxY - minY + 1) * BytesPerPixel < 32KB. pvaRemapValidate can be used to check whether the warp map satisfies the above constraint. It will return errors if any input tile exceeds 32KB.

Input: Image sizes and formats are specified in inRequirements.

Image Format

Allowed

U8

Yes

NV12

Yes

Output: Image sizes and formats are specified in outRequirements.

Image Format

Allowed

U8

Yes

NV12

Yes

WarpMap: Data Layout: [kHWC] Channels: [2] Value Range: (-inf, +inf)

Data Type

Allowed

32bit Float

Yes

Parameters borderMode = NVCV_BORDER_CONSTANT or NVCV_BORDER_REPLICATE

Parameters:
  • handle[out] Where the operator instance handle will be written to.

    • Must not be NULL.

  • inRequirements[in] Pointer to the input image NVCVImageRequirements structure.

  • outRequirements[in] Pointer to the output image NVCVImageRequirements structure.

  • warpMapRequirements[in] Pointer to the warp map NVCVTensorRequirements structure.

  • interpType[in] Interpolation type to be used when accessing non integer pixel values. PVAInterpolationType.

  • borderMode[in] Border mode to be used when accessing elements outside input image.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Possible cases include: 1) The handle, stream, input, or output is either NULL or points to an invalid address. 2) The input or output image does not meet the requirements used to create the operator handle. 3) The metadata of the input does not correspond to the correct format.

  • NVCV_ERROR_OUT_OF_MEMORY – Possible cases include: 1) Failed to allocate memory for the operator. 2) Failed to allocate memory for holding input tile buffer.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus pvaRemapSubmit(
NVCVOperatorHandle handle,
cudaStream_t stream,
NVCVImageHandle in,
NVCVImageHandle out,
NVCVTensorHandle warpMap,
)#

Submits the Remap operator to a CUDA stream.

Note

CUDA stream support requirements:

  • PVA SDK 2.7.0 or later

  • Jetpack 7 or later

  • DriveOS 7 or later

  • x86 Emulator is not supported

Parameters:
  • handle[in] Handle to the operator.

  • stream[in] Handle to a valid CUDA stream.

  • in[in] Input image handle.

  • out[out] Output image handle.

  • warpMap[in] Warp map tensor handle.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus pvaRemapSubmit(
NVCVOperatorHandle handle,
cupvaStream_t stream,
NVCVImageHandle in,
NVCVImageHandle out,
NVCVTensorHandle warpMap,
)#

Submits the Remap operator to a cuPVA stream.

Parameters:
  • handle[in] Handle to the operator.

    • Must not be NULL.

  • stream[in] Handle to a valid cuPVA stream.

  • in[in] Input image handle.

  • out[out] Output image handle.

  • warpMap[in] Warp map tensor handle.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus pvaRemapValidate(
NVCVTensorHandle warpMapHandle,
int32_t inWidth,
int32_t inHeight,
int32_t outWidth,
int32_t outHeight,
)#

Validates the warp map.

Return errors if any input tile exceeds 32KB. This API is mainly for debugging purpose.

Parameters:
  • warpMapHandle[in] Handle to the warp map tensor.

  • inWidth[in] Width of the input image.

  • inHeight[in] Height of the input image.

  • outWidth[in] Width of the output image.

  • outHeight[in] Height of the output image.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Invalid warp map due to input tile size exceeding 32KB.

  • NVCV_SUCCESS – Valid warp map.