Camera2CameraInfo


@ExperimentalCamera2Interop
class Camera2CameraInfo


An interface for retrieving Camera2-related camera information.

Use Camera2Interop.getCameraId or Camera2Interop.getCameraCharacteristics in Java, or CameraInfo.cameraId / CameraInfo.cameraCharacteristics in Kotlin instead.

Summary

Public companion functions

Camera2CameraInfo
from(cameraInfo: CameraInfo)

This function is deprecated. Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Public functions

T?

This function is deprecated. Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

String

This function is deprecated. Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Public properties

String

This property is deprecated. Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Public companion functions

from

Added in 1.6.0
Deprecated in 1.7.0-alpha03
fun from(cameraInfo: CameraInfo): Camera2CameraInfo

Gets the Camera2CameraInfo from a CameraInfo.

If the CameraInfo is retrieved by an Extensions-enabled androidx.camera.core.CameraSelector, calling getCameraCharacteristic will return any available Extensions-specific characteristics if exists.

Parameters
cameraInfo: CameraInfo

The CameraInfo to get from.

Returns
Camera2CameraInfo

The camera information with Camera2 implementation.

Throws
IllegalArgumentException

if the camera info does not contain the camera2 information (e.g., if CameraX was not initialized with a androidx.camera.camera2.Camera2Config).

Public functions

getCameraCharacteristic

Added in 1.0.0
Deprecated in 1.7.0-alpha03
fun <T : Any?> getCameraCharacteristic(key: CameraCharacteristics.Key<T>): T?

Gets a camera characteristic value.

The characteristic value is the same as the value in the CameraCharacteristics that would be obtained from android.hardware.camera2.CameraManager.getCameraCharacteristics.

Parameters
<T : Any?>

The type of the characteristic value.

key: CameraCharacteristics.Key<T>

The CameraCharacteristics.Key of the characteristic.

Returns
T?

the value of the characteristic.

getCameraId

Added in 1.0.0
Deprecated in 1.7.0-alpha03
fun getCameraId(): String

Gets the string camera ID.

The camera ID is the same as the camera ID that would be obtained from android.hardware.camera2.CameraManager.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.

Returns
String

the camera ID.

Throws
IllegalStateException

if the camera info does not contain the camera 2 camera ID (e.g., if CameraX was not initialized with a androidx.camera.camera2.Camera2Config).

Public properties

cameraId

val cameraIdString