4

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

fadden
  • 51,356
  • 5
  • 116
  • 166
Araw
  • 2,410
  • 3
  • 29
  • 57

1 Answers1

7

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.

Araw
  • 2,410
  • 3
  • 29
  • 57
  • 1
    Surprisingly that did not worked for me. On not-so-high-end devices even `YUV_420_888` introduces some noticeable lag which was not the case with Camera v1. – Dmitry Zaytsev Apr 28 '17 at 19:05