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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top