I am trying to maximize exposure and sensitivity to get the most light into an image possible using android.hardware.camera2.
Here are the settings I am using right now:
captureRequestBuilder.set( CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.BLACK_LEVEL_LOCK, true );
captureRequestBuilder.set( CaptureRequest.COLOR_CORRECTION_ABERRATION_MODE,
CameraMetadata.COLOR_CORRECTION_ABERRATION_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.COLOR_CORRECTION_MODE, CameraMetadata.COLOR_CORRECTION_MODE_TRANSFORM_MATRIX );
int[] cstMatrix = new int[]{ 128, 128, 0, 128, 0, 128, 0, 128, 128, 128, 0, 128, 0, 128, 0, 128, 128, 128 };
ColorSpaceTransform cst = new ColorSpaceTransform( cstMatrix );
captureRequestBuilder.set( CaptureRequest.COLOR_CORRECTION_TRANSFORM, cst );
captureRequestBuilder.set( CaptureRequest.SHADING_MODE, CameraMetadata.SHADING_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.NOISE_REDUCTION_MODE, CameraMetadata.NOISE_REDUCTION_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_DISABLED );
captureRequestBuilder.set( CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.EDGE_MODE, CameraMetadata.EDGE_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.SENSOR_SENSITIVITY, MAX_SENSITIVITY );
captureRequestBuilder.set( CaptureRequest.LENS_FOCUS_DISTANCE, (float) 0.0 );
captureRequestBuilder.set( CaptureRequest.SENSOR_FRAME_DURATION, MAX_FRAME_DURATION );
captureRequestBuilder.set( CaptureRequest.SENSOR_EXPOSURE_TIME, MAX_FRAME_DURATION );
captureRequestBuilder.set( CaptureRequest.HOT_PIXEL_MODE, CameraMetadata.HOT_PIXEL_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.STATISTICS_FACE_DETECT_MODE, CameraMetadata.STATISTICS_FACE_DETECT_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE, CameraMetadata.STATISTICS_LENS_SHADING_MAP_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.SENSOR_TEST_PATTERN_MODE, CameraMetadata.SENSOR_TEST_PATTERN_MODE_OFF );
captureRequestBuilder.set( CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, CameraMetadata.CONTROL_VIDEO_STABILIZATION_MODE_OFF );
// build all the settings into the camera request
CaptureRequest captureRequest = captureRequestBuilder.build();
// Finally, we start displaying the camera preview.
mCaptureSession.setRepeatingRequest( captureRequest, mCaptureCallback, backgroundHandler );
Where MAX_SENSITIVITY and MAX_FRAME_DURATION_NS are the max values returned from the GetCameraCharacteristics functions for a given device.
I am using YUV_420_888 format because that seems to be supported by all Android devices that support the Camera2 interface.
I'm hoping for a sanity check of the settings shown above and any additional tips/tricks for getting the most out of every Camera2 compatible camera.
Thanks.
So I discovered that the max sensitivity returned by the camera characteristics call is not a hard limit. You can set the CaptureRequest.SENSOR_SENSITIVITY to values much higher than the supposed limits, at least with the phones I am testing with. I hope this is not a bug that gets fixed 'cause I am relying on it.