A
A
Andrew2013-01-22 14:35:22
Android
Andrew, 2013-01-22 14:35:22

How to modify byte[] data array received from onPreviewFrame?

The onPreviewFrame gets the byte[] data array in YUV format (NV21). I know how to translate this into an rgb array. But since I'm working directly with the brightness of the image, it's convenient for me to work with the Y component in the original array. There are many examples on the web on how to get RGB from NV21 and how to write RGB components to a YUV array. But in order to avoid these transformations, I would like to edit the Y component (brightness) and immediately write it back to the YUV array. If you do it on the forehead, you get a green screen. Maybe someone has done something similar and can tell me how to do it right. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Malinskiy, 2013-01-22
@Malinskiy

byte[] data that you get in preview is immutable globally. those. Of course, you can change it, but this will in no way affect the associated SurfaceHolder. If you want to change data, then you need to make an additional View and display it separately in your code, for example, by converting to Bitmap and then to ImageView, you already seem to have found examples of such operations.
onPreviewFrame is nothing more than Android's notification mechanism. All display happens outside of your code, you only specify where to write preview.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question