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.
- Maximum resolution of the input image: 8192 x 8192
- Minimum resolution of the input image: 32 x 32
- The original 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 image format: YUV_SP_420 and YVU_SP_420 (nv12, nv21)
- Output image format: JPEG, for example, *.jpg
Prototype
APP_ERROR Encode(const Image& inputImage, const std::string savePath, const uint32_t encodeLevel = 100);
APP_ERROR Encode(const Image& inputImage, std::shared_ptr<uint8_t>& outDataPtr,
uint32_t& outDataSize, const uint32_t encodeLevel = 100);
Parameter Description
Parameter |
Input/Output |
Description |
|---|---|---|
inputImage |
Input |
Image class before encoding. The Image classes 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 input encoding level ranges from 0 to 100 and defaults to 100. For the Atlas inference products, it ranges from 1 to 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. |
Return Parameter Description
Data Structure |
Description |
|---|---|
APP_ERROR |
Error code returned during program execution. For details, see the MxBase/ErrorCode/ErrorCode.h file. |