相机preVIEW图像数据处理与Android L和摄像机2 API [英] Camera preview image data processing with Android L and Camera2 API

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

问题描述

我工作的一个Android应用程序,从相机处理输入的图像并将其显示给用户。这是相当简单的,我注册了一个 previewCallback 设置previewCallbackWithBuffer 相机对象。 这是很容易,并与老相机API工程进展顺利

I'm working on an android app that is processing the input image from the camera and displays it to the user. This is fairly simple, I register a PreviewCallback on the camera object with the setPreviewCallbackWithBuffer. This is easy and works smoothly with the old camera API

public void onPreviewFrame(byte[] data, Camera cam) {
    // custom image data processing
}

我想端口我的应用程序,以利用新的摄像机2 API的,我不知道究竟是如何将我这样做。我跟着大号preVIEW样品中Camera2Video,允许录制视频。然而,在样品中没有直接的图像数据传输,所以我不知道在什么地方要我得到的图像的像素数据,以及如何处理它。

I'm trying to port my app to take advantage of the new Camera2 API and I'm not sure how exactly shall I do that. I followed the Camera2Video in L Preview samples that allows to record a video. However, there is no direct image data transfer in the sample, so I don't understand where exactly shall I get the image pixel data and how to process it.

可能有人帮助我,或建议的方式,如何能够得到的android→ previewCallback 的功能,不然怎么可能处理preVIEW显示到屏幕之前从相机数据? (有摄像头的对象上没有preVIEW回调)

Could anybody help me or suggest the way how one can get the the functionality of PreviewCallback in android L, or how it's possible to process preview data from the camera before displaying it to the screen? (there is no preview callback on the camera object)

感谢您!

推荐答案

由于摄像机2 API是从当前的摄像头API很大的不同,它可能会帮助办理相关文档。

Since the camera2 API is very different from the current camera API, it might help to go through the documentation.

一个很好的出发点是camera2basic例子。它演示了如何使用摄像机2 API和配置的ImageReader获得JPEG图像并注册ImageReader.OnImageAvailableListener接收这些图像

A good starting point is camera2basic example. It demonstrates how to use Camera2 API and configure ImageReader to get JPEG images and register ImageReader.OnImageAvailableListener to receive those images

要接受preVIEW框架,你需要在你的ImageReader的表面添加到setRepeatingRequest的CaptureRequest.Builder。

To receive preview frames, you need to add your ImageReader's surface to setRepeatingRequest's CaptureRequest.Builder.

此外,你应该设置的ImageReader的格式YUV_420_888,它会给你在30fps的800万像素(文档,保证在30帧800万像素的的Nexus 5)。

Also, you should set ImageReader's format to YUV_420_888, which will give you 30fps at 8MP (The documentation guarantees 30fps at 8MP for Nexus 5).

这篇关于相机preVIEW图像数据处理与Android L和摄像机2 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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