# 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
public final class ImageCaptureScope
```

<br />

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getCaptureMode()()` Sets or gets the capture mode for this use case. |
| `final int` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getFlashMode()()` Sets or gets the flash mode for this use case. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getIoExecutor()()` Sets or gets the background executor for I/O tasks. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1, to = 100) int` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getJpegQuality()()` Sets or gets the JPEG quality for this use case. |
| `final int` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getOutputFormat()()` Sets or gets the output format for this use case. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getPostviewResolutionSelector()()` Sets or gets the resolution selector for postview images. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getResolutionSelector()()` Sets or gets the resolution selector for this use case. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/camera/core/ImageCapture.ScreenFlash` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getScreenFlash()()` Sets or gets the ScreenFlash implementation for this use case. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getTargetName()()` Sets or gets the target name for this use case configuration. |
| `final int` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#getTargetRotation()()` Sets or gets the target rotation for this use case. |
| `final boolean` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#isPostviewEnabled()()` Sets or gets whether postview is enabled for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setCaptureMode(kotlin.Int)(int value)` Sets or gets the capture mode for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setFlashMode(kotlin.Int)(int value)` Sets or gets the flash mode for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setIoExecutor(java.util.concurrent.Executor)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html value)` Sets or gets the background executor for I/O tasks. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setJpegQuality(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1, to = 100) int value)` Sets or gets the JPEG quality for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setOutputFormat(kotlin.Int)(int value)` Sets or gets the output format for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setPostviewEnabled(kotlin.Boolean)(boolean value)` Sets or gets whether postview is enabled for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setPostviewResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector value)` Sets or gets the resolution selector for postview images. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/resolutionselector/ResolutionSelector value)` Sets or gets the resolution selector for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)(https://developer.android.com/reference/androidx/camera/core/ImageCapture.ScreenFlash value)` Sets or gets the ScreenFlash implementation for this use case. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setTargetName(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Sets or gets the target name for this use case configuration. |
| `final void` | `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#setTargetRotation(kotlin.Int)(int value)` Sets or gets the target rotation for this use case. |

| ### Extension functions |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/camera/core/Camera2InteropEx.https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope#(androidx.camera.core.ImageCaptureScope).camera2Interop(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/camera2/interop/ImageCaptureCamera2Interop, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block )` Applies Camera2 options inside an `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope` DSL block. |

## Public methods

### getCaptureMode

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

```
public final int getCaptureMode()
```

Sets or gets the capture mode for this use case.

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

### getFlashMode

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

```
public final int getFlashMode()
```

Sets or gets the flash mode for this use case.

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

### getIoExecutor

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

```
public final @NonNull Executor getIoExecutor()
```

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

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

### getJpegQuality

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

```
public final @IntRange(from = 1, to = 100) int getJpegQuality()
```

Sets or gets the JPEG quality for this use case.

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

### getOutputFormat

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

```
public final int getOutputFormat()
```

Sets or gets the output format for this use case.

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

### getPostviewResolutionSelector

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

```
public final @NonNull ResolutionSelector getPostviewResolutionSelector()
```

Sets or gets the resolution selector for postview images.

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

### getResolutionSelector

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

```
public final @NonNull ResolutionSelector getResolutionSelector()
```

Sets or gets the resolution selector for this use case.

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

### getScreenFlash

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

```
public final @Nullable ImageCapture.ScreenFlash getScreenFlash()
```

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/androidx/camera/core/ImageCapture.Builder` because `https://developer.android.com/reference/androidx/camera/core/ImageCapture.Builder#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)` requires a non-null `https://developer.android.com/reference/androidx/camera/core/ImageCapture.ScreenFlash`.

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

### getTargetName

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

```
public final @NonNull String getTargetName()
```

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

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

### getTargetRotation

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

```
public final int getTargetRotation()
```

Sets or gets the target rotation for this use case.

Value is one of the following:

- `Surface.ROTATION_0`
- `Surface.ROTATION_90`
- `Surface.ROTATION_180`
- `Surface.ROTATION_270`

<br />

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

### isPostviewEnabled

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

```
public final boolean isPostviewEnabled()
```

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

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

### setCaptureMode

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

```
public final void setCaptureMode(int value)
```

Sets or gets the capture mode for this use case.

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

### setFlashMode

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

```
public final void setFlashMode(int value)
```

Sets or gets the flash mode for this use case.

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

### setIoExecutor

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

```
public final void setIoExecutor(@NonNull Executor value)
```

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

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

### setJpegQuality

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

```
public final void setJpegQuality(@IntRange(from = 1, to = 100) int value)
```

Sets or gets the JPEG quality for this use case.

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

### setOutputFormat

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

```
public final void setOutputFormat(int value)
```

Sets or gets the output format for this use case.

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

### setPostviewEnabled

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

```
public final void setPostviewEnabled(boolean value)
```

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

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

### setPostviewResolutionSelector

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

```
public final void setPostviewResolutionSelector(@NonNull ResolutionSelector value)
```

Sets or gets the resolution selector for postview images.

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

### setResolutionSelector

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

```
public final void setResolutionSelector(@NonNull ResolutionSelector value)
```

Sets or gets the resolution selector for this use case.

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

### setScreenFlash

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

```
public final void setScreenFlash(ImageCapture.ScreenFlash value)
```

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/androidx/camera/core/ImageCapture.Builder` because `https://developer.android.com/reference/androidx/camera/core/ImageCapture.Builder#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)` requires a non-null `https://developer.android.com/reference/androidx/camera/core/ImageCapture.ScreenFlash`.

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

### setTargetName

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

```
public final void setTargetName(@NonNull String value)
```

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

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

### setTargetRotation

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

```
public final void setTargetRotation(int value)
```

Sets or gets the target rotation for this use case.

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

## Extension functions

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

```
public final void Camera2InteropEx.camera2Interop(
    @NonNull ImageCaptureScope receiver,
    @NonNull Function1<@NonNull ImageCaptureCamera2Interop, Unit> block
)
```

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

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

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

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

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

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

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

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

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

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

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

- Still capture callbacks (`https://developer.android.com/reference/androidx/camera/camera2/interop/StillCaptureInterop#setStillCaptureCallback(java.util.concurrent.Executor,android.hardware.camera2.CameraCaptureSession.CaptureCallback)` or `https://developer.android.com/reference/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/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/androidx/camera/core/SessionConfig.Builder#setInterop(androidx.camera.core.InteropConfigurator)` or `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/camera2/interop/ImageCaptureCamera2Interop, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | configuration block setting Camera2 options on `https://developer.android.com/reference/androidx/camera/camera2/interop/ImageCaptureCamera2Interop` |