Closed mqwangios closed 6 years ago
Same here :/ Any solutions?
Frames of the FrameProcessor
are in NV21 format which can't be decoded using BitmapFactory
. You can still convert it to Bitmap
but you would have to use another approach: https://stackoverflow.com/questions/32276522/convert-nv21-byte-array-into-bitmap-readable-format
How to set the output size, I think the output is 1080*1920?
For anyone interested, most straightforward method is to use easyrs library:
//in build.gradle
implementations 'io.github.silvaren:easyrs:0.5.3'
Then convert NV21 to bitmap:
RenderScript rs = RenderScript.create(context); // where context can be your activity, application, etc.
Bitmap outputBitmap = Nv21Image.nv21ToBitmap(rs, frame.image, frame.size.width, frame.size.height);
Why is bitmap null?
private class SampleFrameProcessor implements FrameProcessor { @Override public void process(@NotNull Frame frame) { // Perform frame processing, if needed Bitmap bitmap = BitmapFactory.decodeByteArray(frame.getImage(), 0, frame.getImage().length); ImageView imageView = findViewById(R.id.result); imageView.setImageBitmap(bitmap); }