Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Camera ignore turn flash off exception #2228

Merged
merged 3 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 6 additions & 1 deletion packages/smooth_app/lib/pages/scan/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ class SmoothCameraController extends CameraController {
@override
Future<void> pausePreview() async {
if (_isInitialized) {
await _pauseFlash();
try {
await _pauseFlash();
} catch (exception) {
// Camera already disposed
}

await super.pausePreview();
_isPaused = true;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/smooth_app/lib/pages/scan/mkit_scan_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,17 @@ class _MLKitScanDecoderIsolate {

final CameraImage image = CameraImage.fromPlatformData(message);
final InputImage cropImage = _cropImage(image);
final double imageHeight =
cropImage.inputImageData?.size.longestSide ?? double.infinity;

final List<Barcode> barcodes =
await _barcodeScanner.processImage(cropImage);

port.send(
barcodes
// Only accepts barcodes on half-top of the image
.where((Barcode barcode) =>
(barcode.boundingBox?.top ?? 0.0) <= imageHeight * 0.5)
Comment on lines +238 to +240
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel comfortable doing this already. I often times have to put the barcode in at least some parts behind the card/lower then the middel

.map((Barcode barcode) => _changeBarcodeType(barcode))
.where((String? barcode) => barcode?.isNotEmpty == true)
.cast<String>()
Expand Down