AppcentMobile / removebg

Removebg is a library that effortlessly integrates the U2Net model, allowing users to easily remove backgrounds from images in their Android apps.
MIT License
43 stars 11 forks source link

I have done this below code into JAVA project. but didn't work. #14

Open jinkalzalavadiya opened 4 months ago

jinkalzalavadiya commented 4 months ago
 RemoveBg removeBg = new RemoveBg(CutOutActivity.this);

  removeBg.clearBackground(bitmap).collect(new FlowCollector<Bitmap>() {
            @org.jetbrains.annotations.Nullable
            @Override
            public Object emit(Bitmap bitmap, @NonNull Continuation<? super Unit> continuation) {

                return null;
            }
        }, new Continuation<Unit>() {
            @NonNull
            @Override
            public CoroutineContext getContext() {
                return null;
            }

            @Override
            public void resumeWith(@NonNull Object o) {

            }
        });

Please check above is there any issues?

Thank you.

YueDev commented 4 months ago

execute the following code on a worker thread

    Bitmap bitmap = yourBitmap.copy(Bitmap.Config.ARGB_8888, true);
    Bitmap result = removeBg.removeBackground(bitmap);
    if(result != null) {
        //success
    } else {
        //error
    }
jinkalzalavadiya commented 3 months ago

removeBg.removeBackground(bitmap);
This will not return bitmap. It will return like that

Flow<Bitmap> bitmap1 = removeBg.clearBackground(bitmap);

Have you implement on your JAVA project?

YueDev commented 3 months ago

call this function, it will return a Bitmap. https://github.com/AppcentMobile/removebg/blob/master/removebg/src/main/java/dev/eren/removebg/RemoveBg.kt#L56

hamzakhalil798 commented 4 weeks ago

@YueDev Hey! sorry im new to this can you explain if this library works with java?