Reputation: 197
I am new in android and trying to figure out new camera2 effects. I have no idea how to control iso in camera preview manually. Any help will be appreciated.
Thanks.
Upvotes: 9
Views: 19196
Reputation: 18117
One way to determine if your device supports manual ISO control is to check if it supports the MANUAL_SENSOR capability.
If so, you can turn off auto-exposure by either disabling all automatics:
previewBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_OFF);
or by just disabling auto-exposure, leaving auto-focus and auto-white-balance running:
previewBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
Once you've disabled AE, you can manually control exposure time, sensitivity (ISO), and frame duration):
previewBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, exposureTime);
previewBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, sensitivity);
previewBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, frameDuration);
The valid ranges for these values can be found from SENSOR_INFO_EXPOSURE_TIME_RANGE and SENSOR_INFO_SENSITIVITY_RANGE for exposure and sensitivity. For frame duration, the maximum frame duration can be found from SENSOR_INFO_MAX_DURATION, and the minimum frame duration (max frame rate) depends on your session output configuration. See StreamConfigurationMap.getOutputMinFrameDuration for more details on this.
Note that once you disable AE, you have to control all 3 parameters (there are defaults if you never set one, but they won't vary automatically). You can copy the last-good values for these from the last CaptureResult before you turn off AE, to start with.
Upvotes: 17
Reputation: 807
You have to set previewbuilder
first like this:
mPreviewBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
and than
Range<Integer> range2 = characteristics.get(CameraCharacteristics.SENSOR_INFO_SENSITIVITY_RANGE);
int max1 = range2.getUpper();//10000
int min1 = range2.getLower();//100
int iso = ((progress * (max1 - min1)) / 100 + min1);
mPreviewBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, iso);
progress
is a variable for seekBar from onProgressChanged(SeekBar seekBar, int progress, boolean user)
override method
Upvotes: 2