How do I get the raw Android camera buffer in C using JNI?

后端 未结 3 486
南旧
南旧 2020-12-04 16:10

I\'ve been searching Google and StackOverflow exhaustively and cannot find this. Maybe I\'m missing something obvious. Thanks!

(This is because the Java implementa

3条回答
  •  暖寄归人
    2020-12-04 16:27

    There is no public API to do what you want; the only official (that is, guaranteed to work) method is the Java-level preview callbacks set up through calling Camera.setPreviewCallback(). In Android > 3.0, you can also use Camera.setPreviewTexture() to route preview data to the GPU, and process it there using GLES (or read it back to the CPU). The GPU path is what the ICS AOSP camera application uses for its video effects.

    Presumably, OpenCV and others have looked through the Android framework native code, and have bypassed the Java Camera API, talking to the services below directly.

    This is fairly dangerous, because there is absolutely no guarantee that those interfaces won't change between Android versions, since they are not part of the public API. Using them may be fine now, and then when a user upgrades their device, your app will stop working.

提交回复
热议问题