startLiveFeed method

Future<void> startLiveFeed()

Begins camera livestream.

Implementation

Future<void> startLiveFeed() async {
  final camera = cameras[_cameraIndex ?? 0];
  cameraController = CameraController(
    camera,
    ResolutionPreset.high,
    enableAudio: false,
    imageFormatGroup: Platform.isAndroid
        ? ImageFormatGroup.nv21
        : ImageFormatGroup.bgra8888,
  );

  await cameraController?.initialize();

  if (!mounted) return;

  cameraController?.getMinZoomLevel().then((value) {
    zoomLevel = value;
    minZoomLevel = value;
  });

  cameraController
      ?.setZoomLevel(zoomLevel > minZoomLevel ? zoomLevel : minZoomLevel);

  if (Platform.isIOS) {
    cameraController?.lockCaptureOrientation(DeviceOrientation.portraitUp);
  }

  cameraController?.startImageStream(_processCameraImage);
  setState(() {});
}