Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
906 stars 199 forks source link

Preview off and zoomed in when taking photo #446

Open GoodVibesLab opened 4 months ago

GoodVibesLab commented 4 months ago

Hi everyone,

I'm trying to get a fullscreen preview and capture images from the plugin, but the files returned are zoomed and tranlated to the left. Here's whats the preview looks like:

1708113118749

And her's whats the result looks like:

bd7b1ba1-d324-4eaf-ab65-38a06eba79ec

Here's my implementation:

@override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(child: _cameraBody),
    );
  }

  Widget get _cameraBody => CameraAwesomeBuilder.awesome(
        onImageForAnalysis: (img) => _processImageBarcode(img),
        imageAnalysisConfig: AnalysisConfig(
          androidOptions: const AndroidAnalysisOptions.nv21(
            width: 512,
          ),
          maxFramesPerSecond: 4,
          autoStart: true,
        ),
        sensorConfig: SensorConfig.single(
          aspectRatio: CameraAspectRatios.ratio_16_9,
        ),
        previewFit: CameraPreviewFit.cover,
        saveConfig: SaveConfig.photo(),
        topActionsBuilder: (state) {
          return AwesomeTopActions(
            state: state,
            children: [],
          );
        },
        progressIndicator: CustomCircularProgressIndicator(),
        bottomActionsBuilder: (state) => Padding(
          padding: const EdgeInsets.only(bottom: 38.0),
          child: AwesomeBottomActions(
            padding: EdgeInsets.zero,
            state: state,
            captureButton: GestureDetector(
              onTap: true
                  ? () {
                      state.when(
                        onPhotoMode: (state) => state.takePhoto(
                          onPhoto: (photo) {
                            debugPrint('photo: $photo');
                            photo.when(
                              single: (captureRequest) {
                                XFile? file = captureRequest.file;
                                if (file != null) {
                                  navigateToPage(
                                      context, Routes.createGarageItem,
                                      settings: RouteSettings(arguments: file));
                                }
                              },
                            );
                          },
                        ),
                      );
                    }
                  : null,
              child: Container(
                decoration: BoxDecoration(
                  color:
                      _hasCar ? Palette.red.withOpacity(0.72) : Colors.white54,
                  borderRadius: BorderRadius.circular(50),
                  border: Border.all(
                    color: Colors.white70,
                    width: 4,
                  ),
                ),
                height: 72,
                width: 72,
                padding: const EdgeInsets.all(8),
              ),
            ),
            left: _backButton,
            right: AwesomeFlashButton(
              state: state,
            ),
          ),
        ),
        middleContentBuilder: (state) => Container(),
        theme: AwesomeTheme(
          bottomActionsBackgroundColor: Colors.transparent,
        ),
        previewDecoratorBuilder: (state, preview) {
          return TakePhotoUI();
        },
      );
  I tried with every configuration of sensors, preview fit possible, am I missing something ? Issue is the same on iOS and Android, multiple devices.
[CameraAw](camerawesome: ^2.0.0+1) Flutter 3.16.9 • channel stable • https://github.com/flutter/flutter.git Framework • revision 41456452f2 (3 weeks ago) • 2024-01-25 10:06:23 -0800 Engine • revision f40e976bed Tools • Dart 3.2.6 • DevTools 2.28.5
g-apparence commented 4 months ago

Hi, Yes I found this on Android only for the back camera. The surface that takes the image on this configuration is not right.

Juanchote commented 4 months ago

I am having the same issue, thought I misconfigured something but nope. Any solution?

g-apparence commented 4 months ago

@Juanchote I started to work on something. But I'm not sure if that fixes the issue on every phones.

GoodVibesLab commented 4 months ago

Just for the record I switched to the classic camera flutter package and managed to take fullscreen photos with minor distortion.

Juanchote commented 3 months ago

@Juanchote I started to work on something. But I'm not sure if that fixes the issue on every phones.

Thank you. I will QC it haha

Fintasys commented 3 months ago

Facing same issue in a production app (P8P). Any workaround or knows when this bug was introduced?

jt274 commented 3 months ago

@g-apparence Any update? This seems to happen on most Android cameras and makes it unusable.

g-apparence commented 3 months ago

Yes I had quite good results but I lack time to finish it.

I am now alone working on this and I also have a lot of work.

Fintasys commented 2 months ago

Same issue happened to me on iOS. So I migrated over to official camera plugin unfortunately.

jt274 commented 2 months ago

Same issue happened to me on iOS. So I migrated over to official camera plugin unfortunately.

I will probably unfortunately also need to do this. If there's only one person maintaining the package, it will be hard to keep up with bug fixes and features.

Woolloff commented 1 month ago

@g-apparence Also experiencing this issue. Please advise if you see this being fixed soon or if not, the best way I can contribute to help you fix it.