Git Product home page Git Product logo

Comments (4)

SoftwareGift avatar SoftwareGift commented on May 29, 2024

Could you show me your code? The possible cause is that the value range should be 0-255.We've done some post-processing on the images.Please carefully find the relevant code in the project.

from hms-ml-demo.

Mouadabdelghafouraitali avatar Mouadabdelghafouraitali commented on May 29, 2024

@SoftwareGift thank you for your comment, please let me explain the whole scenario, because there's no way to record the video (record what happen inside LensEnginePreview), I tried to capture the view and converting it to Bitmap, every second I pass the bitmap to MediaRecorder in order to generate a video file.

The issue, is related to the Bitmap inside GraphicOverlay, I don't know why but when I try to convert the LensEnginePreview to Bitmap The image loses its width.

Regarding the code : I've tried to use the same code in the Gesture-Change-Background and the same issue happened.

View to Bitmap (Using Kotlin KTX) :

    fun view2Bitmap(lens: LensEnginePreview): Bitmap {
        return lens.drawToBitmap()
    }

View to Bitmap :

public static Bitmap view2Bitmap(final View view) {
        if (view == null) return null;
        boolean drawingCacheEnabled = view.isDrawingCacheEnabled();
        boolean willNotCacheDrawing = view.willNotCacheDrawing();
        view.setDrawingCacheEnabled(true);
        view.setWillNotCacheDrawing(false);
        Bitmap drawingCache = view.getDrawingCache();
        Bitmap bitmap;
        if (null == drawingCache || drawingCache.isRecycled()) {
            view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
                    View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
            view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
            view.buildDrawingCache();
            drawingCache = view.getDrawingCache();
            if (null == drawingCache || drawingCache.isRecycled()) {
                bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.RGB_565);
                Canvas canvas = new Canvas(bitmap);
                view.draw(canvas);
            } else {
                bitmap = Bitmap.createBitmap(drawingCache);
            }
        } else {
            bitmap = Bitmap.createBitmap(drawingCache);
        }
        view.setWillNotCacheDrawing(willNotCacheDrawing);
        view.setDrawingCacheEnabled(drawingCacheEnabled);
        return bitmap;
    }

please use one of the above code in the Gesture-Change-Background project, and you will see what I'm talking about.

Thank you

from hms-ml-demo.

SoftwareGift avatar SoftwareGift commented on May 29, 2024

The pixel value of the image ranges from 0 to 255. You can write the bitmap value to a txt file and see if the value is the same as you expected.

from hms-ml-demo.

Mouadabdelghafouraitali avatar Mouadabdelghafouraitali commented on May 29, 2024

I've managed to fix this issue, thank you

from hms-ml-demo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.