Why i get CAMERA_ERROR (3) when using flutter camera

Viewed 3105

the following error occurs when using flutter camera plugin, I've added the permission to the manifest file, and still not working.

Launching lib\main.dart on sdk gphone x86 in debug mode...
Parameter format not correct -
āœ“ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Connecting to VM Service at ws://127.0.0.1:64116/dm5AqTZrDK0=/ws
I/CameraManagerGlobal(20232): Connecting to camera service
W/Gralloc4(20232): allocator 3.x is not supported
E/CameraCaptureSession(20232): Session 0: Exception while stopping repeating:
E/CameraCaptureSession(20232): android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): The camera device has encountered a serious error
E/CameraCaptureSession(20232):  at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:2231)
E/CameraCaptureSession(20232):  at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1241)
E/CameraCaptureSession(20232):  at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:578)
E/CameraCaptureSession(20232):  at io.flutter.plugins.camera.Camera.closeCaptureSession(Camera.java:480)
E/CameraCaptureSession(20232):  at io.flutter.plugins.camera.Camera.close(Camera.java:486)
E/CameraCaptureSession(20232):  at io.flutter.plugins.camera.Camera$2.onError(Camera.java:187)
E/CameraCaptureSession(20232):  at android.hardware.camera2.impl.CameraDeviceImpl.notifyError(CameraDeviceImpl.java:1629)
E/CameraCaptureSession(20232):  at android.hardware.camera2.impl.CameraDeviceImpl.lambda$oDs27OTfKFfK18rUW2nQxxkPdV0(Unknown Source:0)
E/CameraCaptureSession(20232):  at android.hardware.camera2.impl.-$$Lambda$CameraDeviceImpl$oDs27OTfKFfK18rUW2nQxxkPdV0.accept(Unknown Source:8)
E/CameraCaptureSession(20232):  at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:278)
E/CameraCaptureSession(20232):  at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:201)
E/CameraCaptureSession(20232):  at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:97)
E/CameraCaptureSession(20232):  at android.os.Handler.handleCallback(Handler.java:938)
E/CameraCaptureSession(20232):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/CameraCaptureSession(20232):  at android.os.Looper.loop(Looper.java:223)
E/CameraCaptureSession(20232):  at android.app.ActivityThread.main(ActivityThread.java:7656)
E/CameraCaptureSession(20232):  at java.lang.reflect.Method.invoke(Native Method)
E/CameraCaptureSession(20232):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/CameraCaptureSession(20232):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/flutter (20232): CameraException(Previous capture has not returned yet., takePicture was called before the previous capture returned.)
2 Answers

You can also now use this plugin : CamerAwesome

Official plugin has been quite abandonned. This plugin includes flash, zoom, auto focus... and no initialisation required.

I also received this error when using Flutter camera plugin example when I changed it from CameraController.startVideoRecording() to CameraController.startImageStream(Function<CameraImage>).

To resolve this issue I commented/removed imageFormatGroup: ImageFormatGroup.jpeg at CameraController instantiation:

controller = CameraController(
  cameraDescription,
  ResolutionPreset.medium,
  enableAudio: enableAudio,
  //imageFormatGroup: ImageFormatGroup.jpeg, //remove or comment this line
);

This may happen because CameraImage received at startImageStream uses YUV image encoding.

Related