Android Camera2 - CONTROL_AE_REGIONS not working on Samsung devices

1.1k views Asked by At

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?

1

There are 1 answers

3
Mikhail On

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:

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.

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. If the region is entirely outside the crop region, it will be ignored and not reported in the result metadata.