Search code examples
androidimage-processingandroid-camerazxingyuv

Zxing camera and preview frame format (YUV, RGB...)


I'm using the Zxing API to decode some QR Code images. I need to convert the YUV format to -> RGB format to be used in an other application.

I know the camera buffer returns a byte[] under the NV21 format (YUV), but which one is it ?

  • Do I get a YUV420 format ? Or a YUV422 format ?
  • If so, how do I convert this format to an RGB888 format ? Do I need to convert the YUV to YUV888 before that ?

Thanks for your time,

EDIT: One thing I do not undestand is the length of the byte[] from the YUV420 preview frame. For a 1280*720 resolution , I get 1,382,400.00 bytes. How is it calculated ?


Solution

  • NV21 is basically YUV420. You can convert directly: http://en.wikipedia.org/wiki/YUV#Y.27UV420p_.28NV21.29_to_ARGB8888_conversion