# CameraXDslUtils

Added in 1.7.0-rc02

*** ** * ** ***


```
public final class CameraXDslUtils
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/ImageAnalysis` | `https://developer.android.com/reference/androidx/camera/core/CameraXDslUtils#imageAnalysis(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/ImageAnalysisScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)` Creates an `https://developer.android.com/reference/androidx/camera/core/ImageAnalysis` using a Kotlin DSL block. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/ImageCapture` | `https://developer.android.com/reference/androidx/camera/core/CameraXDslUtils#imageCapture(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)` Creates an `https://developer.android.com/reference/androidx/camera/core/ImageCapture` using a Kotlin DSL block. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/Preview` | `https://developer.android.com/reference/androidx/camera/core/CameraXDslUtils#preview(kotlin.Function1)(@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/core/PreviewScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block)` Creates a `https://developer.android.com/reference/androidx/camera/core/Preview` using a Kotlin DSL block. |

## Public methods

### imageAnalysis

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

```
public static final @NonNull ImageAnalysis imageAnalysis(@NonNull Function1<@NonNull ImageAnalysisScope, Unit> block)
```

Creates an `https://developer.android.com/reference/androidx/camera/core/ImageAnalysis` using a Kotlin DSL block.

```kotlin
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageCapture
import androidx.camera.core.imageAnalysis
import androidx.camera.core.imageCapture
import androidx.camera.core.preview
import androidx.camera.core.resolutionselector.ResolutionSelector

// 1. Using the new Kotlin DSL to configure UseCases in a clean and idiomatic way
val previewUseCase = preview {
    targetName = "preview_dsl"
    targetRotation = Surface.ROTATION_90
    resolutionSelector = ResolutionSelector.Builder().build()
    isPreviewStabilizationEnabled = true
    targetFrameRate = Range(30, 30)
}

val imageCaptureUseCase = imageCapture {
    targetName = "capture_dsl"
    captureMode = ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY
    flashMode = ImageCapture.FLASH_MODE_AUTO
    jpegQuality = 95
}

val imageAnalysisUseCase = imageAnalysis {
    targetName = "analysis_dsl"
    backpressureStrategy = ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
    imageQueueDepth = 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/core/ImageAnalysisScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | A receiver lambda on `https://developer.android.com/reference/androidx/camera/core/ImageAnalysisScope` to configure the image analysis. |

### imageCapture

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

```
public static final @NonNull ImageCapture imageCapture(@NonNull Function1<@NonNull ImageCaptureScope, Unit> block)
```

Creates an `https://developer.android.com/reference/androidx/camera/core/ImageCapture` using a Kotlin DSL block.

```kotlin
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageCapture
import androidx.camera.core.imageAnalysis
import androidx.camera.core.imageCapture
import androidx.camera.core.preview
import androidx.camera.core.resolutionselector.ResolutionSelector

// 1. Using the new Kotlin DSL to configure UseCases in a clean and idiomatic way
val previewUseCase = preview {
    targetName = "preview_dsl"
    targetRotation = Surface.ROTATION_90
    resolutionSelector = ResolutionSelector.Builder().build()
    isPreviewStabilizationEnabled = true
    targetFrameRate = Range(30, 30)
}

val imageCaptureUseCase = imageCapture {
    targetName = "capture_dsl"
    captureMode = ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY
    flashMode = ImageCapture.FLASH_MODE_AUTO
    jpegQuality = 95
}

val imageAnalysisUseCase = imageAnalysis {
    targetName = "analysis_dsl"
    backpressureStrategy = ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
    imageQueueDepth = 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/core/ImageCaptureScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | A receiver lambda on `https://developer.android.com/reference/androidx/camera/core/ImageCaptureScope` to configure the image capture. |

### preview

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

```
public static final @NonNull Preview preview(@NonNull Function1<@NonNull PreviewScope, Unit> block)
```

Creates a `https://developer.android.com/reference/androidx/camera/core/Preview` using a Kotlin DSL block.

```kotlin
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageCapture
import androidx.camera.core.imageAnalysis
import androidx.camera.core.imageCapture
import androidx.camera.core.preview
import androidx.camera.core.resolutionselector.ResolutionSelector

// 1. Using the new Kotlin DSL to configure UseCases in a clean and idiomatic way
val previewUseCase = preview {
    targetName = "preview_dsl"
    targetRotation = Surface.ROTATION_90
    resolutionSelector = ResolutionSelector.Builder().build()
    isPreviewStabilizationEnabled = true
    targetFrameRate = Range(30, 30)
}

val imageCaptureUseCase = imageCapture {
    targetName = "capture_dsl"
    captureMode = ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY
    flashMode = ImageCapture.FLASH_MODE_AUTO
    jpegQuality = 95
}

val imageAnalysisUseCase = imageAnalysis {
    targetName = "analysis_dsl"
    backpressureStrategy = ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
    imageQueueDepth = 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/core/PreviewScope, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block` | A receiver lambda on `https://developer.android.com/reference/androidx/camera/core/PreviewScope` to configure the preview. |