使用Android Camera2 API快速捕获闪光/不闪光图像 [英] Capture flash/no-flash images quickly using Android Camera2 API
问题描述
我正在编写一个Android应用程序,以在用户按下捕获"按钮时快速捕获闪光/不闪光图像对.在编写我的应用程序时,我提到了Camera2Basic应用程序
I am writing an android application to capture flash/no-flash image pair quickly when a user presses capture button. For writing my application I referred to Camera2Basic app here.
我从Android文档中发现,要触发闪光灯,预览请求构建器应将 AE_MODE 设置为 AE_MODE_ON_ALWAYS_FLASH .
From Android documentation, I found that for flash to fire, the preview request builder should have AE_MODE set to AE_MODE_ON_ALWAYS_FLASH.
我正在使用三个请求生成器:预览,无闪存和闪存 两者之间的区别是:
I am using three request builders: preview, noflash and flash The difference between three is:
-
预览:AE_MODE设置为AE_MODE_ON_ALWAYS_FLASH,AF_MODE设置为CONTROL_AF_MODE_CONTINUOUS_PICTURE
preview: AE_MODE set to AE_MODE_ON_ALWAYS_FLASH and AF_MODE set to CONTROL_AF_MODE_CONTINUOUS_PICTURE
无闪存:AE_MODE设置为AE_MODE_ON
noflash: AE_MODE set to AE_MODE_ON
闪光灯:AE_MODE设置为AE_MODE_ONALWAYS_FLASH
flash: AE_MODE set to AE_MODE_ONALWAYS_FLASH
我使用的是 Nexus 5 设备,我发现,要仅捕获Flash图像,必须具有如上所述的预览生成器和Flash Builder,并使用上述提交静态捕获请求Flash 构建器.使用此顺序,我 总是 在Nexus 5中获得正确的闪光图像.预闪是自动 总是 处理.
I am using Nexus 5 device and I found that for capturing just a flash image, one must have preview builder and flash builder as described above, and submit a still capture request using above flash builder. Using this sequence, I always get a proper flash image in Nexus 5. The pre-flash is always automatically handled.
谈到原始问题,捕获一对Flash/No-Flash图像,我的步骤序列如下:
Coming to original question, capturing a pair of flash/no-flash images, my sequence of steps is as follows:
-
在拍照中,我使用预览构建器开始自动对焦触发.
In take picture, I start auto-focus trigger using preview builder.
自动对焦完成后,我使用 noflash 和 flash 构建器( 第一个noflash)来回提交两个静止捕捉请求,然后闪烁 )
When auto-focus is complete, I submit two still capture requests back to back using noflash and flash builders (first noflash, then flash)
但是,我得到的 第一张 图像是 flash图像 和 第二 是 无闪存图片 .我不理解这种输出反转.
However, the first image I get is a flash image and second is a no-flash image. I don't understand this reversal in output.
- JPEG大小写:第一张图片是 始终 张 正确的闪光图片 ,第二图像是 总是 张正确的无闪存图像 ,如下所示:
- JPEG case: First image is always a proper flash image, second image is always a proper no-flash image as shown below:
与使用 noflash 构建器提交的请求相对应的Flash图片:
Flash image corresponding to request submitted using noflash builder:
与使用 flash 构建器提交的请求相对应的不包含Flash的图片:
No-flash image corresponding to request submitted using flash builder:
- YUV_420_888情况:与JPEG中的情况相同,但是 noflash图像永远不合适 .人们可能会注意到右侧的 白条 以及不正确的颜色,这也很嘈杂 !
- YUV_420_888 case: Sames as in JPEG, however, noflash image is never proper. One can notice a white strip on right side as well as improper colors, also it is very noisy!
与使用 noflash 构建器提交的请求相对应的Flash图片:
Flash image corresponding to request submitted using noflash builder:
不正确的不闪动 图片与使用 flash 构建器提交的请求相对应:
Improper no-flash image corresponding to request submitted using flash builder:
偏离路线,因为以YUV_420_888格式背对背捕获了两个图像,所以我在两者之间添加了一个预览请求,以防止溢出.
Off-course, since in YUV_420_888 format two images are captured back to back, I add a preview request in between to prevent spill over.
我的问题是:
-
为什么输出图像的顺序颠倒了?
Why the order of output images is reversed?
为什么YUV_420_888格式的无闪光图像不合适?
Why no-flash image in YUV_420_888 format is not proper?
请帮助.
推荐答案
要确认几件事:
- 确保仅将单个请求的触发器设置为开始",而不是连续设置
- 如果AE_MODE是AE控制闪光的一种,则将忽略FLASH_MODE;否则,将忽略FLASH_MODE.最好不要以防万一.
- 确保对最终捕获请求使用STILL_CAPTURE请求模板;否则,主闪光灯不会闪光.
- 您应该能够在快闪请求之后立即提交第二个不快闪STILL_CAPTURE请求(为安全起见,请留下一个缓冲区请求,因为由于卷帘快门,主快闪可能会在之前和之后的一帧内部分可见闪光灯捕获后);只需提交一个预览请求,然后提交一个带有AE_MODE_ON的STILL_CAPTURE请求.
- 为了获得最大速度,请不要捕获JPEG图像;额外的编码时间会导致图像之间的延迟.使用YUV_420_888并自己创建JPEG.
这篇关于使用Android Camera2 API快速捕获闪光/不闪光图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!