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

How to not take picture pressing capture button? #524

Open
kawi15 opened this issue Oct 18, 2024 · 0 comments
Open

How to not take picture pressing capture button? #524

kawi15 opened this issue Oct 18, 2024 · 0 comments

Comments

@kawi15
Copy link

kawi15 commented Oct 18, 2024

Hi, I am mixing barcode scanning with taking pictures and I want to take picture only when it's QR Code visible on camera.

CameraAwesomeBuilder.awesome(
        saveConfig: SaveConfig.photo(),
        sensorConfig: SensorConfig.single(
          aspectRatio: CameraAspectRatios.ratio_16_9,
        ),
        availableFilters: [],
        onImageForAnalysis: (image) async {
          final inputImage = image.toInputImage();
          try {
            recognizedBarcodes = await _barcodeScanner.processImage(inputImage);
            print(recognizedBarcodes.length);
            for (Barcode barcode in recognizedBarcodes) {
              debugPrint("Barcode: [${barcode.format}]: ${barcode.rawValue}");
            }
          } catch (error) {
            debugPrint("...sending image resulted error $error");
          }
        },
        bottomActionsBuilder: (state) => AwesomeBottomActions(
          state: state,
          right: Container(),
          left: Container(),
          captureButton: AwesomeCaptureButton(
            state: state,
          ),
        ),
        onMediaCaptureEvent: (event) async {
          print(recognizedBarcodes.length);
          if (recognizedBarcodes.length == 1) {
            switch ((event.status, event.isPicture, event.isVideo)) {
              case (MediaCaptureStatus.capturing, true, false):
                debugPrint('Capturing picture...');
              case (MediaCaptureStatus.success, true, false):
                event.captureRequest.when(
                  single: (single) {
                    debugPrint('Picture saved: ${single.file?.path}');
                    Navigator.of(context, rootNavigator: true).push(
                      MaterialPageRoute(
                        builder: (context) => DisplayPictureScreen(
                          // Pass the automatically generated path to
                          // the DisplayPictureScreen widget.
                          imagePath: single.file!.path,
                        ),
                      ),
                    );
                  },
                );
              case (MediaCaptureStatus.failure, true, false):
                debugPrint('Failed to capture picture: ${event.exception}');
              default:
                debugPrint('Unknown event: $event');
            }
          } else {
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('No Qr Code in picture')));
          }
        },
      )

I tried something like this but it is saving picture on phone. I want to show snackbar, if there is no QR code without saving picture, and save picture when QR Code is on picture.
Is this possible somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant