I'm receiving YUV420
image data in byte[]
on every onDrawFrame()
. I need to find out the colors present in the image from the byte array given. How can I extract U and V value for each pixel and use them to determine if the specific color is present in that image (something like HSV
color range).
I've separated UV array from original image data like this:
byte[] data = image.getData();
int inputYLength = image.getWidth() * image.getHeight();
int inputUVLength = image.getWidth() * image.getHeight() / 2;
ByteBuffer uvBuffer = ByteBuffer.allocateDirect(inputUVLength);
uvBuffer.put(image.getData(), inputYLength, inputUVLength);
uvBuffer.position(0);
uvBuffer
holds byte values for U and V components. How to use this for color detection?