ImageSegmentation imageSegmentation = new ImageSegmentation(getApplicationContext());
SegConfiguration config = new SegConfiguration.Builder()
.setProcessMode(VisionTextConfiguration.MODE_IN)
.setSegmentationType(SegConfiguration.TYPE_PORTRAIT_SEGMENTATION_VIDEO)
.build();
imageSegmentation.setConfiguration(config);VisionImageMetadata.Builder builder = new VisionImageMetadata.Builder();
builder.setFormat(17);
int originalHeight = 200;
int originalWidth = 200;
builder.setHeight(originalHeight);
builder.setWidth(originalWidth);
builder.setRotation(0);
VisionImageMetadata metadata = builder.build();byte[] yuvBytes = new byte[originalWidth * originalHeight * 3 / 2];
VisionImage image = VisionImage.fromByteArray(yuvBytes, metadata);
int resultCode = imageSegmentation.doSegmentation(image, mImageResult, null);
ImageResult mImageResult = new ImageResult();
byte[] resultBytes = mImageResult.getByteArray();
{
"resultCode":0
}
可以的,在detect()方法中会默认启动引擎,如果引擎已经启动则不会再次启动,开发者可以放心使用。
视频人像分割需要输入的图像大小1200w像素。
视频人像分割为端侧能力,手机如果是国内版本,需要通过懒加载方式下载到本地,需要联网;海外版本,不需要联网。