简体   繁体   English

Android Camera2 Basics API

[英]Android Camera2 Basics API

I am reading the code about Android Camera2 APIs from here: https://github.com/googlesamples/android-Camera2Basic 我正在从这里阅读有关Android Camera2 API的代码: https//github.com/googlesamples/android-Camera2Basic

And it is confusing in this lines: https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java#L570-L574 它在这方面令人困惑: https//github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java#L570-L574

that the previewRequest builder only add surface, which is the TextureView to show, as target. previewRequest构建器仅将表面(即要显示的TextureView)添加为目标。 But the following line actually add both as the targets. 但是以下行实际上将两者都添加为目标。 As I understand, this should not fire the "OnImageAvailable" Lisenter during preview, no? 据我了解,这不应该在预览期间触发“OnImageAvailable”Lisenter,不是吗? So why this add the imagereader's surface here? 那么为什么在这里添加图像阅读器的表面呢?

I tried to removed this imagereader's surface here but got error when I really want to capture an image..... 我试图在这里删除这个图像阅读器的表面但是当我真的想拍摄图像时出错了.....

SOOO CONFUSING!!! SOOO ConfUSING !!!

You need to declare all output Surface s that image data might be sent to at the time you create a CameraCaptureSession . 您需要声明在创建CameraCaptureSession时可能会将图像数据发送到的所有输出Surface This is just the way the framework is designed. 这就是框架的设计方式。

Whenever you create a CaptureRequest , you add a (list of) target output Surface (s). 每当您创建CaptureRequest ,都会添加一个(列表)目标输出Surface (s)。 This is where the image data from the captured frame will go- it may be a Surface associated with a TextureView for displaying, or with an ImageReader for saving, or with an Allocation for processing, etc. (A Surface is really just a buffer which can take the data output by the camera. The type of object that buffer is associated with determines how you can access/work with the data.) 这是来自捕获帧的图像数据将来的地方 - 它可能是与用于显示的TextureView关联的Surface ,或者用于保存的ImageReader ,或者用于处理的Allocation等。( Surface实际上只是一个缓冲区,可以获取摄像机输出的数据。缓冲区关联的对象类型决定了如何访问/使用数据。)

You don't have to send the data from each frame to all registered Surface s, but it has to be sent to a subset of them. 您不必将每个帧的数据发送到所有已注册的Surface ,但必须将其发送到它们的子集。 You can't add a Surface as a target to a CaptureRequest if it wasn't registered with the CameraCaptureSession when it was created. 您不能添加一个Surface为目标的CaptureRequest如果它与所登记的CameraCaptureSession创建时。 Well, you can, but passing it to the session will cause a crash, so don't. 嗯,你可以,但将它传递给会话将导致崩溃,所以不要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM