Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageReader makes Camera lag

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

like image 367
Araw Avatar asked Mar 13 '23 17:03

Araw


1 Answers

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.

like image 178
Araw Avatar answered Mar 24 '23 10:03

Araw