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:

  • If the image width and height of a Tensor class object are 500 and 499, you can call GetOriginalSize() to get the original image size (500 and 499) and call GetSize() to get the actual image size (512 and 500) after padding the converted Image class object.
  • If the image width and height of a Tensor class object are 512 and 500, padding is not required for the Image class object after conversion. The width and height of the converted Image class object are still 512 and 500.

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.