Decodes the input image data and converts the local image into the Image class for subsequent preprocessing and inference services. Currently, .jpeg and .png images are supported.
For details about the API, see decode.
Prepare a local image file to be decoded, initialize the ImageProcessor class, and call the decode API of the ImageProcessor class to decode and return the output Image object.

Key steps are demonstrated as follows:
Construct the ImageProcessor object. You need to specify the device ID during the construction.
Pass parameters in a proper format to the decode API.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from mindx.sdk import base from mindx.sdk.base import ImageProcessor, Image def process(): # Image decoding # Initialize the ImageProcessor object. imageProcessor = ImageProcessor(device_id) image_path = "test_image.jpg" # Read the image path for decoding. The decoding format is nv12 (YUV_SP_420). decoded_image = imageProcessor.decode(image_path, base.nv12) if __name__ == "__main__": base.mx_init() # Initialize resources. process() base.mx_deinit() # Deinitialize resources. |