# Camera2CameraInfo

Artifact: [androidx.camera:camera-camera2](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/camera2/interop/Camera2CameraInfo.kt+class:androidx.camera.camera2.interop.Camera2CameraInfo) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0) Deprecated in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
@ExperimentalCamera2Interop
class Camera2CameraInfo
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

An interface for retrieving Camera2-related camera information.

Use `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraId(androidx.camera.core.CameraInfo)` or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraCharacteristics(androidx.camera.core.CameraInfo)` in Java, or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraInfo).cameraId()` / `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraInfo).cameraCharacteristics()` in Kotlin instead.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo` | `[from](https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#from(androidx.camera.core.CameraInfo))(cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo)` **This function is deprecated.** Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'. |

| ### Public functions |
|---|---|
| `T?` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> [getCameraCharacteristic](https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key))(key: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html<T>)` **This function is deprecated.** Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `[getCameraId](https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraId())()` **This function is deprecated.** Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#cameraId()` **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](https://developer.android.com/jetpack/androidx/releases/camera#1.6.0) Deprecated in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
fun [from](https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#from(androidx.camera.core.CameraInfo))(cameraInfo: CameraInfo): Camera2CameraInfo
```

> [!CAUTION]
> **This function is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Gets the `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo` from a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`.

If the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` is retrieved by an Extensions-enabled `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector`, calling `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key)` will return any available Extensions-specific characteristics if exists.

| Parameters |
|---|---|
| `cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` | The `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` to get from. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo` | The camera information with Camera2 implementation. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the camera info does not contain the camera2 information (e.g., if CameraX was not initialized with a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/Camera2Config`). |

## Public functions

### getCameraCharacteristic

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0) Deprecated in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
fun <T : Any?> [getCameraCharacteristic](https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key))(key: CameraCharacteristics.Key<T>): T?
```

> [!CAUTION]
> **This function is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Gets a camera characteristic value.

The characteristic value is the same as the value in the `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` that would be obtained from `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#getCameraCharacteristics(java.lang.String)`.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | The type of the characteristic value. |
| `key: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html<T>` | The `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.Key.html` of the characteristic. |

| Returns |
|---|---|
| `T?` | the value of the characteristic. |

### getCameraId

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0) Deprecated in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
fun [getCameraId](https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraId())(): String
```

> [!CAUTION]
> **This function is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.

Gets the string camera ID.

The camera ID is the same as the camera ID that would be obtained from `https://developer.android.com/reference/android/hardware/camera2/CameraManager.html#getCameraIdList()`. The ID that is retrieved is not static and can change depending on the current internal configuration of the `https://developer.android.com/reference/kotlin/androidx/camera/core/Camera` from which the CameraInfo was retrieved.

The Camera is a logical camera which can be backed by multiple `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html`. However, only one CameraDevice is active at one time. When the CameraDevice changes then the camera id will change.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the camera ID. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the camera info does not contain the camera 2 camera ID (e.g., if CameraX was not initialized with a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/Camera2Config`). |

## Public properties

### cameraId

```
val cameraId: String
```

> [!CAUTION]
> **This property is deprecated.**   
> Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'.