2

使用 Android Camera2,我想在计算曝光时使用一个区域来忽略图像的前 25%。我正在使用这个:

// Compute the metering rectangle to ignore the top 25% of the picture:
Rect newRect = new Rect(mActiveArraySize.left, (int) (mActiveArraySize.height() * 0.25), mActiveArraySize.right, mActiveArraySize.bottom);
MeteringRectangle meteringRectangle = new MeteringRectangle(newRect, 1);
MeteringRectangle[] meteringRectangleArr = { meteringRectangle };

// Set the metering rectangle:
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, meteringRectangleArr);

// Set the request:
try { mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), null, mBackgroundHandler); }
catch (CameraAccessException e) { e.printStackTrace(); }

它正在我的 Nexus 5X 上运行。但是在三星 Galaxy Note 5 上(我猜是在所有三星设备上),它不起作用,我的区域被忽略了。

我看到了这个问题:Android Camera2 API - Set AE-regions not working,操作员说他设法通过使用三星 SDK 让它工作。我真的更愿意避免这种情况。

是否有人设法让 AE 区域与三星设备一起使用?

4

1 回答 1

0

最近我遇到了同样的问题,终于找到了对我有帮助的解决方案。

我需要做的就是从活动传感器矩形的边缘移动 1 个像素。在您的示例中,而不是这个矩形:

Rect newRect = new Rect(mActiveArraySize.left,
                        (int) (mActiveArraySize.height() * 0.25),
                        mActiveArraySize.right,
                        mActiveArraySize.bottom);

我会用这个:

Rect newRect = new Rect(mActiveArraySize.left + 1,
                        (int)(mActiveArraySize.height() * 0.25),
                        mActiveArraySize.right + 1,
                        mActiveArraySize.bottom - 2);

2从底部减去,因为活动数组的最底部像素是mActiveArraySize.height() - 1,我需要再减去一个像素。

似乎许多供应商没有很好地实现这部分文档

如果测光区域在捕获结果元数据中返回的使用的 android.scaler.cropRegion 之外,相机设备将忽略裁剪区域之外的部分,仅输出相交矩形作为结果元数据中的测光区域。如果该区域完全在裁剪区域之外,它将被忽略并且不会在结果元数据中报告。

于 2017-09-04T06:57:28.560 回答