Android的摄像机2基础API [英] Android Camera2 Basics API

查看:485
本文介绍了Android的摄像机2基础API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了code关于Android的API摄像机2从这里:
https://github.com/googlesamples/android-Camera2Basic

I am reading the code about Android Camera2 APIs from here: https://github.com/googlesamples/android-Camera2Basic

而正是在这混乱的线路:
<一href=\"https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java#L570-L574\" rel=\"nofollow\">https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java#L570-L574

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

这在previewRequest建设者只添加的表面,这是显示,作为目标TextureView。但是,以下行实际上作为目标添加这两个。据我所知,这应该不火preVIEW在OnImageAvailableLisenter,不是吗?那么,为什么这个在此处添加的ImageReader表面?

that the previewRequest builder only add surface, which is the TextureView to show, as target. But the following line actually add both as the targets. As I understand, this should not fire the "OnImageAvailable" Lisenter during preview, no? So why this add the imagereader's surface here?

我试图删除这个的ImageReader的表面在这里却得到了错误,当我真的想捕捉的图像.....

I tried to removed this imagereader's surface here but got error when I really want to capture an image.....

SOOO混乱!

推荐答案

您需要声明的所有输出表面 S中的图像数据可以在创建的时候被送到一个 CameraCaptureSession 。这仅仅是个框架的设计方式。

You need to declare all output Surfaces that image data might be sent to at the time you create a CameraCaptureSession. This is just the way the framework is designed.

当你创建一个 CaptureRequest ,添加一个(列表)目标输出表面(S)。这是从捕获的帧的图像数据将去 - 它可能是与 TextureView 显示相关的表面 ,或与的ImageReader 用于保存,或与分配处理等(A 表面真的只是可以通过相机拍摄的数据输出的缓冲器。对象的该缓冲区关联的类型决定了如何与数据访问/工作)。

Whenever you create a CaptureRequest, you add a (list of) target output 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.)

您不必从每帧的数据发送到所有已注册的表面 S,但它必须被发送给他们的一个子集。您不能添加表面作为目标为 CaptureRequest 如果它不与<$ C注册$ C> CameraCaptureSession 当它被创建。嗯,你可以,但它传递给会话会导致系统崩溃,所以不要。

You don't have to send the data from each frame to all registered Surfaces, but it has to be sent to a subset of them. You can't add a Surface as a target to a CaptureRequest if it wasn't registered with the CameraCaptureSession when it was created. Well, you can, but passing it to the session will cause a crash, so don't.

这篇关于Android的摄像机2基础API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆