I need to convert the frames to bitmap for processing, but I'm getting null from BitmapFactory.decodeByteArray(frame.getData(), 0, frame.getData().length).
Do I have to set offset to make this working? Or what is the correct way of doing this?
I need to convert the frames to bitmap for processing, but I'm getting null from BitmapFactory.decodeByteArray(frame.getData(), 0, frame.getData().length).
Do I have to set offset to make this working? Or what is the correct way of doing this?
You need to do something like this
ByteArrayOutputStream out = new ByteArrayOutputStream();
YuvImage yuvImage = new YuvImage(frame.getData(), ImageFormat.NV21, frame.getSize().getWidth(), frame.getSize().getHeight(), null);
yuvImage.compressToJpeg(new Rect(0, 0, frame.getSize().getWidth(), frame.getSize().getHeight()), 90, out);
byte[] imageBytes = out.toByteArray();
Bitmap image = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
@hitec16 yes,you are right.
Most helpful comment
You need to do something like this