文档
注册

Crop

函数功能

ImageProcessor类的图像抠图接口,Atlas 推理系列产品(Ascend 310P AI处理器支持异步执行,使用该接口申请的Image内存无需用户管理,由内部管理释放,抠图效果示意图请参见图1

输入输出Image类支持的图像格式参考如下。
  • Atlas 200/300/500 推理产品支持YUV_SP_420、YVU_SP_420(nv12、nv21)。
  • Atlas 200I/500 A2 推理产品支持YUV_SP_420、YVU_SP_420(nv12、nv21)。
  • Atlas 推理系列产品(Ascend 310P AI处理器支持YUV_SP_420、YVU_SP_420、RGB_888、BGR_888(nv12、nv21、rgb、bgr),其中RGB(BGR)图像格式分辨率不超过(4096 * 4096)。
  1. “inputImage”的真实图片分辨率范围:18 * 6 ~ 4096 * 4096,其中 YUV_SP_420 和 YVU_SP_420 格式的分辨率为18 * 6 ~ 8192 * 8192。
  2. 抠图区域不超出输入图片区域,输入抠图坐标框“cropRect”的四个值推荐均为偶数。

    除RGB、BGR以外,若包含奇数,则左上角坐标自动向下取偶数,右下角坐标自动向上取偶数。

    抠图区域的最大分辨率为4096 * 4096,最小分辨率为18 * 6。

    例如:cropRect{1, 1, 1287, 1287},实际抠图宽高为:((1287 + 1) - (1 - 1))= 1288,对应的分辨率为1288 * 1288。

  3. 输出“outputImageVec”中,各项图片的宽自动与16对齐, 高与2对齐,范围为:32 * 6 ~ 4096 * 4096。

批量输入图片的抠图场景,输入图片数量不超过12张,抠图配置参数“cropRectVec”长度不超过256,输出图片张数不超过256且应满足输出图片张数 = 输入图片张数 * 抠图配置参数“cropRectVec”长度

图1 抠图

函数原型

APP_ERROR ImageProcessor::Crop(const Image& inputImage, const Rect& cropRect, Image& outputImage);
APP_ERROR ImageProcessor::Crop(const Image& inputImage, const Rect& cropRect, Image& outputImage, AscendStream& stream);
APP_ERROR ImageProcessor::Crop(const Image& inputImage, const std::vector<Rect>& cropRectVec, std::vector<Image>& outputImageVec);
APP_ERROR ImageProcessor::Crop(const Image& inputImage, const std::vector<Rect>& cropRectVec, std::vector<Image>& outputImageVec, AscendStream& stream);
APP_ERROR ImageProcessor::Crop(const std::vector<Image>& inputImageVec, const std::vector<Rect>& cropRectVec, std::vector<Image>& outputImageVec);
APP_ERROR ImageProcessor::Crop(const std::vector<Image>& inputImageVec, const std::vector<Rect>& cropRectVec, std::vector<Image>& outputImageVec, AscendStream& stream);

参数说明

参数名

输入/输出

说明

inputImage

输入

输入抠图前的Image类。

Decode接口和其他VPC接口获取的Image类可以直接作为输入。若是用户自定义构造的Image类,则需要设置图像宽高。

inputImageVec

输入

输入抠图前的Image类列表(针对批量抠图场景)。

cropRect

输入

输入图像的抠图坐标框。

cropRectVec

输入

输入图像的抠图坐标框列表(针对批量抠图场景)。

outputImage

输出

输出抠图后的Image类。

outputImageVec

输出

输出抠图后的Image类列表(针对批量抠图场景)。

stream

输入

输入用于异步执行的Stream,具体请参见AscendStream

返回参数说明

数据结构

说明

APP_ERROR

程序执行返回的错误码,请参考APP_ERROR说明

搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词