Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hair Segmentation Not working #81

Open
abi98213 opened this issue Sep 13, 2021 · 1 comment
Open

Hair Segmentation Not working #81

abi98213 opened this issue Sep 13, 2021 · 1 comment

Comments

@abi98213
Copy link

Hey team,
I am trying to run hair segmentation but it is not working and is returning null image as output.

private void createImageTransactor(Bitmap bitmap) {

        MLImageSegmentationSetting setting = new MLImageSegmentationSetting
                .Factory()
                // Set the segmentation mode to hair segmentation.
                .setAnalyzerType(MLImageSegmentationSetting.HAIR_SEG)
                .create();

        MLImageSegmentationAnalyzer analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer(setting);

        MLFrame frame = MLFrame.fromBitmap(bitmap);
        Task<MLImageSegmentation> task = analyzer.asyncAnalyseFrame(frame);

        task.addOnSuccessListener(segmentation -> {
            // Detection success.
            foregroundBitmap = segmentation.foreground;
            imageView.setImageBitmap(foregroundBitmap);
        })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(Exception e) {
                        // Detection failure.
                    }
                });
}

Here is the dependencies graph.

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

@Mike-mei
Copy link
Contributor

You can refer to the answer on StackOverflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants