Convert ARFrame to bitmap Array


I want to convert the bytedata returned by the ARD Frame to Bitmap array so that i can feed it to other sources:
I tried this:

public ARCONTROLLER_ERROR_ENUM onFrameReceived(ARDeviceController deviceController, 
ARFrame frame) {
byte[] data = frame.getByteData();
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

     if(bitmap != null){
       // do something

But it doesn’t work, the decodeByteArray can’t decode the byte data return by the frame and it always return null.
So, any suggestions on how to convert the byte-data returned by the from to bitmap?


Scroll down about 8 posts in the (Latest) view :slight_smile:

How to get a Bitmap from an ARframe?


Hi synman,
Thank you for your reply, but what I’m trying to do is a little bit different, I don’t need to create a video component and git the bitmap from it, but I need to convert the ARFrame directly to bitmap so that I can use with my logic.
So is there any way to get the Bitmap form the ARFrame directly without rendering the frame or using costume component?


You will find in that thread I already addressed (high level) what I believe to be the state of the ARFrame packet data. It is an encoded H.264 stream and would have to first be converted using an encoder before you can make it a usable bitmap.

This is why the TextureView approach is nice on Android. Utilizing a background thread you can pull a bitmap of the already pushed view. This is actually more useful than trying to decode the data a second time because the Android Media Encoder is already doing it for you.


Thank your very much for you help!
do you have an piece of code that I can lock at?