Huawei MLKit imagesegmentation返回空值



我正在使用华为SDK从图像中删除背景。

案例1:

在使用com.huawei.hms:ml-computer-vision-segmentation:2.0.4.300但是google play store拒绝了

你的应用包含不符合设备和网络滥用政策的内容。我们发现您的应用程序使用了不兼容的华为移动服务SDK版本,其中包含从Google Play以外的未知来源下载或安装应用程序的代码。鉴于SDK的性质,请将其从提交到Play Store的应用程序版本中删除。

案例2:

在使用

com.huawei.hms:ml-computer-vision-segmentation:3.5.0.303这个更新的版本,然后谷歌play商店批准我的应用程序,但得到空指针异常擦除图像前景的高度和宽度。

我的代码是

public void addSelectedBackground(MLImageSegmentation mlImageSegmentation) {
this.mutableBitmap = Bitmap.createBitmap(mlImageSegmentation.original.getWidth(), mlImageSegmentation.original.getHeight(), Bitmap.Config.ARGB_8888);
this.f1867pd.dismiss();
Bitmap bitmap = maskBitmap;
if (bitmap != null) {
bitmap.recycle();
maskBitmap = null;
}
new Canvas(this.mutableBitmap).drawBitmap(mlImageSegmentation.foreground, 0.0f, 0.0f, (Paint) null);
maskBitmap = this.mutableBitmap;
this.ryLoding.setVisibility(View.GONE);
this.imgMainPic.setImageBitmap(maskBitmap);
}

如果有人知道这个问题请指导我。谢谢!

我已经尝试了最新的sdk,但没有成功。

你可以尝试在Google Play Store中集成完整的SDK。

请从下面的URL获取更多信息。

https://developer.huawei.com/consumer/en/doc/development/hiai - guides/seg - sdk - 0000001050038094

dependencies{
// Import the base SDK.
implementation 'com.huawei.hms:ml-computer-vision-segmentation:3.7.0.302'
// Import the multiclass segmentation model package.
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-multiclass-model:3.7.0.302'
// Import the human body segmentation model package.
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-body-model:3.7.0.302'
// Import the hair segmentation model package.
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-hair-model:3.7.0.302'
}  

如果您仍然有问题,请尝试捕获logcat日志。所以我们可以帮助调查。

最新更新