diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index 29073fe..9562370 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -23,7 +23,7 @@ jobs: flutter-version: '3.22.2' - run: flutter pub get - run: flutter config --enable-web - - run: sudo apt-get -y install xvfb xorg gtk2-engines-pixbuf + # - run: sudo apt-get -y install xvfb xorg gtk2-engines-pixbuf - name: test env: TEST_INSTANCE_URL: ${{ secrets.TEST_INSTANCE_URL }} @@ -35,7 +35,9 @@ jobs: --dart-define=ELN_URL=$TEST_INSTANCE_URL \ --driver=test_driver/integration_test.dart \ --target=integration_test/app_test.dart \ - -d web-server --browser-name=chrome --web-browser-flag "--disable-web-security --headless" --headless + -d web-server --browser-name=chrome \ + --web-browser-flag "--disable-web-security --headless --use-fake-ui-for-media-stream --use-fake-device-for-media-stream" + --headless build: runs-on: ubuntu-latest diff --git a/lib/components/ocr_camera.dart b/lib/components/ocr_camera.dart index 3689d64..3a79673 100644 --- a/lib/components/ocr_camera.dart +++ b/lib/components/ocr_camera.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart' show kIsWeb; import 'package:camera/camera.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -31,10 +32,13 @@ class _OcrCameraState extends State { @override void initState() { super.initState(); - - _cameraIndex = + // initialize the cameraIndex unless it's a web platform + if (!kIsWeb) { + _cameraIndex = cameras.indexWhere((camera) => camera.lensDirection == widget.initialLensDirection); + } _startLiveFeed(); + } @override @@ -53,6 +57,8 @@ class _OcrCameraState extends State { Future _startLiveFeed() async { final camera = cameras[_cameraIndex]; + // inspect the camera + print('Camera: $camera'); _controller = CameraController( camera, ResolutionPreset.low, @@ -61,7 +67,10 @@ class _OcrCameraState extends State { _controller?.initialize().then((_) async { if (!mounted) return; - await _controller?.lockCaptureOrientation(DeviceOrientation.portraitUp); + // if web platform (kIsWeb) then do not set the orientation + if (!kIsWeb) { + await _controller?.lockCaptureOrientation(DeviceOrientation.portraitUp); + } _controller?.startImageStream(_processCameraImage); setState(() {}); @@ -86,8 +95,8 @@ class _OcrCameraState extends State { final Size imageSize = Size(image.width.toDouble(), image.height.toDouble()); final camera = cameras[_cameraIndex]; - final imageRotation = InputImageRotationValue.fromRawValue(camera.sensorOrientation) ?? - InputImageRotation.rotation0deg; + + final imageRotation = InputImageRotationValue.fromRawValue(camera.sensorOrientation) ?? InputImageRotation.rotation0deg; final inputImageFormat = InputImageFormatValue.fromRawValue(image.format.raw) ?? InputImageFormat.nv21;