Skip to content

Support of converting YUV_240_888 to Bitmap #6

@siralam

Description

@siralam

Hello, first of all thanks for your great library!

I am now trying to do something to each frame returned by Android Camera 2 API (Which I guess most user of this library do).

Note that I have already specified YUV_240_888 for the ImageReader:

        mFrameImageReader = ImageReader.newInstance(largest.getWidth() / 4, largest.getHeight() / 4,
                ImageFormat.YUV_420_888, 2);

And in onImageAvailable:

        @Override
        public void onImageAvailable(ImageReader reader) {
            Image image = reader.acquireNextImage();
            try {
                if (onFrameCallback != null) {
                    ByteBuffer buffer = image.getPlanes()[0].getBuffer();
                    byte[] bytes = new byte[buffer.capacity()];
                    buffer.get(bytes);
                    Bitmap frameBitmap = YuvToRgb.yuvToRgb(rs, bytes, width, height);
                    Log.i("onFrame", frameBitmap.getWidth() + ", " + frameBitmap.getHeight());
                }
            } finally {
                image.close();
            }
        }

When I attach a debugger, I can see the conversion line is executed but before the logging line, the app crashes without any stacktrace, instead giving this error message:

Fatal signal 7 (SIGBUS), code 2, fault addr 0xbe68f040 in tid 1699

Do you have any idea / any working example with Camera 2 API?

By the way, Camera 1 returns NV21 format and I have tried with Camera 1 API and NV21 works perfectly. But Camera 2 does not support NV21...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions