'imageSegmentationResult.original return null in android 12 - huawei image segmentation
I'm using huawei image segmentation for background remove from the image. this code work perfectly fine up to android 11 but it get crash on android 12.
Code:
private final void analyse(Bitmap bitmap) {
pd = new ProgressDialog(this, R.style.MyAlertDialogStyle);
pd.setMessage("Process");
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setCancelable(false);
pd.show();
MLFrame mlFrame = MLFrame.fromBitmap(bitmap);
mAnalyzer.asyncAnalyseFrame(mlFrame)
.addOnSuccessListener(new OnSuccessListener<MLImageSegmentation>() {
@Override
public void onSuccess(MLImageSegmentation mlImageSegmentation) {
addSelectedBackground(mlImageSegmentation);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
}
});
}
private void addSelectedBackground(MLImageSegmentation mlImageSegmentation) {
mutableBitmap = Bitmap.createBitmap(
mlImageSegmentation.original.getWidth(),
mlImageSegmentation.original.getHeight(),
Bitmap.Config.ARGB_8888
);
pd.dismiss();
if (maskBitmap != null) {
maskBitmap.recycle();
maskBitmap = null;
}
Canvas canvas = new Canvas(mutableBitmap);
canvas.drawBitmap(mlImageSegmentation.foreground, 0F, 0F, null);
maskBitmap = mutableBitmap;
call();
}
Dependencies:
implementation'com.huawei.agconnect:agconnect-core:1.5.2.300'
implementation 'com.huawei.hms:ml-computer-vision-segmentation:2.1.0.301'
implementation 'com.huawei.hms:ml-computer-vision-image-segmentation-body-model:2.2.0.300'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
