问题
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