Huawei MLKit ImageSegmentaion return null value

265 views Asked by At

I'm using Huawei SDK's to erase background from image.

Case 1:

When using com.huawei.hms:ml-computer-vision-segmentation:2.0.4.300 Everything works perfectly But google play store reject app to stated as

Your app contains content that doesn’t comply with the Device and Network Abuse policy. We found your app is using a non-compliant version of Huawei Mobile Services SDK SDK which contains code to download or install applications from unknown sources outside of Google Play. Given the nature of the SDK, please remove it from the version of your app submitted to the Play Store.

Case 2:

when using

com.huawei.hms:ml-computer-vision-segmentation:3.5.0.303 this updated version then google play store approve my app but getting null pointer exception on Erased Image foreground height and width.

my code is

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);
}

If anyone knows this issue please guide me. Thanks !

I have tried with latest sdk's but didn't successful.

1

There are 1 answers

4
Zinna On

You can try to integrate the full SDK on Google Play Store.

Please get more information from the URL below.

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'
}  

If you still have issues, please try to catch the logcat logs. So we can help to investigate.