Manipulate BufferQueue on the native side

96 Views Asked by At

I want to write an app that has to manipulate some buffer produces by the Camera (Camera2 api). The code that manipulates the buffer is written in native c (Let's say color conversion).

Basically, this means that I have a java Camera2 API, which needs a Surface to write to. How do I convert this Surface into a native buffer that the native code can manipulate? Any samples that I can look at?

1

There are 1 best solutions below

0
On

You can use the camera2 NDK, if you're targeting recent enough Android releases. That accepts ANativeWindow objects as outputs.

Otherwise, you can pass the ByteBuffers from an ImageReader via JNI into native code, and access the data with no extra copies.