Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
19 changes: 14 additions & 5 deletions lib/components/ocr_camera.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -31,10 +32,13 @@ class _OcrCameraState extends State<OcrCamera> {
@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
Expand All @@ -53,6 +57,8 @@ class _OcrCameraState extends State<OcrCamera> {

Future _startLiveFeed() async {
final camera = cameras[_cameraIndex];
// inspect the camera
print('Camera: $camera');
_controller = CameraController(
camera,
ResolutionPreset.low,
Expand All @@ -61,7 +67,10 @@ class _OcrCameraState extends State<OcrCamera> {
_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(() {});
Expand All @@ -86,8 +95,8 @@ class _OcrCameraState extends State<OcrCamera> {
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;
Expand Down