Tensor类的抠图接口,支持异步执行,使用该接口申请的Tensor内存无需用户管理,由内部管理释放。
当前仅支持Atlas 推理系列产品。
批量抠图的场景,输入Tensor数量只支持一个,抠图配置参数“cropRectVec”长度不超过256,输出Tensor数不超过256且应满足输出Tensor数 = 输入图片张数 * 抠图配置参数“cropRectVec”长度。
APP_ERROR Crop(const Tensor &inputTensor, const Rect &cropRect, Tensor &outputTensor, bool keepMargin = false, AscendStream& stream = AscendStream::DefaultStream());
APP_ERROR Crop(const Tensor &inputTensor, const std::vector<Rect> &cropRectVec, std::vector<Tensor> &outputTensorVec, bool keepMargin = false, AscendStream& stream = AscendStream::DefaultStream());
参数名 |
输入/输出 |
说明 |
---|---|---|
inputTensor |
输入 |
Tensor类,输入张量,不可为空,需在Device/DVPP侧分配内存,数据类型为UINT8。 输入张量宽度范围为[10, 4096],高度范围为[6, 4096],若输入或输出张量格式包含YUV400时,宽度范围为[18, 4096]。 |
cropRect |
输入 |
输入Tensor的抠图坐标框,不得超过输入张量的宽高范围。 |
cropRectVec |
输入 |
输入Tensor的抠图坐标框列表(针对批量抠图场景)。 |
outputTensor |
输出 |
输出抠图后的Tensor类。 |
outputTensorVec |
输出 |
输出抠图后的Tensor类列表(针对批量抠图场景)。 |
keepMargin |
输入 |
输出的“outputTensor”中是否保留Tensor中无效的边界区域。默认值为“false”,表示不保留Tensor中无效的边界区域,即输出Tensor宽高与抠图宽高一致。 |
stream |
输入 |
输入用于异步执行的Stream,默认为“AscendStream::DefaultStream()”,表示创建一个默认流(即同步执行)。 |
数据结构 |
说明 |
---|---|
APP_ERROR |
程序执行返回的错误码,请参考APP_ERROR说明。 |