Search code examples
androidandroid-cameraglsurfaceview

How to get YUV from Android GLSurfaceView?


Is there any way to get YUV buffer from Android Camera with GLSurfaceView ? (Not from onPreviewFrame)


Solution

  • You get a YUV buffer from the Android Camera by using the Android Camera API. There's no reason to get OpenGL ES involved if you just want a single frame. Use ImageReader to avoid data copies.

    OpenGL ES works with RGB, not YUV, so anything rendered by GLES has been color-space converted. You can do the conversion back to YUV in a fragment shader if you like.

    In any event, the SurfaceView classes are not intended as intermediates in a processing pipeline; they are display endpoints. You can't get anything from them. See the arch doc for details.