Reputation: 15
I have a camera preview working and I want to extract the Y value from specific coordinates of my camera preview to determine the luma.
However, I do not know how to create the 'byte[] yuv' parameter for when I pass in values. From the API docs ( http://developer.android.com/reference/android/graphics/YuvImage.html ) it tells me it is the yuv data. So how do I obtain this byte array from my camera preview to create my YuvImage?
Or am I tackling this problem completely wrong?
Thanks in advance.
Upvotes: 0
Views: 606
Reputation: 57173
Normally, the data byte[] that arrives from onPreviewFrame() has luma data packed in a width*height array.
To extract luma(x, y) you can use the following snippet:
void onPreviewFrame(byte[] data, android.hardware.Camera camera) {
byte result = data[x + y*width];
}
You don't need YuvImage for that.
Upvotes: 1