While using Camera2API in Android as CameraMetadata.CONTROL_MODE_OFF
, the images care coming with A LOT OF green, just like as if there is only a green channel.
The code I used is:
final CaptureRequest.Builder captureBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
captureBuilder.addTarget(imageReader.getSurface());
captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_OFF);
captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME,Long.valueOf("2000000000"));
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY,200);
But when I set the CameraMetadata
to CONTROL_MODE_AUTO
, as in
captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
then the images are correct (not green).
Why is that and what must be done to avoid it?
You basically answered your own question, the documentation for CONTROL_AWB_MODE says
This control is only effective if android.control.mode is AUTO.
So CONTROL_MODE_OFF
takes precedence over each individual control of 3A routines. If you need to disable just some of them, keeping the others in AUTO, use per-routine controls CONTROL_AE_MODE, CONTROL_AF_MODE and CONTROL_AWB_MODE.