Channel Reorder

group NVCV_C_ALGORITHM_CHANNEL_REORDER

Functions

NVCVStatus cvcudaChannelReorderCreate(NVCVOperatorHandle *handle)

Constructs and an instance of the channel reorder operator. The operator is used to cha reformats the input from kNHWC format to kNCHW format or from kNCHW format to kNHWC format.

Parameters:

handle[out] Where the image instance handle will be written to.

  • Must not be NULL.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Handle is null.

  • NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaChannelReorderVarShapeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVImageBatchHandle out, NVCVTensorHandle orders_in)

Executes the reformat operation on the given cuda stream. This operation does not wait for completion.

Limitations:

  • Input and output image formats must all have the same number of channels and have only one plane, although the channels can be swizzled (i.e. RGBA8, BGRA8, etc).

  • The number of samples in the input and output ImageBatch must be the same

  • The orders_in tensor must have 2 dimensions. First dimension correspond to the number of images being, and the second the number of channels.

Example: let input be RGBA8 with a pixel = [108,63,18,214], output be YUV8, orders_in = [3,-1,1]

The corresponding pixel in the output will be [214,0,63].

  • Must not be NULL.

  • The order value must be >= 0 and < the number of channels in input image.

  • Tensor dimensions must be NxC, where N is the number of images in the input varshape, and C is the number of channels in the output images.

Note

The output images’ format isn’t updated to reflect the new channel ordering.

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

    • Must not be NULL.

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

  • in[in] input varshape image batch.

  • out[out] output varshape image batch.

  • orders_in[in] 2D tensor with layout “NC” which specifies, for each output image sample in the batch, the index of the input channel to copy to the output channel. Negative indices will map to ‘0’ value written to the corresponding output channel.

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.