颤振相机叠加

时间:2018-05-15 10:28:41

标签: android-camera flutter ios-camera

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

有没有人知道一个颤动相机插件或教程解释如何做到这一点?

4 个答案:

答案 0 :(得分:8)

您可以使用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,
        ),
      ),
    ),
  ],
);

答案 1 :(得分:4)

请访问此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,
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    ),
  ),
);

enter image description here

答案 2 :(得分:0)

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

官方插件有一个比率错误,使覆盖率不正确。 该插件包括闪光灯,变焦,自动对焦...,无需初始化。

答案 3 :(得分:0)

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

相关问题