首页 > 解决方案 > how is the Y plane from YUV is saved in byte array

问题描述

I am using camera 2 API to take images

I need only the brightness of the images so I use the y buffer only as below

      ByteBuffer buffer = image.getPlanes()[0].getBuffer();

                byte[] bytes = new byte[buffer.capacity()];

                buffer.get(bytes);

as far as i know the y plane has all the image pixels and each value of pixel brightness is stored in the byte array value, whats the sequnce they are stored in ? for example is image is like this :

xxxxx
yyyyy
zzzzz

then the bytes array would be like [xxxxyyyyyzzzzz] or [xyzxyzxyzxyz] ?

I tried both sequence but I keep getting wrong results also when I try different phones I get different results ? while the resolution is fixed the image format is YUV_420 the images that I use are only black or white !

标签: javaandroidyuv

解决方案


推荐阅读