【问题标题】:Android Camera : avoid mirror images using front-cameraAndroid相机:使用前置摄像头避免镜像
【发布时间】:2014-09-08 05:51:43
【问题描述】:

我正在尝试使用前置摄像头开发相机应用程序。我的预览与前置摄像头是正确的,但是当我捕获图像时它保存为预览的镜像。如何在不使用位图矩阵变换的情况下修复镜像效果?

我尝试了以下开发者网站的代码

public static void setCameraDisplayOrientation(android.hardware.Camera camera) {
    android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
    android.hardware.Camera.getCameraInfo(defaultCameraId, info);
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    int degrees = 0;
    switch (rotation) {
    case Surface.ROTATION_0:
        degrees = 0;
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }

    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        result = (360 - result) % 360; // compensate the mirror
    } else { // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }
    camera.setDisplayOrientation(result);
}

但这对我不起作用。我该怎么做才能解决这个问题?

【问题讨论】:

    标签: android camera


    【解决方案1】:

    前置摄像头是标准镜像。您的预览会自动将其镜像恢复正常。但是,当您拍摄图像或视频时,您会直接从相机中获取帧/图像。所以你必须使用一个矩阵来镜像它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多