简体   繁体   English

Android Camera2-CONTROL_AE_REGIONS在三星设备上不起作用

[英]Android Camera2 - CONTROL_AE_REGIONS not working on Samsung devices

Using Android Camera2, I want to use a region to ignore the top 25% of the image when computing the exposure. 使用Android Camera2,我想在计算曝光时使用区域忽略图像的前25%。 I'm using this: 我正在使用这个:

// 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(); }

And it's working on my Nexus 5X. 它可以在我的Nexus 5X上运行。 But on a Samsung Galaxy Note 5 (and, I guess, on all Samsung devices), it doesn't work, my area is ignored. 但是在Samsung Galaxy Note 5(我猜是在所有Samsung设备上)上,它不起作用,我的区域被忽略了。

I saw this question: Android Camera2 API - Set AE-regions not working , with the op saying that he managed to get it working by using the Samsung SDK. 我看到了一个问题: Android Camera2 API-设置AE区域不起作用 ,操作人员说他设法使用Samsung SDK使其起作用。 I'd really prefer to avoid that. 我真的更喜欢避免这种情况。

Does someone managed to get the AE regions working with Samsung devices? 是否有人设法使AE地区与Samsung设备兼容?

Recently I had the same problem and finally found a solution that helped me. 最近,我遇到了同样的问题,终于找到了对我有帮助的解决方案。

All I needed to do was to step 1 pixel from the edges of the active sensor rectangle. 我需要做的就是从活动传感器矩形的边缘开始移动1个像素。 In your example, instead of this rectangle: 在您的示例中,代替此矩形:

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

I would use this: 我会用这个:

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

I subtracted 2 from the bottom because the botommost pixel of the active array is mActiveArraySize.height() - 1 , and I need to subtract one more pixel. 我从底部减去2 ,因为活动数组的最底部像素是mActiveArraySize.height() - 1 ,我需要再减去一个像素。

It seems that many vendors have poorly implemented this part of 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. 如果测光区域在捕获结果元数据中返回的使用的android.scaler.cropRegion之外,则摄像头设备将忽略裁剪区域之外的部分,仅在结果元数据中输出交点矩形作为测光区域。 If the region is entirely outside the crop region, it will be ignored and not reported in the result metadata. 如果该区域完全位于作物区域之外,则它将被忽略并且不会在结果元数据中报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM