Using Android Camera2, I want to use a region to ignore the top 25% of the image when computing the exposure. 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. But on a Samsung Galaxy Note 5 (and, I guess, on all Samsung devices), it doesn't work, my area is ignored.
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. I'd really prefer to avoid that.
Does someone managed to get the AE regions working with Samsung devices?
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. In your example, instead of this rectangle:
I would use this:
I subtracted
2
from the bottom because the botommost pixel of the active array ismActiveArraySize.height() - 1
, and I need to subtract one more pixel.It seems that many vendors have poorly implemented this part of documentation