Decode
Function Usage
Image decoding API of the ImageProcessor class. The memory allocated by this API does not need to be managed or destroyed by users. Only the memory allocated on the host can be used as the input of this API. Currently, the data type of the input image memory can be JPEG or PNG.
- JPG/JPEG format:
- Maximum resolution of the JPG/JPEG input image: 8192 x 8192. (The RGB_888 and BGR_888 formats support only 4096 x 4096.)
- Minimum resolution of the JPG/JPEG input image: 32 x 32
- Supported formats by the output decoded images and outputImage: YUV_SP_420 and YVU_SP_420. (The Atlas inference products also support RGB_888 and BGR_888 formats.)
- Output image width: a multiple of 128 (Atlas 200/300/500 inference product); a multiple of 64 (Atlas inference products); a multiple of 16 (RGB_888 and BGR_888). The decoding API automatically aligns the width.
- Output image height: a multiple of 16. The decoding API automatically aligns the height.
Restrictions on the JPG and JPEG input image format:- Only Huffman coding is supported. The subsample of the stream is 444, 422, 420, 400, or 440.
- Arithmetic coding is not supported.
- The progressive JPEG format is not supported.
- The JPEG 2000 format is not supported.
- PNG format:
- Maximum resolution of the PNG input image: 4096 x 4096.
- Minimum resolution of the PNG input image: 32 x 32.
- decodeFormat does not need to be set. By default, decoding is performed based on the PNG source format. For example:
- If the PNG image channel is in RGB/GRAY format, the format of the decoded output image is RGB_888.
- If the PNG image channel is in RGBA/AGRAY format, the format of the decoded output image is RGBA_8888.
- Output image width: a multiple of 128. The decoding API automatically aligns the width.
- Output image height: a multiple of 16. The decoding API automatically aligns the height.
Prototype
APP_ERROR Decode(const std::shared_ptr<uint8_t> dataPtr, const uint32_t dataSize,
Image& outputImage, const ImageFormat decodeFormat = ImageFormat::YUV_SP_420);
APP_ERROR Decode(const std::string inputPath, Image& outputImage,
const ImageFormat decodeFormat = ImageFormat::YUV_SP_420);
Parameter Description
Return Parameter Description
Data Structure |
Description |
|---|---|
APP_ERROR |
Error code returned during program execution. For details, see the MxBase/ErrorCode/ErrorCode.h file. |
Parent topic: ImageProcessor