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

Camera view is broken in the release mode for both Android and iOS #515

Open
xajik opened this issue Sep 17, 2024 · 0 comments
Open

Camera view is broken in the release mode for both Android and iOS #515

xajik opened this issue Sep 17, 2024 · 0 comments

Comments

@xajik
Copy link

xajik commented Sep 17, 2024

Steps to Reproduce

Debug build:
flutter_02

Release build:

flutter_01

Expected results

Camera view doesn't render properly in the release mode.

Actual results

What you see

About your device

Apple, iPhone 15, 11;
Android Pixel 6P

Your flutter version

Run this in your command line

Flutter 3.24.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5874a72aa4 (4 weeks ago) • 2024-08-20 16:46:00 -0500
Engine • revision c9b9d5780d
Tools • Dart 3.5.1 • DevTools 2.37.2

camerawesome: ^2.1.0
google_mlkit_face_detection: ^0.11.0


final options = FaceDetectorOptions(
    enableContours: true,
    enableClassification: true,
    enableLandmarks: true,
  );
  late final faceDetector = FaceDetector(options: options);

`
Widget _awsomeCamera() {
    return CameraAwesomeBuilder.awesome(
      previewFit: CameraPreviewFit.fitHeight,
      saveConfig: SaveConfig.photo(
        exifPreferences: ExifPreferences(saveGPSLocation: false),
      ),
      imageAnalysisConfig: AnalysisConfig(
        androidOptions: const AndroidAnalysisOptions.nv21(
          width: 250,
        ),
        maxFramesPerSecond: 5, // depending on your phone performances
      ),
      onImageForAnalysis: (image) => _analyzeImage(image),
      sensorConfig: SensorConfig.single(
        aspectRatio: CameraAspectRatios.ratio_4_3,
        flashMode: FlashMode.auto,
        sensor: Sensor.position(SensorPosition.front),
        zoom: 0.0,
      ),
      onMediaTap: (mediaCapture) {
        if (mediaCapture.captureRequest.path != null) {
          _takePicture(mediaCapture.captureRequest.path!);
        }
      },
      topActionsBuilder: (state) {
        return AwesomeBottomActions(
          state: state,
          left: AwesomeFlashButton(state: state),
          right: Expanded(child: Container()),
          captureButton: Expanded(child: Container()),
        );
      },
      middleContentBuilder: (state) {
        return Column(
          children: [
            const Spacer(),
            StreamBuilder(
                stream: _faceDetectedController.stream,
                builder: (context, snapshot) {
                  bool faceDetected = snapshot.data ?? false;
                  return Container(
                    // Retrieve your AwesomeTheme's background color
                    color: AwesomeThemeProvider.of(context)
                        .theme
                        .bottomActionsBackgroundColor,
                    child: Align(
                      alignment: Alignment.bottomCenter,
                      child: Padding(
                        padding: const EdgeInsets.only(bottom: 10, top: 10),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Icon(
                              Icons.circle,
                              color: faceDetected ? Colors.green : Colors.red,
                              size: 20,
                            ),
                            const SizedBox(width: 10),
                            Text(
                              faceDetected
                                  ? "Face detected"
                                  : "No face detected",
                              style: const TextStyle(
                                color: Colors.white,
                                fontWeight: FontWeight.bold,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  );
                }),
          ],
        );
      },
    );
  }

Future _analyzeImage(AnalysisImage image) async {
    final inputImage = image.toInputImage();
    try {
      faceDetector.processImage(inputImage).then((faces) {
        if (faces.isNotEmpty) {
          _faceDetectedController.add(true);
        } else {
          _faceDetectedController.add(false);
        }
      });
    } catch (error) {
      debugPrint("...sending image resulted error $error");
    }
  }
`

@xajik xajik changed the title Camera view is broken in the release mod for both Android and iOS Camera view is broken in the release mode for both Android and iOS Sep 17, 2024
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