文档管理中心
API参考HUAWEI HiAI Enginecom.huawei.hiai.hiai-engine.huawei-hiai-visioncom.huawei.hiai.vision.imageImageSegmentation

ImageSegmentation

展开

Class Info

com.huawei.hiai.vision.image.segmentation.ImageSegmentation

本接口可以对输入图像中包含人像的部分进行人像分割检测,分割结果表现为人像和背景区分呈现。

  • 图片人像分割:人像区域为白色,背景为黑色。可以利用其进行图像前景背景替换和背景虚化等美化。
  • 图像语义分割:对拍照图像进行像素级的识别和分割,从而获得图像中物体的类别信息以及精确位置信息。
  • 视频人像分割:支持实时视频流(如手机Camera)的实时处理,开发者将实时视频流的每一帧图像传输到HiAiEngine,算法对图中的人像进行分割,并将字节数组的掩码结果,返回给用户。

Public Constructor Summary

展开

Constructor Name

ImageSegmentation(Context context)

构造ImageSegmentation对象。

Public Method Summary

展开

Qualifier and Type

Method Name

HwHiAIResultCode

doSegmentation(VisionImage image, ImageResult segResult, IVisionCallback cb)

图片人像分割结果,返回分割结果码。

图像语义分割结果,返回分割结果码。

视频人像分割结果,返回分割功能返回码。

void

setConfiguration(SegConfiguration sc)

选择人像分割或语义分割。

Public Constructors

ImageSegmentation

展开

Constructor

public ImageSegmentation (Context context)

构造对象实例。

Parameters
展开

Name

Description

context

传入应用上下文。

Public Methods

doSegmentation

展开

Method

public HwHiAIResultCode doSegmentation (VisionImage image, ImageResult segResult)

图片人像分割结果,返回分割结果码。

图像语义分割结果,返回分割结果码。

视频人像分割结果,返回分割功能返回码。

Parameters
展开

Name

Description

image

Bitmap类型图片数据。

segResult

结果类,用于获取分割结果。

cb

回调函数接口对象。

  • 传入null,表示同步处理。
  • 传入非null,即回调函数接口对象,表示异步处理,用于异步返回结果。
Return
展开

Type

Description

int

执行结果返回码。

setConfiguration

展开

Method

public void setConfiguration (SegConfiguration sc)

选择图片人像分割或图像语义分割 。

Parameters
展开

Name

Description

sc

  • 使用SegmentationConfiguration的setSegmentationType(int type)方法确定选择分割方式,其中传入参数type=SegmentationConfiguration.TYPE_PORTRAIT表示人像分割。
  • 使用SegmentationConfiguration的setSegmentationType(int type)方法确定选择人像还是语义分割,其中传入参数SegmentationConfiguration.TYPE_SEMANTIC表示语义分割;
  • 使用SegConfiguration的setSegmentationType(int type)方法确定选择人像还是语义分割。还是视频人像分割,其中传入参数SegConfiguration.TYPE_PORTRAIT_SEGMENTATION_VIDEO =表示视频人像分割。
在 API参考 中进行搜索
请输入您想要搜索的关键词