Android Camera2 RAW 流媒体 [英] Android Camera2 RAW streaming

查看:62
本文介绍了Android Camera2 RAW 流媒体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Android 很陌生,正在尝试:

I am very new to Android and trying to:

  • 从相机流式传输原始数据 (ImageFormat RAW_SENSOR)
  • 处理原始数据
  • 以交互方式显示处理结果

似乎原始数据捕获仅在静态捕获模式下可用.这是正确的吗?

It seems like raw data capture is only available in still capture mode. Is this correct ?

如果是这样,是否可以改为对 RAW 图像执行重复的 CaptureRequests ?使用 13MP 传感器可以获得什么样的性能?任何参考代码?

If so would it be possible to perform repeated CaptureRequests for RAW images instead ? What kind of performance can be expected using a 13MP sensor ? Any reference code ?

非常感谢,

纪尧姆

编辑:

这是我目前所做的:

  • 创建渲染到 SurfaceTexture 的预览捕获
  • 在 onSurfaceTextureUpdated() 中计算/更新帧率

  • Create preview capture that renders to SurfaceTexture
  • Frame rate is calculated / updated in onSurfaceTextureUpdated()

问题:

  • 可以在 onSurfaceTextureUpdated() 中计算帧率吗?
  • 我尝试为 texture.setDefaultBufferSize() 设置不同的尺寸,但它对帧率没有影响.这正常吗?

将原始 ImageReader 的表面添加到 cameraDevice.createCaptureSession()

Add raw ImageReader's surface to cameraDevice.createCaptureSession()

原始分辨率为 4208x3120

The raw resolution is 4208x3120

最小帧持续时间为 33 毫秒

Minimum frame duration is 33ms

停顿时间为 200 毫秒

Stall duration is 200ms

我仅获得预览的帧速率约为 25-30 fps.

The framerate I get for only preview is about 25-30 fps.

我在预览和启用每帧原始捕获时获得的帧速率约为 15 fps.

The framerate I get when I preview and enable raw capture every frame is about 15 fps.

我收到一些ImageReader_JNI:无法获取缓冲区项,很可能客户端试图获取超过 maxImages 个缓冲区"的消息,即使我每 100 帧进行原始捕获也是如此.

I get some "ImageReader_JNI: Unable to acquire a buffer item, very likely client tried to acquire more than maxImages buffers" message, even if I do raw capture every 100 frames.

我很想得到一些反馈:

  • 这是否是做我想做的事情的正确方式.
  • 如果效率更高,我如何切换到连拍捕捉而不是每 N 帧静止图像.
  • 这些初始数字是否有意义.

非常感谢,

纪尧姆

推荐答案

是否完全支持 RAW 捕获以及它可以完成的速率都取决于设备.

Whether RAW capture is supported at all, and what rate it can be done are both device-dependent.

如果设备支持 RAW 功能,那么您可以使用具有 RAW_SENSOR 格式的 ImageReader 作为捕获目标.该格式也将列在 可用输出中格式.您可以在 createCaptureSession 在 RAW 能力表中.

If the device supports the RAW capability, then you can use an ImageReader with the RAW_SENSOR format as a capture target. The format will then also be listed in the available output formats. You can see what kinds of stream combinations are supported in the documentation for createCaptureSession in the RAW-capability table.

要确定捕获 RAW 缓冲区的速度,请查看 getOutputMinFrameDuration,它告诉您在包含给定格式和分辨率组合的输出时的最大帧速率.此外,getOutputStallDuration 方法将告诉您在针对 RAW 输出的两个连续请求之间是否需要额外延迟以避免停止预览.在一般情况下,不需要支持任何特定的 RAW 缓冲区输出速率.

To determine how fast you can capture RAW buffers, take a look at the output of getOutputMinFrameDuration, which tells you what the maximum frame rate when including an output of given format and resolution combination. In addition, the getOutputStallDuration method will tell you if you need extra delay between two consecutive requests targeting the RAW output to avoid stalling preview. There's no requirement to support any particular output rate of RAW buffers in the general case.

但是,如果设备支持更高效的 RAW10 或 RAW12 格式,并且它支持 BURST_CAPTURE 功能,则保证支持以至少 20fps 的速率捕获这些格式.

However, if the device supports either of the more-efficient RAW10 or RAW12 formats, and it supports the BURST_CAPTURE capability, then it's guaranteed to support capturing those formats with at least 20fps rates.

您可以查看 Google camera2raw 示例以获取基本的静态照片.但是,您当然可以连续捕获 RAW 缓冲区,而不是与 JPEG 缓冲区一起捕获.但在这种情况下,您的帧速率可能会非常低,为了保持预览帧速率,您可能希望每 N 个预览帧中只发出一个 RAW 捕获.

You can look at the Google camera2raw sample for basic still capture. However, you can certainly capture RAW buffers continually instead of alongside JPEG buffers. But your frame rate may be very low in that case, and to preserve your preview frame rate, you may wish to only issue a RAW capture one out of every N preview frames.

例如,如果 RAW_SENSOR 的停顿持续时间为 100 毫秒,但最小帧持续时间为 30 毫秒,您可以通过使用 (R+P),P,P,P,(R+P),P,P,P... 这样每个原始捕获的开始之间至少有 100 毫秒.这将为您提供 ~8fps RAW 和 30fps 预览.

For example, if the stall duration for RAW_SENSOR is 100ms, but the minimum frame duration is 30ms, you can run continuous preview by having a capture request pattern of (R+P),P,P,P,(R+P),P,P,P... so that there's at least 100 ms between the starts of each raw capture. That'll get you ~8fps RAW and 30fps preview.

这篇关于Android Camera2 RAW 流媒体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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