Search code examples
androidandroid-camerax

Getting byte[] or ByteBuffer from CameraX ImageAnalysis


Is there a way to get a byte[] or ByteBuffer from the CameraX ImageAnalysis use case? Any insight is appreciated.


Solution

  • From CameraX test app:

    byte[] bytes = new byte[image.getPlanes()[0].getBuffer().remaining()];
    image.getPlanes()[0].getBuffer().get(bytes);