Android Camera2 RAW流 [英] Android Camera2 RAW streaming

查看:175
本文介绍了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 ?

在此先感谢

纪尧姆

编辑:

这是我到目前为止所做的:

Here is what I have done so far:

  • 创建呈现到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

最小帧持续时间为33ms

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用作捕获目标.然后,该格式也会在可用输出中列出格式.您可以在

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缓冲区的速度,请查看 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格式,并且支持

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的停顿持续时间为100ms,但最小帧持续时间为30ms,则可以通过具有(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天全站免登陆