'Get camera ISO / shutter speed using CameraX or Camera2
I'm trying to get the current preview's shutter speed and ISO settings.
I cannot find a way to do this using CameraX or Camera2. Is this not something that is available?
Failing that, is there a way to get the settings that were used to take a photo?
Solution 1:[1]
For Camera2, this information is available in the CaptureResult objects you get for every captured image, via onCaptureCompleted. However, not all devices support listing this information; only devices that list the READ_SENSOR_SETTINGS capability will do this. That includes all devices that list hardware level FULL or better, and may include some devices at the LIMITED level.
Specifically, you want to look at SENSOR_SENSITIVITY for ISO and SENSOR_EXPOSURE_TIME for shutter speed.
If you want the values used for a JPEG capture, look at the CaptureResult that comes from the CaptureRequest you used to request the JPEG.
Solution 2:[2]
I also was able to GET only the ISO settings using Jetpack/CameraX API through the Camera2CameraInfo.from and then getCameraCharacteristic. But it seems there is no way to set them (using CameraX).
Solution 3:[3]
In the latest releases of Jetpack/CameraX it is also possible to set the ISO/ShutterSpeed. The below example sets the ISO for preview (written in C# language, but it is similar to Java):
var builder = new Preview.Builder();
var ext1 = new Camera2Interop.Extender(builder)
.SetCaptureRequestOption(CaptureRequest.ControlAeMode, (int)ControlAEMode.Off)
.SetCaptureRequestOption(CaptureRequest.SensorSensitivity, 3200);
var preview = builder.SetTargetName("PREVIEW").Build();
preview.SetSurfaceProvider(sfcPreview.SurfaceProvider);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Eddy Talvala |
Solution 2 | Ladislav |
Solution 3 |