用户需准备好本地待解码的图片文件或待解码的图片数据,初始化ImageProcessor类,构造输出的Image对象,通过调用ImageProcessor类的Decode接口解码结果。
图片解码调用流程参考如下:
关键步骤说明如下:
以下为功能特性关键步骤的代码示例,不可以直接拷贝编译运行,仅供参考。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
//初始化 MxInit(); { //构造图像处理类 ImageProcessor imageProcessor(deviceId); //(可选)初始化解码通道 imageProcessor.InitJpegDecodeChannel(); //图像解码 //解码后的图像类 Image decodedImage; //根据图像路径进行解码 std::string imagePath = "image path"; APP_ERROR ret = imageProcessor.Decode(imagePath, decodedImage, ImageFormat::YUV_SP_420); if (ret != APP_ERR_OK) { std::cout << "Decode failed." << std::endl; } } //去初始化 MxDeInit(); |