ImageReader makes Camera lag

此生再无相见时 提交于 2019-11-29 22:27:03

问题


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

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);

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


回答1:


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.



来源:https://stackoverflow.com/questions/34555545/imagereader-makes-camera-lag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!