Android Camera2 - CONTROL_AE_REGIONS 不适用于三星设备

标签 android camera2 metering exposure

使用 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。但是在 Samsung Galaxy Note 5 上(我猜是在所有 Samsung 设备上),它不起作用,我的区域被忽略了。

我看到了这个问题:Android Camera2 API - Set AE-regions not working ,运算符(operator)说他设法通过使用三星 SDK 使其正常工作。我真的很想避免这种情况。

有人设法让 AE 区域与三星设备一起工作吗?

最佳答案

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

我需要做的就是从 Activity 传感器矩形的边缘开始移动 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,因为 Activity 数组的最底部像素是mActiveArraySize.height() - 1,我需要再减去一个像素。

documentation这部分似乎很多厂商都没有很好的实现

If the metering region is outside the used android.scaler.cropRegion returned in capture result metadata, the camera device will ignore the sections outside the crop region and output only the intersection rectangle as the metering region in the result metadata. If the region is entirely outside the crop region, it will be ignored and not reported in the result metadata.

关于Android Camera2 - CONTROL_AE_REGIONS 不适用于三星设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44325049/

相关文章:

java - CameraDevice 无法创建 session [Camera2]

Android camera2 点击聚焦

android - camera2,android中的手动对焦

audio - 带有音频和视频过滤器的 ffplay/ffmpeg

android - 使用嵌套选择 Android SQLite 的复杂更新查询

android - 带有 ref 的 Firebase toObject

android - 如何调用来自不同 Activity 的 View 寻呼机中的 fragment ?

java - 从应用程序共享时更改 apk 文件名