# androidx.camera.camera2.interop

*** ** * ** ***

## Interfaces

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop` | Configures Camera2 `https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.html` options. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraDeviceInterop` | Configures Camera2 `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html` options. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/OutputConfigurationInterop` | Configures Camera2 `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html` options. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigurationInterop` | Configures Camera2 `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration.html` options. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/StillCaptureInterop` | Configures Camera2 options for still capture requests. |

## Classes

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraControl` | **This class is deprecated.** Use the CameraControl.applyCamera2Interop or CameraControl.applyCamera2InteropAsync extension functions instead, e.g., 'cameraControl.applyCamera2Interop { setCaptureRequestOption(key, value) }'. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo` | **This class is deprecated.** Use the CameraInfo extension properties instead, e.g., 'cameraInfo.cameraId' or 'cameraInfo.cameraCharacteristics'. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop` | Provides utilities to configure and query Camera2 APIs. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2Interop.Extender` | **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. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Configurator` | Configures `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` options on a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` | Configures Camera2 options on a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CaptureRequestOptionTarget` | Target class supporting `captureRequest[key] = value` indexing operator syntax. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CaptureRequestOptions` | **This class is deprecated.** Use the camera2Interop or applyCamera2Interop extension functions instead, e.g., 'builder.camera2Interop { setCaptureRequestOption(key, value) }'. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CaptureRequestOptions.Builder` | **This class is deprecated.** Use the camera2Interop or applyCamera2Interop extension functions instead, e.g., 'builder.camera2Interop { setCaptureRequestOption(key, value) }'. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Configurator` | Configures `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` options on an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` | Configures Camera2 options on an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` use case. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Configurator` | Configures `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` options on a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` | Configures Camera2 options on a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionParameterTarget` | Target class supporting `sessionParameter[key] = value` indexing operator syntax. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/StillCaptureRequestOptionTarget` | Target class supporting `stillCaptureRequest[key] = value` indexing operator syntax. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Configurator` | Configures `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` options on `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` builders. |
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` | Configures Camera2 options on a `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`. |

## Annotations

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ExperimentalCamera2Interop` | Denotes that the annotated method uses the experimental methods which allow direct access to camera2 classes. |

## Extension functions summary

|---|---|
| `suspend inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraControl).applyCamera2Interop(kotlin.Function1)(crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Applies Camera2 options to a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl` asynchronously within a coroutine. |
| `inline https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraControl).applyCamera2InteropAsync(kotlin.Function1)(crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Applies Camera2 options to a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl` asynchronously. |
| `inline B` | `<B : https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase.InteropConfigurable<B>> B.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.UseCase.InteropConfigurable).camera2Interop(kotlin.Function1)( crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Applies Camera2 options to a UseCase builder. |
| `inline https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.ImageCapture.Builder).camera2Interop(kotlin.Function1)(crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Applies Camera2 options to an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder`. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<B : https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase.InteropConfigurable<B>> https://developer.android.com/reference/kotlin/androidx/camera/core/InteropConfigurableScope<B>.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.InteropConfigurableScope).camera2Interop(kotlin.Function1)( crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Applies Camera2 options inside an `https://developer.android.com/reference/kotlin/androidx/camera/core/InteropConfigurableScope` DSL block. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.ImageCaptureScope).camera2Interop(kotlin.Function1)(crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Applies Camera2 options inside an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope` DSL block. |
| `inline https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.SessionConfig.Builder).camera2Interop(kotlin.Function1)(crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Applies Camera2 options to a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder`. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfigScope.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.SessionConfigScope).camera2Interop(kotlin.Function1)(crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Applies Camera2 options inside a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfigScope` DSL block. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(kotlin.String).toCameraSelector()()` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` targeting this camera ID string. |

## Extension properties summary

|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraInfo).cameraCharacteristics()` Returns the `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` from this `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo.https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraInfo).cameraId()` Returns the Camera2 camera ID from this `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`. |

## Extension functions

### CameraControl.applyCamera2Interop

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/Camera2InteropEx.kt+function:applyCamera2Interop) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
suspend inline fun CameraControl.applyCamera2Interop(crossinline block: CameraControlCamera2Interop.() -> Unit): Unit
```

Applies Camera2 options to a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl` asynchronously within a coroutine.

Dynamically updates repeating capture request parameters or capture request keys on an active camera session. Options configured within a single `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraControl).applyCamera2Interop(kotlin.Function1)` are applied atomically in a single repeating capture request update. Subsequent calls to `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraControl).applyCamera2Interop(kotlin.Function1)` 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)` (or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.SessionConfig.Builder).camera2Interop(kotlin.Function1)`).

This function suspends until all specified interoperability options have been successfully updated in the underlying repeating capture request. Throws `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl.OperationCanceledException` if a newer configuration is applied before this operation takes effect or if the camera is closed.

Options configured via `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` include:

- Capture request key-value pairs (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#captureRequest()` via `captureRequest[...]` or `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()`)

**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 3A routines and camera control APIs.

**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)`

```kotlin
import androidx.camera.camera2.interop.applyCamera2Interop

cameraControl.applyCamera2Interop {
    captureRequest[CaptureRequest.CONTROL_AE_MODE] = CaptureRequest.CONTROL_AE_MODE_OFF
    repeatingCaptureCallback = object : CameraCaptureSession.CaptureCallback() {}
}
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl.OperationCanceledException` | if a newer configuration is applied before this operation takes effect or if the camera is closed |

### CameraControl.applyCamera2InteropAsync

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/Camera2InteropEx.kt+function:applyCamera2InteropAsync) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
inline fun CameraControl.applyCamera2InteropAsync(crossinline block: CameraControlCamera2Interop.() -> Unit): ListenableFuture<Void>
```

Applies Camera2 options to a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl` asynchronously.

Dynamically updates repeating capture request parameters or capture request keys on an active camera session. Options configured within a single `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraControl).applyCamera2InteropAsync(kotlin.Function1)` are applied atomically in a single repeating capture request update. Subsequent calls to `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.CameraControl).applyCamera2InteropAsync(kotlin.Function1)` 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)` (or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.SessionConfig.Builder).camera2Interop(kotlin.Function1)`).

Options configured via `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` include:

- Capture request key-value pairs (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#captureRequest()` via `captureRequest[...]` or `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()`)

**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 3A routines and camera control APIs.

**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)`

```kotlin
import androidx.camera.camera2.interop.applyCamera2Interop
import androidx.camera.camera2.interop.applyCamera2InteropAsync

cameraControl.applyCamera2InteropAsync {
    captureRequest[CaptureRequest.CONTROL_AE_MODE] = CaptureRequest.CONTROL_AE_MODE_OFF
    repeatingCaptureCallback = object : CameraCaptureSession.CaptureCallback() {}
}
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraControlCamera2Interop` |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Void.html>` | `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` completing with `null` when all specified interoperability options have been successfully updated in the underlying repeating capture request. The future fails with `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl.OperationCanceledException` if a newer configuration is applied before this operation takes effect or if the camera is closed. Cancelling the future is a no-op. |

### B.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/Camera2InteropEx.kt+function:camera2Interop) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
inline fun <B : UseCase.InteropConfigurable<B>> B.camera2Interop(
    crossinline block: UseCaseCamera2Interop.() -> Unit
): B
```

Applies Camera2 options to a UseCase builder.

Configures Camera2 options on builders implementing `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase.InteropConfigurable` (such as `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview.Builder`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder`, or `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapture.Builder`). For `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder`, use the dedicated `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.ImageCapture.Builder).camera2Interop(kotlin.Function1)` extension function.

Options configured via `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` include:

- 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()`)

**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.

```kotlin
import androidx.camera.camera2.interop.camera2Interop
import androidx.camera.core.Preview
import androidx.camera.core.preview

val preview =
    Preview.Builder()
        .camera2Interop {
            physicalCameraId = "5"
            mirrorMode = OutputConfiguration.MIRROR_MODE_H
        }
        .build()
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` |

| Returns |
|---|---|
| `B` | this builder |

### ImageCapture.Builder.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/Camera2InteropEx.kt+function:camera2Interop) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
inline fun ImageCapture.Builder.camera2Interop(crossinline block: ImageCaptureCamera2Interop.() -> Unit): ImageCapture.Builder
```

Applies Camera2 options to an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder`.

Configures Camera2 options specific to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder`.

Options configured via `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` include:

- 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#stillCaptureRequest()` via `stillCaptureRequest[...]` or `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)` or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/StillCaptureInterop#stillCaptureCallback()`)

**Note:** Using Camera2 interop options can override internal CameraX configurations. 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. 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.

**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)`

```kotlin
import androidx.camera.camera2.interop.camera2Interop
import androidx.camera.core.ImageCapture
import androidx.camera.core.imageCapture

val imageCapture =
    ImageCapture.Builder()
        .camera2Interop {
            stillCaptureRequestTemplateType = CameraDevice.TEMPLATE_STILL_CAPTURE
            stillCaptureRequest[CaptureRequest.CONTROL_AF_MODE] =
                CaptureRequest.CONTROL_AF_MODE_OFF
            stillCaptureCallback =
                object : CameraCaptureSession.CaptureCallback() {
                    override fun onCaptureCompleted(
                        session: CameraCaptureSession,
                        request: CaptureRequest,
                        result: TotalCaptureResult,
                    ) {}
                }
            physicalCameraId = "5"
        }
        .build()
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder` | this builder |

### InteropConfigurableScope.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/Camera2InteropEx.kt+function:camera2Interop)

```
inline fun <B : UseCase.InteropConfigurable<B>> InteropConfigurableScope<B>.camera2Interop(
    crossinline block: UseCaseCamera2Interop.() -> Unit
): Unit
```

Applies Camera2 options inside an `https://developer.android.com/reference/kotlin/androidx/camera/core/InteropConfigurableScope` DSL block.

Configures Camera2 options on the underlying UseCase builder within Kotlin DSL blocks such as `preview { ... }`, `imageAnalysis { ... }`, or `videoCapture { ... }`. For `imageCapture { ... }`, use the dedicated `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/package-summary#(androidx.camera.core.ImageCaptureScope).camera2Interop(kotlin.Function1)` extension function.

Options configured via `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` include:

- 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()`)

**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.

```kotlin
import androidx.camera.camera2.interop.camera2Interop
import androidx.camera.core.preview

val preview = preview {
    camera2Interop {
        physicalCameraId = "0"
        mirrorMode = OutputConfiguration.MIRROR_MODE_H
    }
}
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/UseCaseCamera2Interop` |

### ImageCaptureScope.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/Camera2InteropEx.kt+function:camera2Interop) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
inline fun ImageCaptureScope.camera2Interop(crossinline block: ImageCaptureCamera2Interop.() -> Unit): Unit
```

Applies Camera2 options inside an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope` DSL block.

Configures Camera2 options on the underlying `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder` within an `imageCapture { ... }` DSL block.

Options configured via `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` include:

- 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#stillCaptureRequest()` via `stillCaptureRequest[...]` or `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)` or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/StillCaptureInterop#stillCaptureCallback()`)

**Note:** Using Camera2 interop options can override internal CameraX configurations. 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. 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.

**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)`

```kotlin
import androidx.camera.camera2.interop.camera2Interop
import androidx.camera.core.imageCapture

val imageCapture = imageCapture {
    camera2Interop {
        stillCaptureRequestTemplateType = CameraDevice.TEMPLATE_PREVIEW
        stillCaptureRequest[CaptureRequest.CONTROL_AF_MODE] = CaptureRequest.CONTROL_AF_MODE_OFF
        stillCaptureCallback =
            object : CameraCaptureSession.CaptureCallback() {
                override fun onCaptureCompleted(
                    session: CameraCaptureSession,
                    request: CaptureRequest,
                    result: TotalCaptureResult,
                ) {}
            }
        physicalCameraId = "5"
    }
}
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` |

### SessionConfig.Builder.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/Camera2InteropEx.kt+function:camera2Interop) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
inline fun SessionConfig.Builder.camera2Interop(crossinline block: SessionConfigCamera2Interop.() -> Unit): SessionConfig.Builder
```

Applies Camera2 options to a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder`.

Configures Camera2 options for a capture session builder. Can be called on a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder` directly or within a `https://developer.android.com/reference/kotlin/androidx/camera/core/package-summary#sessionConfig(kotlin.collections.List,kotlin.Function1)` DSL block.

Options configured via `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` include:

- Session parameters (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigurationInterop#sessionParameter()` via `sessionParameter[...]` or `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)` or `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigurationInterop#sessionStateCallback()`)

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

- Capture request key-value pairs (`https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/CameraCaptureSessionInterop#captureRequest()` via `captureRequest[...]` or `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()`)

**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.

**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)`)

```kotlin
import androidx.camera.camera2.interop.camera2Interop
import androidx.camera.core.SessionConfig
import androidx.camera.core.preview
import androidx.camera.core.sessionConfig

val sessionConfig =
    SessionConfig.Builder(preview)
        .camera2Interop {
            colorSpace = ColorSpace.Named.DISPLAY_P3
            sessionParameter[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = Range(60, 60)
            captureRequest[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = Range(60, 60)
            repeatingCaptureRequestTemplate = CameraDevice.TEMPLATE_PREVIEW
            repeatingCaptureCallback = object : CameraCaptureSession.CaptureCallback() {}
        }
        .build()
```

```kotlin
import androidx.camera.camera2.interop.camera2Interop
import androidx.camera.core.preview
import androidx.camera.core.sessionConfig

val sessionConfig =
    sessionConfig(listOf(preview)) {
        camera2Interop {
            colorSpace = ColorSpace.Named.DISPLAY_P3
            sessionParameter[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = Range(60, 60)
            captureRequest[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = Range(60, 60)
            repeatingCaptureRequestTemplate = CameraDevice.TEMPLATE_PREVIEW
            repeatingCaptureCallback = object : CameraCaptureSession.CaptureCallback() {}
        }
    }
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder` | this builder |

### SessionConfigScope.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/Camera2InteropEx.kt+function:camera2Interop) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
inline fun SessionConfigScope.camera2Interop(crossinline block: SessionConfigCamera2Interop.() -> Unit): Unit
```

Applies Camera2 options inside a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfigScope` DSL block.

Configures Camera2 options on the underlying `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig.Builder` within a `sessionConfig { ... }` DSL block.

```kotlin
import androidx.camera.camera2.interop.camera2Interop
import androidx.camera.core.preview
import androidx.camera.core.sessionConfig

val sessionConfig =
    sessionConfig(listOf(preview)) {
        camera2Interop {
            colorSpace = ColorSpace.Named.DISPLAY_P3
            sessionParameter[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = Range(60, 60)
            captureRequest[CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE] = Range(60, 60)
            repeatingCaptureRequestTemplate = CameraDevice.TEMPLATE_PREVIEW
            repeatingCaptureCallback = object : CameraCaptureSession.CaptureCallback() {}
        }
    }
```

| Parameters |
|---|---|
| `crossinline block: https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | configuration block setting Camera2 options on `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/SessionConfigCamera2Interop` |

### String.toCameraSelector

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/Camera2InteropEx.kt+function:toCameraSelector) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
fun String.toCameraSelector(): CameraSelector
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` | `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` matching this camera ID |

## Extension properties

### CameraInfo.cameraCharacteristics

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/Camera2InteropEx.kt+symbol:cameraCharacteristics) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
val CameraInfo.cameraCharacteristics: CameraCharacteristics
```

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if this `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` does not contain Camera2 information |

### CameraInfo.cameraId

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/Camera2InteropEx.kt+symbol:cameraId) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
val CameraInfo.cameraId: String
```

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if this `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` does not contain Camera2 information |