HMS-Core / hms-ml-demo

HMS ML Demo provides an example of integrating Huawei ML Kit service into applications. This example demonstrates how to integrate services provided by ML Kit, such as face detection, text recognition, image segmentation, asr, and tts.
https://developer.huawei.com/consumer/en/hms/huawei-mlkit?ha_source=hms1
Apache License 2.0
356 stars 120 forks source link

Black Image When setExact is FALSE #78

Open Mouadabdelghafouraitali opened 3 years ago

Mouadabdelghafouraitali commented 3 years ago

I'm using the following code to get the foreground only from a given bitmap:

    private MLImageSegmentationAnalyzer analyzer;

    public void analyzer(Bitmap src, MLCallBack mlCallBack) {
        MLImageSegmentationSetting setting = new MLImageSegmentationSetting.Factory()
                .setExact(false)
                .setAnalyzerType(MLImageSegmentationSetting.BODY_SEG)
                .setScene(MLImageSegmentationScene.FOREGROUND_ONLY)
                .create();

        this.analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting);
        MLFrame mlFrame = new MLFrame.Creator().setBitmap(src).create();
        Task<MLImageSegmentation> task = this.analyzer.asyncAnalyseFrame(mlFrame);
        task.addOnSuccessListener(mlImageSegmentationResults ->
                mlCallBack.onMLCompleted(mlImageSegmentationResults.getForeground()))
                .addOnFailureListener(e ->
                        mlCallBack.onMLFailed());
    }

But the output is always BLACK, when I set .setExact(true), everything works fine, I would like to speed up to background remover process that's why I set False to setExact()