How to remove lag in camera preview in Flutter when using startImageStream?

Viewed 1572

I am creating a Flutter application wherein I use Flutter's camera: 0.5.8+2 plugin.
In the application, I have a CameraPreview widget in the build function and use the startImageStream((CameraImage img){}) to set up an image stream after initializing the controller, to use the stream of images for further processing.

The issue that I am facing is that the CameraPreview lags a lot when I use startImageStream function and although the fps at which I receive the images are high (which is a requirement of the application), the lag is something I want to remove.

I have tried other workarounds like controller.takePicture(path) which helps to remove the lag but it drops the fps of images to around 6 (the requirement of the application is > 10 fps) on the emulator, and this is even lower on a real phone.

Can anyone recommend a workaround for this problem / alternate methods wherein the lag in the CameraPreview is removed as well as the fps of streaming the images is high (> 10 fps)?

1 Answers

try to change ResolutionPreset. in my case, I set ResolutionPreset.medium then it works fine.

Related