# Camera2Interop

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/Camera2Interop.kt+class:androidx.camera.camera2.interop.Camera2Interop) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

*** ** * ** ***


```
class Camera2Interop
```

<br />

*** ** * ** ***

Provides utilities to configure and query Camera2 APIs.

**Note:** Using Camera2 interop options can override internal CameraX configurations. If an option configured via interop conflicts with options required by CameraX internally, the option from Camera2Interop will override, which may result in unexpected behavior or interfere with CameraX functionality.

Use this class to:

- Apply Camera2 configuration to `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` builders using `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forUseCase(androidx.core.util.Consumer)`, `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forImageCapture(androidx.core.util.Consumer)`, or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forSessionConfig(androidx.core.util.Consumer)`

- Apply Camera2 configuration to active camera controls using `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forCameraControl(androidx.core.util.Consumer)`

- Query Camera2 metadata using `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)`

- Create camera selectors or filters using `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraSelectorFromCameraId(kotlin.String)` or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraFilterFromCameraId(kotlin.String)`

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ExperimentalCamera2Interop class https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Extender<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` **This class is deprecated.** Use the camera2Interop extension function on UseCase.Builder (e.g., 'builder.camera2Interop { setPhysicalCameraId(physicalCameraId) }') or SessionConfig.Builder for capture request options and callbacks instead. |

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Configurator` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forCameraControl(androidx.core.util.Consumer)(configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop>)` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Configurator` to modify a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Configurator` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forImageCapture(androidx.core.util.Consumer)(configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop>)` Creates an `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Configurator` to modify ImageCapture builders. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Configurator` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forSessionConfig(androidx.core.util.Consumer)(configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop>)` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Configurator` to modify a session configuration builder. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Configurator` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forUseCase(androidx.core.util.Consumer)(configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop>)` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Configurator` to modify Preview, ImageAnalysis, and VideoCapture builders. |
| `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraCharacteristics(androidx.camera.core.CameraInfo)(cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo)` Returns the `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` from a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraFilter` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraFilterFromCameraId(kotlin.String)(cameraId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraFilter` that matches a specific Camera2 camera ID. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraId(androidx.camera.core.CameraInfo)(cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo)` Returns the Camera2 camera ID from a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` | `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#getCameraSelectorFromCameraId(kotlin.String)(cameraId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` targeting a specific Camera2 camera ID. |

## Public companion functions

### forCameraControl

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

```
fun forCameraControl(configurator: Consumer<CameraControlCamera2Interop>): CameraControlCamera2Configurator
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Configurator` to modify a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl`.

Use this with `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#applyInteropAsync(androidx.camera.core.InteropConfigurator<? super androidx.camera.core.CameraControl>)` to dynamically send Camera2 capture request options to an active camera. All options configured within a single `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Companion#forCameraControl(androidx.core.util.Consumer)` are applied atomically in a single repeating capture request update. Subsequent calls to `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#applyInteropAsync(androidx.camera.core.InteropConfigurator<? super androidx.camera.core.CameraControl>)` update parameters incrementally without clearing previously set keys, unless explicitly cleared using `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#clearCaptureRequestOption(android.hardware.camera2.CaptureRequest.Key)` or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#clearAllCaptureRequestOptions()`. This overwrites options set with `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` via `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder#setInterop(androidx.camera.core.InteropConfigurator)`.

The `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` target allows configuring options such as:

- Capture request key-value pairs (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#setCaptureRequestOption(android.hardware.camera2.CaptureRequest.Key,kotlin.Any)`)

- Clearing specific capture request keys (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#clearCaptureRequestOption(android.hardware.camera2.CaptureRequest.Key)`)

- Clearing all capture request keys (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#clearAllCaptureRequestOptions()`)

- Capture request template type (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#repeatingCaptureRequestTemplate()`)

- Repeating capture callbacks (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#setRepeatingCaptureCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraCaptureSession.CaptureCallback)` or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#repeatingCaptureCallback()`)

**Warning:** Callbacks configured via interop receive raw `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html` instances. Directly invoking state-altering, lifecycle, or request-submitting methods on these raw objects bypasses CameraX pipeline management and causes state desynchronization, stream freezing, or crashes. Do not invoke:

- Session lifecycle methods: `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#close()`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#abortCaptures()`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#stopRepeating()`

- Request submission methods: `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingRequest(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingBurst(java.util.List&lt;android.hardware.camera2.CaptureRequest&gt;, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#captureBurst(java.util.List&lt;android.hardware.camera2.CaptureRequest&gt;, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`

- Surface / output configuration methods: `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#updateOutputConfiguration(android.hardware.camera2.params.OutputConfiguration)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#finalizeOutputConfigurations(java.util.List&lt;android.hardware.camera2.params.OutputConfiguration&gt;)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#prepare(android.view.Surface)`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#switchToOffline(java.util.Collection&lt;android.view.Surface&gt;, java.util.concurrent.Executor, android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback)`

| Parameters |
|---|---|
| `configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop>` | the callback applying Camera2 options to `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Configurator` | the `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Configurator` to pass to `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#applyInteropAsync(androidx.camera.core.InteropConfigurator<? super androidx.camera.core.CameraControl>)` |

### forImageCapture

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

```
fun forImageCapture(configurator: Consumer<ImageCaptureCamera2Interop>): ImageCaptureCamera2Configurator
```

Creates an `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Configurator` to modify ImageCapture builders.

Use this with `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setInterop(androidx.camera.core.InteropConfigurator<androidx.camera.core.ImageCapture.Builder>)` in Java to apply Camera2 options. The `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` target allows configuring options such as:

- Physical camera ID (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#physicalCameraId()`)

- Stream use case (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#streamUseCase()`)

- Mirror mode (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#mirrorMode()`)

- Timestamp base (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#timestampBase()`)

- Dynamic range profile (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#dynamicRangeProfile()`)

- Surface group ID (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#surfaceGroupId()`)

- Still capture request key-value pairs (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/StillCaptureInterop#setStillCaptureRequestOption(android.hardware.camera2.CaptureRequest.Key,kotlin.Any)`)

- Still capture request template type (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/StillCaptureInterop#stillCaptureRequestTemplateType()`)

- Still capture callbacks (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/StillCaptureInterop#setStillCaptureCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraCaptureSession.CaptureCallback)`)

The capture request keys for one-shot still captures (such as `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)`) are determined by copying all repeating request keys (which may include keys added via `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder#setInterop(androidx.camera.core.InteropConfigurator)` or `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#applyInteropAsync(androidx.camera.core.InteropConfigurator<? super androidx.camera.core.CameraControl>)`) and then overriding them with the still capture request keys configured here.

**Warning:** Callbacks configured via interop receive raw `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html` instances. Directly invoking state-altering, lifecycle, or request-submitting methods on these raw objects bypasses CameraX pipeline management and causes state desynchronization, stream freezing, or crashes. Do not invoke:

- Session lifecycle methods: `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#close()`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#abortCaptures()`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#stopRepeating()`

- Request submission methods: `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingRequest(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingBurst(java.util.List&lt;android.hardware.camera2.CaptureRequest&gt;, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#captureBurst(java.util.List&lt;android.hardware.camera2.CaptureRequest&gt;, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`

- Surface / output configuration methods: `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#updateOutputConfiguration(android.hardware.camera2.params.OutputConfiguration)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#finalizeOutputConfigurations(java.util.List&lt;android.hardware.camera2.params.OutputConfiguration&gt;)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#prepare(android.view.Surface)`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#switchToOffline(java.util.Collection&lt;android.view.Surface&gt;, java.util.concurrent.Executor, android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback)`

| Parameters |
|---|---|
| `configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop>` | the callback applying Camera2 options to `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Configurator` | the `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Configurator` to pass to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setInterop(androidx.camera.core.InteropConfigurator<androidx.camera.core.ImageCapture.Builder>)` |

### forSessionConfig

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

```
fun forSessionConfig(configurator: Consumer<SessionConfigCamera2Interop>): SessionConfigCamera2Configurator
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Configurator` to modify a session configuration builder.

Use this with `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder#setInterop(androidx.camera.core.InteropConfigurator)` in Java to apply Camera2 options to a custom session configuration. The `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` target allows configuring options such as:

- Session parameters (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigurationInterop#setSessionParameter(android.hardware.camera2.CaptureRequest.Key,kotlin.Any)`)

- Session type (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigurationInterop#sessionType()`)

- Color space (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigurationInterop#colorSpace()`)

- Session state callbacks (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigurationInterop#setSessionStateCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraCaptureSession.StateCallback)`)

- Device state callbacks (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraDeviceInterop#setDeviceStateCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraDevice.StateCallback)`)

- Capture request key-value pairs (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#setCaptureRequestOption(android.hardware.camera2.CaptureRequest.Key,kotlin.Any)`)

- Clearing specific capture request keys (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#clearCaptureRequestOption(android.hardware.camera2.CaptureRequest.Key)`)

- Clearing all capture request keys (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#clearAllCaptureRequestOptions()`)

- Capture request template type (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#repeatingCaptureRequestTemplate()`)

- Repeating capture callbacks (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#setRepeatingCaptureCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraCaptureSession.CaptureCallback)`)

**Warning:** Callbacks configured via interop receive raw `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html` and `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html` instances. Directly invoking state-altering, lifecycle, or request-submitting methods on these raw objects bypasses CameraX pipeline management and causes state desynchronization, stream freezing, or crashes. Do not invoke:

- On `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html`: `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#close()` or session creation methods (`https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSessionByOutputConfigurations(java.util.List&lt;android.hardware.camera2.params.OutputConfiguration&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List&lt;android.view.Surface&gt;, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createExtensionSession(android.hardware.camera2.params.ExtensionSessionConfiguration)`)

- On `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html`: lifecycle methods (`https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#close()`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#abortCaptures()`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#stopRepeating()`), request submission methods (`https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingRequest(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#setRepeatingBurst(java.util.List&lt;android.hardware.camera2.CaptureRequest&gt;, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#captureBurst(java.util.List&lt;android.hardware.camera2.CaptureRequest&gt;, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)`), or surface configuration methods (`https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#updateOutputConfiguration(android.hardware.camera2.params.OutputConfiguration)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#finalizeOutputConfigurations(java.util.List&lt;android.hardware.camera2.params.OutputConfiguration&gt;)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#prepare(android.view.Surface)`, `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html#switchToOffline(java.util.Collection&lt;android.view.Surface&gt;, java.util.concurrent.Executor, android.hardware.camera2.CameraOfflineSession.CameraOfflineSessionCallback)`)

| Parameters |
|---|---|
| `configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop>` | the callback applying Camera2 options to `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Configurator` | the `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Configurator` to pass to `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder#setInterop(androidx.camera.core.InteropConfigurator)` |

### forUseCase

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

```
fun forUseCase(configurator: Consumer<UseCaseCamera2Interop>): UseCaseCamera2Configurator
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Configurator` to modify Preview, ImageAnalysis, and VideoCapture builders.

Use this with `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase.InteropConfigurable#setInterop(androidx.camera.core.InteropConfigurator<? super B>)` in Java to apply Camera2 options. The `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` target allows configuring options such as:

- Physical camera ID (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#physicalCameraId()`)

- Stream use case (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#streamUseCase()`)

- Mirror mode (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#mirrorMode()`)

- Timestamp base (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#timestampBase()`)

- Dynamic range profile (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#dynamicRangeProfile()`)

- Surface group ID (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop#surfaceGroupId()`)

For `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder`, use `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop#forImageCapture(androidx.core.util.Consumer)`.

| Parameters |
|---|---|
| `configurator: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop>` | the callback applying Camera2 options to `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Configurator` | the `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Configurator` to pass to `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase.InteropConfigurable#setInterop(androidx.camera.core.InteropConfigurator<? super B>)` |

### getCameraCharacteristics

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

```
fun getCameraCharacteristics(cameraInfo: CameraInfo): CameraCharacteristics
```

Returns the `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` from a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`.

Example:

```kotlin
CameraCharacteristics characteristics = Camera2Interop.getCameraCharacteristics(cameraInfo);
Integer sensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
```

| Parameters |
|---|---|
| `cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` | target `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` | `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` associated with `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Companion#getCameraCharacteristics(androidx.camera.core.CameraInfo)` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Companion#getCameraCharacteristics(androidx.camera.core.CameraInfo)` does not contain Camera2 information |

### getCameraFilterFromCameraId

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

```
fun getCameraFilterFromCameraId(cameraId: String): CameraFilter
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraFilter` that matches a specific Camera2 camera ID.

| Parameters |
|---|---|
| `cameraId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | target Camera2 camera ID |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraFilter` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraFilter` matching `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Companion#getCameraFilterFromCameraId(kotlin.String)` |

### getCameraId

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

```
fun getCameraId(cameraInfo: CameraInfo): String
```

Returns the Camera2 camera ID from a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`.

Example:

```kotlin
String cameraId = Camera2Interop.getCameraId(cameraInfo);
```

| Parameters |
|---|---|
| `cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` | target `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` |

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Companion#getCameraId(androidx.camera.core.CameraInfo)` does not contain Camera2 information |

### getCameraSelectorFromCameraId

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

```
fun getCameraSelectorFromCameraId(cameraId: String): CameraSelector
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` targeting a specific Camera2 camera ID.

Example:

```kotlin
CameraSelector cameraSelector = Camera2Interop.getCameraSelectorFromCameraId("0");
cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, useCase);
```

| Parameters |
|---|---|
| `cameraId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | target Camera2 camera ID |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` that filters for `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Companion#getCameraSelectorFromCameraId(kotlin.String)` |