【问题标题】:Zoom level difference between Camera1 and Camera2Camera1 和 Camera2 之间的缩放级别差异
【发布时间】:2019-01-07 01:58:56
【问题描述】:

在我们的应用程序中,我们同时支持 API,Camera 和 Camera2,用于拍照。我注意到的是,我们在两个 API 中获得了不同的放大深度。

使用 Camera1 API,设置缩放级别很简单:

Camera.Paramenters params = mCamera.getParameters();
params.setZoom(zoomLevel);
mCamera.setParameters(params);

使用 Camera2 API,缩放级别设置如下(为标准 Camera2 示例应用程序拍摄的代码):

final int zoomScale = 200;
captureBuilder.set(CaptureRequest.SCALER_CROP_REGION, new
     Rect(zoomScale * mZoomLevel, zoomScale * mZoomLevel, mStartBounds.right
     - (zoomScale * mZoomLevel), mStartBounds.bottom - (zoomScale * mZoomLevel)));

我使用的 Android 设备的最大缩放值为 4。在缩放级别 4 时,Camera1 的放大倍数似乎比 Camera2 大得多(至少 10%)。

我想知道我是否在计算中遗漏了什么,或者仅仅是 Camera2 API 的设计方式。问候。

【问题讨论】:

    标签: android android-camera2


    【解决方案1】:

    我不确定您如何为 zoomScale 选择值 200。 camera2 的裁剪区域位于传感器 active array 的坐标中,因此如果要进行 2 倍缩放,则需要将矩形设置为活动数组的宽度和高度的一半。

    粗略的示例代码:

    CameraCharacteristics c = cameraManager.getCameraCharacteristics(cameraId);
    Rect activeArray = c.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
    int cropWidth = activeArray.width() / mZoomLevel;
    int cropHeight = activeArray.height() / mZoomLevel; 
    int cropLeft = (activeArray.width() - cropWidth) / 2;
    int cropTop = (activeArray.height() - cropHeight) / 2;
    Rect cropRegion = new Rect(cropLeft, cropTop, cropLeft + cropWidth, cropTop + cropHeight)
    captureBuilder.set(CaptureRequest.SCALER_CROP_REGION, cropRegion);
    

    【讨论】:

      猜你喜欢
      • 2019-04-16
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      • 2020-06-16
      • 2015-11-01
      • 2016-01-16
      • 2012-07-27
      • 1970-01-01
      相关资源
      最近更新 更多