Camera2CameraInfo
@ExperimentalCamera2Interop
public final class Camera2CameraInfo
An interface for retrieving Camera2-related camera information.
Summary
Public methods |
|
|---|---|
static @NonNull Camera2CameraInfo |
from(@NonNull CameraInfo cameraInfo)Gets the |
@Nullable T |
<T> getCameraCharacteristic(@NonNull CameraCharacteristics.Key<T> key)Gets a camera characteristic value. |
@NonNull String |
Gets the string camera ID. |
Public methods
from
public static @NonNull Camera2CameraInfo from(@NonNull CameraInfo cameraInfo)
Gets the Camera2CameraInfo from a CameraInfo.
If the CameraInfo is retrieved by an Extensions-enabled CameraSelector, calling getCameraCharacteristic will return any available Extensions-specific characteristics if exists.
| Parameters | |
|---|---|
@NonNull CameraInfo cameraInfo |
The |
| Returns | |
|---|---|
@NonNull Camera2CameraInfo |
The camera information with Camera2 implementation. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the camera info does not contain the camera2 information (e.g., if CameraX was not initialized with a |
getCameraCharacteristic
public @Nullable T <T> getCameraCharacteristic(@NonNull CameraCharacteristics.Key<T> key)
Gets a camera characteristic value.
The characteristic value is the same as the value in the CameraCharacteristics that would be obtained from getCameraCharacteristics.
| Parameters | |
|---|---|
<T> |
The type of the characteristic value. |
@NonNull CameraCharacteristics.Key<T> key |
The |
| Returns | |
|---|---|
@Nullable T |
the value of the characteristic. |
getCameraId
public @NonNull String getCameraId()
Gets the string camera ID.
The camera ID is the same as the camera ID that would be obtained from getCameraIdList. The ID that is retrieved is not static and can change depending on the current internal configuration of the androidx.camera.core.Camera from which the CameraInfo was retrieved. The Camera is a logical camera which can be backed by multiple android.hardware.camera2.CameraDevice. However, only one CameraDevice is active at one time. When the CameraDevice changes then the camera id will change.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if the camera info does not contain the camera 2 camera ID (e.g., if CameraX was not initialized with a |