【问题标题】:Flutter Camera OverlayFlutter 相机叠加层
【发布时间】:2018-10-25 03:41:52
【问题描述】:

我一直在为即将到来的项目做一些研究,并希望在自定义形状/半透明 img 后面渲染相机视图,以在拍照时充当指南。

有谁知道解释如何做到这一点的颤振相机插件或教程?

【问题讨论】:

    标签: android-camera flutter ios-camera


    【解决方案1】:

    您可以使用 Flutter 团队的相机插件进行 Flutter。

    https://pub.dartlang.org/packages/camera

    然后将您的图像和相机视图放置在 Stack Widget 中,如下所示:

    return new Stack(
      alignment: FractionalOffset.center,
      children: <Widget>[
        new Positioned.fill(
          child: new AspectRatio(
              aspectRatio: controller.value.aspectRatio,
              child: new CameraPreview(controller)),
        ),
        new Positioned.fill(
          child: new Opacity(
            opacity: 0.3,
            child: new Image.network(
              'https://picsum.photos/3000/4000',
              fit: BoxFit.fill,
            ),
          ),
        ),
      ],
    );
    

    【讨论】:

    • 有什么办法可以用叠加层保存这个视频吗?
    • 我也想用叠加保存视频?任何建议..@JoseTapizquent
    【解决方案2】:

    请访问此repo。此示例使用相机插件。

    new AspectRatio(
      aspectRatio: controller.value.aspectRatio,
      child: Container(
        child: Stack(
          children: <Widget>[
            CameraPreview(controller),
            Align(
              alignment: Alignment.bottomCenter,
              child: Container(
                width: double.infinity,
                height: 120.0,
                padding: EdgeInsets.all(20.0),
                color: Color.fromRGBO(00, 00, 00, 0.7),
                child: Stack(
                  children: <Widget>[
                    Align(
                      alignment: Alignment.center,
                      child: Material(
                        color: Colors.transparent,
                        child: InkWell(
                          borderRadius: BorderRadius.all(Radius.circular(50.0)),
                          onTap: () {
                            _captureImage();
                          },
                          child: Container(
                            padding: EdgeInsets.all(4.0),
                            child: Image.asset(
                              'assets/images/ic_shutter_1.png',
                              width: 72.0,
                              height: 72.0,
                            ),
                          ),
                        ),
                      ),
                    ),
                    Align(
                      alignment: Alignment.centerRight,
                      child: Material(
                        color: Colors.transparent,
                        child: InkWell(
                          borderRadius: BorderRadius.all(Radius.circular(50.0)),
                          onTap: () {
                            if (!_toggleCamera) {
                              onCameraSelected(widget.cameras[1]);
                              setState(() {
                                _toggleCamera = true;
                              });
                            } else {
                              onCameraSelected(widget.cameras[0]);
                              setState(() {
                                _toggleCamera = false;
                              });
                            }
                          },
                          child: Container(
                            padding: EdgeInsets.all(4.0),
                            child: Image.asset(
                              'assets/images/ic_switch_camera_3.png',
                              color: Colors.grey[200],
                              width: 42.0,
                              height: 42.0,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
    

    .

    【讨论】:

      【解决方案3】:

      您现在也可以使用此插件: CamerAwesome

      官方插件有一个比例错误,导致覆盖率不好。 这个插件包括闪光灯、变焦、自动对焦……并且不需要初始化。

      【讨论】:

        【解决方案4】:

        您可以在我的页面上查看完整代码 https://github.com/Prashantm111/flutter-camera-inscreen-app

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-04-08
          • 1970-01-01
          • 2019-04-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-09-30
          相关资源
          最近更新 更多