Encode

Function Usage

Image encoding API of the ImageProcessor class. The memory allocated by this API does not need to be managed or destroyed by users.

For details, see Image Encoding.

  • Maximum resolution of the input image: 8192 x 8192
  • Minimum resolution of the input image: 32 x 32
  • The actual width and height of the input image must be even numbers. If they are odd numbers, they are automatically rounded up to an even number. The encoded image automatically pads one pixel.
  • Input image width: a multiple of 16 for YUV420SP or RGB data
  • Input image height: same as the input height or the value rounded up to the nearest multiple of 16 (at least 32)
  • Input format.
    • Atlas 200/300/500 inference product: YUV_SP_420 and YVU_SP_420 (nv12 and nv21)
    • Atlas 200I/500 A2 inference product: YUV_SP_420 and YVU_SP_420 (nv12 and nv21)
    • Atlas inference product and Atlas 800I A2 inference product: YUV_SP_420, YVU_SP_420, RGB_888 and BGR_888 (nv12, nv21, rgb, and bgr). The resolution of the RGB (BGR) image format cannot exceed 4096 x 4096.
  • Output image format: JPEG, for example, *.jpg

Prototype

1
APP_ERROR ImageProcessor::Encode(const Image& inputImage, const std::string savePath, const uint32_t encodeLevel = 100);
1
APP_ERROR ImageProcessor::Encode(const Image& inputImage, std::shared_ptr<uint8_t>& outDataPtr, uint32_t& outDataSize, const uint32_t encodeLevel = 100);

Parameters

Parameter

Input/Output

Description

inputImage

Input

Image class before encoding. The Image class obtained by the Decode API and other VPC APIs can be directly used as inputs.

If the user-defined Image class is used, set the image width and height.

encodeLevel

Input

The default value is 100. For the Atlas 200/300/500 inference product, the input encoding level range is [0, 100].For the Atlas 200I/500 A2 inference product, Atlas inference product and Atlas 800I A2 inference product, the value range is [1, 100].

savePath

Input

Path for storing the encoded image. The file name extension must be jpg.

outDataPtr

Output

Memory data address of the encoded image.

outDataSize

Output

Memory data size of the encoded image.

Response Parameters

Data Structure

Description

APP_ERROR

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