的ImageReader使得相机滞后 [英] ImageReader makes Camera lag

查看:1179
本文介绍了的ImageReader使得相机滞后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面对,我正在使用的ImageReader除了拥有这是用来显示相机的输出SurfaceView一个问题。我已经加入了SurfaceView本身和这样的ImageReader表面(并且为了获得新的图像添加事件的ImageReader听众):

I'm facing a problem where I am using a ImageReader in addition to have a SurfaceView which is used to show the output of the camera. I have added the SurfaceView itself and the surface for the ImageReader like this (and added the ImageReader listeners in order to receive events on new images):

preview.addTarget(_surfaces.get(1)); //ImageReader surface
preview.addTarget(_surfaces.get(0)); //SurfaceView of the layout

不过,如果我删除的应用程序工作正常的ImageReader(没有从相机滞后)。但只要的ImageReader表面被添加摄像机I滞后了很多。任何人有任何想法,以使得相机运行更顺畅?的ImageReader是这样创建:

However, if I remove the ImageReader the application is working fine (no lagging from the camera). But as soon as the ImageReader surface is added the camera i lagging a lot. Anyone have any ideas in order to makes the camera run more smooth? The ImageReader is created like this:

reader = ImageReader.newInstance(640, 480, ImageFormat.JPEG, 1);

我想的滞后可能是由于该图像已经被渲染的两倍(?),无论在布局的SurfaceView和的ImageReader本身

I guess the lag could be due to that the image has to be rendered two times(?), both on the SurfaceView of the layout and the ImageReader itself

推荐答案

原来,问题的ImageReader的的imageformat。更改 ImageFormat.JPEG 来,例如 ImageFormat.YUV_420_888 固定的滞后问题。

Turns out that the problem is the ImageFormat of the ImageReader. Changing the ImageFormat.JPEG to for example ImageFormat.YUV_420_888 fixed the lagging problem.

这篇关于的ImageReader使得相机滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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