Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control iso manually in camera2, android

Tags:

android

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.

like image 776
Vardges Avatar asked Feb 03 '15 06:02

Vardges


People also ask

What is Camera2 in Android?

Camera2 is the latest low-level Android camera package and replaces the deprecated Camera class. Camera2 provides in-depth controls for complex use cases, but requires you to manage device-specific configurations. You can read about specific Camera2 classes and functions in the reference documentation.


1 Answers

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.

like image 79
Eddy Talvala Avatar answered Sep 20 '22 06:09

Eddy Talvala