# ImageCaptureScope

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

*** ** * ** ***


```
@CameraXDsl
class ImageCaptureScope
```

<br />

*** ** * ** ***

Scope class for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` configuration DSL.

## Summary

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#captureMode()` Sets or gets the capture mode for this use case. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#flashMode()` Sets or gets the flash mode for this use case. |
| `https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#ioExecutor()` Sets or gets the background executor for I/O tasks. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#isPostviewEnabled()` Sets or gets whether postview is enabled for this use case. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#jpegQuality()` Sets or gets the JPEG quality for this use case. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#outputFormat()` Sets or gets the output format for this use case. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#postviewResolutionSelector()` Sets or gets the resolution selector for postview images. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#resolutionSelector()` Sets or gets the resolution selector for this use case. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash?` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#screenFlash()` Sets or gets the ScreenFlash implementation for this use case. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#targetName()` Sets or gets the target name for this use case configuration. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureScope#targetRotation()` Sets or gets the target rotation for this use case. |

| ### Extension functions |
|---|---|
| `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/core/ImageCaptureScope#(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. |

## Public properties

### captureMode

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

```
var captureMode: Int
```

Sets or gets the capture mode for this use case.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setCaptureMode(int)` |   |

### flashMode

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

```
var flashMode: Int
```

Sets or gets the flash mode for this use case.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setFlashMode(int)` |   |

### ioExecutor

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

```
var ioExecutor: Executor
```

Sets or gets the background executor for I/O tasks.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setIoExecutor(java.util.concurrent.Executor)` |   |

### isPostviewEnabled

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

```
var isPostviewEnabled: Boolean
```

Sets or gets whether postview is enabled for this use case.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setPostviewEnabled(boolean)` |   |

### jpegQuality

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

```
var jpegQuality: Int
```

Sets or gets the JPEG quality for this use case.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setJpegQuality(int)` |   |

### outputFormat

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

```
var outputFormat: Int
```

Sets or gets the output format for this use case.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setOutputFormat(int)` |   |

### postviewResolutionSelector

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

```
var postviewResolutionSelector: ResolutionSelector
```

Sets or gets the resolution selector for postview images.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setPostviewResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` |   |

### resolutionSelector

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

```
var resolutionSelector: ResolutionSelector
```

Sets or gets the resolution selector for this use case.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` |   |

### screenFlash

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

```
var screenFlash: ImageCapture.ScreenFlash?
```

Sets or gets the ScreenFlash implementation for this use case.

Note: Setting this property to `null` is a no-op on the underlying `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder` because `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)` requires a non-null `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)` |   |

### targetName

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

```
var targetName: String
```

Sets or gets the target name for this use case configuration.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setTargetName(java.lang.String)` |   |

### targetRotation

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

```
var targetRotation: Int
```

Sets or gets the target rotation for this use case.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setTargetRotation(int)` |   |

## Extension functions

### 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)

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