startLiveFeed method

Future startLiveFeed()

Implementation

Future startLiveFeed() async {
  _cameras = await availableCameras();
  if (_cameras.isEmpty) {
    return;
  }
  _controller = CameraController(
    _cameras[0],
    ResolutionPreset.max,
  );
  final camera = _cameras[0];
  _controller = CameraController(
    camera,
    ResolutionPreset.high,
    enableAudio: false,
  );
  _controller?.initialize().then((_) {
    if (!mounted) {
      return;
    }
    _controller?.getMinZoomLevel().then((value) {
      zoomLevel = value;
      minZoomLevel = value;
    });
    _controller?.getMaxZoomLevel().then((value) {
      maxZoomLevel = value;
    });
    _controller?.startImageStream(_processCameraImage);
    setState(() {});
  }).catchError((Object e) {
    if (e is CameraException) {
      switch (e.code) {
        case 'CameraAccessDenied':
          log('User denied camera access.');
          break;
        default:
          log('Handle other errors.');
          break;
      }
    }
  });
}