TensorToImage

Function Usage

Converts the Tensor class on the host to the Image class on the host, or converts the Tensor class on the device to the Image class on the DVPP.

During the conversion, the width of Image is 16-pixel aligned upwards, and the height of Image is 2-pixel aligned upwards. The converted Image class object has a padding region.

The converted Image class can call the member function GetSize() to return the Size class object to view the width and height after padding, and call the member function GetOriginalSize() to return the Size class object to view the original width and height of the image.

Example:

Prototype

1
static APP_ERROR Image::TensorToImage(const Tensor& inputTensor, Image& Image, const ImageFormat& imageFormat);

Parameters

Parameter

Input/Output

Description

inputTensor

Input

Tensor class, input tensor. The input must meet the following requirements:

  • The element type must be uint8.
  • The dimensions of the tensor must be 2 (in YUV400 format), 3, or 4.
  • The width, height, and number of channels of the tensor must match those of imageFormat.

Image

Output

Image class, outputs. The memory is allocated on the DVPP side.

imageFormat

Input

ImageFormat class that specifies the image format, which must match the image format corresponding to the inputTensor data.

Response Parameters

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.