It is 2017 and I am finally starting switching from Camera1 to Camera2. In Camera1 I was greatly relying on setPreviewCallbackWithBuffer()
to perform a real time frame processing, however in Camera2 this works much much slower to the point where it becomes almost unusable.
To compare, on Moto G3 Camera1 can easily produce 30-40 FPS while on Camera2 I couldn't get more than 10-15 FPS.
Here is how I am creating ImageReader
imageReader = ImageReader
.newInstance(
previewSize.width, // size is around 1280x720
previewSize.height,
ImageFormat.YUV_420_888, // note, it is not JPEG
2 // max number of images, does not really affect performance
);
imageReader.setOnImageAvailableListener(
callback,
CameraThread.getInstance().createHandler()
);
Callback itself does the minimum possible job:
Image image = reader.acquireNextImage();
image.close();
I already checked similar answers, such as this one. However their problem is that they're using JPEG
image format instead of YUV_420_888
.
How to achieve a performance similar to Camera1?