# CameraController

Artifact: [androidx.camera:camera-view](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/view/CameraController.java+class:androidx.camera.view.CameraController) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

*** ** * ** ***


```
abstract class CameraController
```

<br />

Known direct subclasses [LifecycleCameraController](https://developer.android.com/reference/kotlin/androidx/camera/view/LifecycleCameraController)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/view/LifecycleCameraController` | A controller that provides most of the CameraX features. |

*** ** * ** ***

The abstract base camera controller class.

This a high level controller that provides most of the CameraX core features in a single class. It handles camera initialization, creates and configures `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`s. It also listens to device motion sensor and set the target rotation for the use cases.

The controller is required to be used with a `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`. `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` provides the UI elements to display camera preview. The layout of the `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` is used to set the crop rect so the output from other use cases matches the preview display in a WYSIWYG way. The controller also listens to `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`'s touch events to handle tap-to-focus and pinch-to-zoom features.

This class provides features of 4 `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`s: `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` and `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapture`. `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview` is required and always enabled. `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` are enabled by default. The video capture is disabled by default because it might affect other use cases, especially on lower end devices. It might be necessary to disable `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` and/or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` before the video capture feature can be enabled. Disabling/enabling `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`s freezes the preview for a short period of time. To avoid the glitch, the `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`s need to be enabled/disabled before the controller is set on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`.

There are two main approaches to configure the `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController`:

1. **Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setEnabledUseCases(int)`** : This is for basic usage scenarios. The `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController` will manage the `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` lifecycles and configurations for you. You can enable or disable features like image capture, image analysis, and video capture as needed.
2. **Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setSessionConfig(androidx.camera.core.SessionConfig,androidx.camera.core.CameraSelector)`** : This approach is for apps where the methods exposed from the CameraController can't fulfill their requirements. Apps can use this to configure the UseCases via SessionConfig and then they can access those methods via the UseCases directly. If apps need to access many advanced methods from UseCases that are not exposed from the CameraController, it is recommended to directly use UseCases, PreviewView and setViewPort to do the implementation. When using this approach, a `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview` use case is mandatory.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize` **This class is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` instead. <br /> |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#COORDINATE_SYSTEM_VIEW_REFERENCED() = 1` **This property is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#COORDINATE_SYSTEM_VIEW_REFERENCED()` instead. <br /> |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#IMAGE_ANALYSIS() = 2` Bitmask option to enable `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#IMAGE_CAPTURE() = 1` Bitmask option to enable `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#TAP_TO_FOCUS_FAILED() = 4` The previous tap-to-focus action was failed to complete. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#TAP_TO_FOCUS_FOCUSED() = 2` The previous tap-to-focus action was completed successfully and the camera is focused. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#TAP_TO_FOCUS_NOT_FOCUSED() = 3` The previous tap-to-focus action was completed successfully but the camera is still unfocused, similar to the `https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#CONTROL_AF_STATE_NOT_FOCUSED_LOCKED` state. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#TAP_TO_FOCUS_NOT_STARTED() = 0` No tap-to-focus action has been started by the end user. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#TAP_TO_FOCUS_STARTED() = 1` A tap-to-focus action has started but not completed. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE() = 4` Bitmask option to enable video capture use case. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#clearEffects()()` Removes all effects. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#clearImageAnalysisAnalyzer()()` Removes a previously set analyzer. |
| `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/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#enableTorch(boolean)(torchEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Enable the torch or disable the torch. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getCameraControl()()` Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl` of the currently attached camera. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getCameraInfo()()` Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` of the currently attached camera. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getCameraSelector()()` Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector`. |
| `https://developer.android.com/reference/java/util/concurrent/Executor.html?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisBackgroundExecutor()()` Gets the default executor for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` background tasks. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisBackpressureStrategy()()` Returns the mode with which images are acquired. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisImageQueueDepth()()` Gets the image queue depth of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisOutputImageFormat()()` Gets the output image format for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisResolutionSelector()()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread [getImageAnalysisTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisTargetSize())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisResolutionSelector()` instead. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureFlashMode()()` Gets the flash mode for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |
| `https://developer.android.com/reference/java/util/concurrent/Executor.html?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureIoExecutor()()` Gets the default executor for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` IO tasks. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureMode()()` Returns the image capture mode. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureResolutionSelector()()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread [getImageCaptureTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureTargetSize())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureResolutionSelector()` instead. <br /> |
| `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/view/CameraController#getInitializationFuture()()` Gets a `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` that completes when camera initialization completes. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getPreviewResolutionSelector()()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread [getPreviewTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getPreviewTargetSize())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getPreviewResolutionSelector()` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData<https://developer.android.com/reference/kotlin/androidx/camera/view/TapToFocusInfo!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTapToFocusInfoState()()` Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` with a `https://developer.android.com/reference/kotlin/androidx/camera/view/TapToFocusInfo` containing the latest focus state and corresponding tap position. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread [getTapToFocusState](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTapToFocusState())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTapToFocusInfoState()` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTorchState()()` Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` of current `https://developer.android.com/reference/kotlin/androidx/camera/core/TorchState`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getVideoCaptureDynamicRange()()` Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange` for video capture. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getVideoCaptureMirrorMode()()` Gets the mirror mode for video capture. |
| `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getVideoCaptureQualitySelector()()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` for `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()`. |
| `https://developer.android.com/reference/android/util/Range.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getVideoCaptureTargetFrameRate()()` Gets the target frame rate in frames per second for video capture. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData<https://developer.android.com/reference/kotlin/androidx/camera/core/ZoomState!>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getZoomState()()` Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` of `https://developer.android.com/reference/kotlin/androidx/camera/core/ZoomState`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#hasCamera(androidx.camera.core.CameraSelector)(cameraSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector)` Checks if the given `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` can be resolved to a camera. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isAutoRotationEnabled()()` Returns whether auto-rotation is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isImageAnalysisEnabled()()` Checks if `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isImageCaptureEnabled()()` Checks if `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isPinchToZoomEnabled()()` Returns whether pinch-to-zoom is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isRecording()()` Returns whether there is an in-progress video recording. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isTapToFocusEnabled()()` Returns whether tap-to-focus is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isVideoCaptureEnabled()()` Checks if video capture is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setAutoRotationEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to enable auto-rotation. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setCameraSelector(androidx.camera.core.CameraSelector)(cameraSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector)` Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setEffects(java.util.Set<androidx.camera.core.CameraEffect>)(effects: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/camera/core/CameraEffect!>)` Sets `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraEffect`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setEnabledUseCases(int)(enabledUseCases: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Enables or disables use cases. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisAnalyzer(java.util.concurrent.Executor,androidx.camera.core.ImageAnalysis.Analyzer)( executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, analyzer: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer )` Sets an analyzer to receive and analyze images. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisBackgroundExecutor(java.util.concurrent.Executor)(executor: https://developer.android.com/reference/java/util/concurrent/Executor.html?)` Sets the executor that will be used for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` background tasks. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisBackpressureStrategy(int)(strategy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the backpressure strategy to apply to the image producer to deal with scenarios where images may be produced faster than they can be analyzed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisImageQueueDepth(int)(depth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the image queue depth of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisOutputImageFormat(int)(imageAnalysisOutputImageFormat: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the output image format for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)( resolutionSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector? )` Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread [setImageAnalysisTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisTargetSize(androidx.camera.view.CameraController.OutputSize))(targetSize: https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` instead. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureFlashMode(int)(flashMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the flash mode for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureIoExecutor(java.util.concurrent.Executor)(executor: https://developer.android.com/reference/java/util/concurrent/Executor.html?)` Sets the default executor that will be used for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` IO tasks. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureMode(int)(captureMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the image capture mode. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)( resolutionSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector? )` Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread [setImageCaptureTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureTargetSize(androidx.camera.view.CameraController.OutputSize))(targetSize: https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` instead. <br /> |
| `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/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setLinearZoom(float)(linearZoom: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Sets current zoom by a linear zoom value ranging from 0f to 1.0f. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPinchToZoomEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Enables/disables pinch-to-zoom. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPreviewResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)(resolutionSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector?)` Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread [setPreviewTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPreviewTargetSize(androidx.camera.view.CameraController.OutputSize))(targetSize: https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPreviewResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` instead. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setSessionConfig(androidx.camera.core.SessionConfig,androidx.camera.core.CameraSelector)( sessionConfig: https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig, cameraSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector )` Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` with the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` for the CameraController. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setTapToFocusAutoCancelDuration(long,java.util.concurrent.TimeUnit)( duration: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, timeUnit: https://developer.android.com/reference/java/util/concurrent/TimeUnit.html )` Sets the auto-cancel duration for tap-to-focus events. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setTapToFocusEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Enables/disables tap-to-focus. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setVideoCaptureDynamicRange(androidx.camera.core.DynamicRange)(dynamicRange: https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange)` Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange` for video capture. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setVideoCaptureMirrorMode(int)(mirrorMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the mirror mode for video capture. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setVideoCaptureQualitySelector(androidx.camera.video.QualitySelector)(qualitySelector: https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector)` Sets the `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` for `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setVideoCaptureTargetFrameRate(android.util.Range<java.lang.Integer>)(targetFrameRate: https://developer.android.com/reference/android/util/Range.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>)` Sets the target frame rate range in frames per second for video capture. |
| `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/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setZoomRatio(float)(zoomRatio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Sets current zoom by ratio. |
| `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) @https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#startRecording(androidx.camera.video.FileDescriptorOutputOptions,androidx.camera.view.video.AudioConfig,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.video.VideoRecordEvent>)( outputOptions: https://developer.android.com/reference/kotlin/androidx/camera/video/FileDescriptorOutputOptions, audioConfig: https://developer.android.com/reference/kotlin/androidx/camera/view/video/AudioConfig, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent!> )` Takes a video to a given file descriptor. |
| `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#startRecording(androidx.camera.video.FileOutputOptions,androidx.camera.view.video.AudioConfig,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.video.VideoRecordEvent>)( outputOptions: https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions, audioConfig: https://developer.android.com/reference/kotlin/androidx/camera/view/video/AudioConfig, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent!> )` Takes a video to a given file. |
| `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#startRecording(androidx.camera.video.MediaStoreOutputOptions,androidx.camera.view.video.AudioConfig,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.video.VideoRecordEvent>)( outputOptions: https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions, audioConfig: https://developer.android.com/reference/kotlin/androidx/camera/view/video/AudioConfig, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent!> )` Takes a video to MediaStore. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)( executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback )` Captures a new still image for in memory access. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageSavedCallback)( outputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, imageSavedCallback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback )` Captures a new still image and saves to a file along with application specified metadata. |

## Constants

### COORDINATE_SYSTEM_VIEW_REFERENCED

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
const val COORDINATE_SYSTEM_VIEW_REFERENCED = 1: Int
```

> [!CAUTION]
> **This property is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#COORDINATE_SYSTEM_VIEW_REFERENCED()` instead.

`https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer` option for returning `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` coordinates.

When the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer` is configured with this option, it will receive a `https://developer.android.com/reference/android/graphics/Matrix.html` that will receive a value that represents the transformation from camera sensor to the `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`, which can be used for highlighting detected result in `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`. For example, laying over a bounding box on top of the detected face.

Note this option only works if the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer` is set via `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisAnalyzer(java.util.concurrent.Executor,androidx.camera.core.ImageAnalysis.Analyzer)`. It will not be effective when used with camera-core directly.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer` |   |

### IMAGE_ANALYSIS

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

```
const val IMAGE_ANALYSIS = 2: Int
```

Bitmask option to enable `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. In `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setEnabledUseCases(int)`, if `(enabledUseCases & IMAGE_ANALYSIS) != 0`, then controller will enable image analysis features.

### IMAGE_CAPTURE

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

```
const val IMAGE_CAPTURE = 1: Int
```

Bitmask option to enable `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. In `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setEnabledUseCases(int)`, if `(enabledUseCases & IMAGE_CAPTURE) != 0`, then controller will enable image capture features.

### TAP_TO_FOCUS_FAILED

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

```
const val TAP_TO_FOCUS_FAILED = 4: Int
```

The previous tap-to-focus action was failed to complete. This is usually due to device limitations.

### TAP_TO_FOCUS_FOCUSED

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

```
const val TAP_TO_FOCUS_FOCUSED = 2: Int
```

The previous tap-to-focus action was completed successfully and the camera is focused.

### TAP_TO_FOCUS_NOT_FOCUSED

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

```
const val TAP_TO_FOCUS_NOT_FOCUSED = 3: Int
```

The previous tap-to-focus action was completed successfully but the camera is still unfocused, similar to the `https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#CONTROL_AF_STATE_NOT_FOCUSED_LOCKED` state. The end user might be able to get a better result by trying again with different camera distances and/or lighting.

### TAP_TO_FOCUS_NOT_STARTED

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

```
const val TAP_TO_FOCUS_NOT_STARTED = 0: Int
```

No tap-to-focus action has been started by the end user.

### TAP_TO_FOCUS_STARTED

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

```
const val TAP_TO_FOCUS_STARTED = 1: Int
```

A tap-to-focus action has started but not completed. The app also gets notified with this state if a new action happens before the previous one could finish.

### VIDEO_CAPTURE

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

```
const val VIDEO_CAPTURE = 4: Int
```

Bitmask option to enable video capture use case. In `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setEnabledUseCases(int)`, if `(enabledUseCases & VIDEO_CAPTURE) != 0`, then controller will enable video capture features.

## Public functions

### clearEffects

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

```
@MainThread
fun clearEffects(): Unit
```

Removes all effects.

Once called, CameraX will remove all the effects and rebind the `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

### clearImageAnalysisAnalyzer

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

```
@MainThread
fun clearImageAnalysisAnalyzer(): Unit
```

Removes a previously set analyzer.

This will stop data from streaming to the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

If the current `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer#getDefaultTargetResolution()` returns non-null value, calling this method will reconfigure the camera which might cause additional latency. To avoid this, call this method when the lifecycle is not active.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#clearAnalyzer()` |   |

### enableTorch

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

```
@MainThread
fun enableTorch(torchEnabled: Boolean): ListenableFuture<Void!>
```

Enable the torch or disable the torch.

If the value is set before the camera is ready, `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController` waits for the camera to be ready and then enables the torch.

| Parameters |
|---|---|
| `torchEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` to turn on the torch, `false` to turn it off. |

| 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!>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` which is successful when the torch was changed to the value specified. It fails when it is unable to change the torch state. Cancellation of this future is a no-op. |

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

### getCameraControl

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

```
@MainThread
fun getCameraControl(): CameraControl?
```

Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl` of the currently attached camera.

For controls available directly through CameraController as well as `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl`, it's recommended to use the ones with CameraController, e.g. `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setLinearZoom(float)` v.s. `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#setLinearZoom(float)`. CameraControl is a lower-layer API and may require more steps to achieve the same effect, and will not maintain control values when switching between cameras.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl?` | The `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl` of the current camera. Returns `null` if camera is not ready. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/Camera#getCameraControl()` |   |

### getCameraInfo

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

```
@MainThread
fun getCameraInfo(): CameraInfo?
```

Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` of the currently attached camera.

For info available directly through CameraController as well as `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`, it's recommended to use the ones with CameraController, e.g. `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTorchState()` v.s. `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#getTorchState()`. `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` is a lower-layer API and may require more steps to achieve the same effect, and will not maintain values when switching between cameras.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo?` | The `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` of the current camera. Returns `null` if camera is not ready. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/Camera#getCameraInfo()` |   |

### getCameraSelector

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

```
@MainThread
fun getCameraSelector(): CameraSelector
```

Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector`.

The default value is`https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector#DEFAULT_BACK_CAMERA()`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` |   |

### getImageAnalysisBackgroundExecutor

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

```
@MainThread
fun getImageAnalysisBackgroundExecutor(): Executor?
```

Gets the default executor for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` background tasks.

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

### getImageAnalysisBackpressureStrategy

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

```
@MainThread
fun getImageAnalysisBackpressureStrategy(): Int
```

Returns the mode with which images are acquired.

If not set, it defaults to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_KEEP_ONLY_LATEST()`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The backpressure strategy applied to the image producer. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#getBackpressureStrategy()` |   |

### getImageAnalysisImageQueueDepth

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

```
@MainThread
fun getImageAnalysisImageQueueDepth(): Int
```

Gets the image queue depth of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#getImageQueueDepth()` |   |

### getImageAnalysisOutputImageFormat

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

```
@MainThread
fun getImageAnalysisOutputImageFormat(): Int
```

Gets the output image format for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

The returned image format can be either `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_YUV_420_888()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_RGBA_8888()` or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_NV21()`.

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

### getImageAnalysisResolutionSelector

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

```
@MainThread
fun getImageAnalysisResolutionSelector(): ResolutionSelector?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

This method returns the value set by `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)`. It returns `null` if the value has not been set.

### getImageAnalysisTargetSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@MainThread
fun [getImageAnalysisTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisTargetSize())(): CameraController.OutputSize?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageAnalysisResolutionSelector()` instead.

Returns the intended output size for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` set by `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisTargetSize(androidx.camera.view.CameraController.OutputSize)`, or `null` if not set.

### getImageCaptureFlashMode

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

```
@MainThread
fun getImageCaptureFlashMode(): Int
```

Gets the flash mode for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the flashMode. Value is `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_AUTO()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_ON()`, or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_OFF()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` |   |

### getImageCaptureIoExecutor

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

```
@MainThread
fun getImageCaptureIoExecutor(): Executor?
```

Gets the default executor for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` IO tasks.

### getImageCaptureMode

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

```
@MainThread
fun getImageCaptureMode(): Int
```

Returns the image capture mode.

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

### getImageCaptureResolutionSelector

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

```
@MainThread
fun getImageCaptureResolutionSelector(): ResolutionSelector?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`.

This method returns the value set by `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` (ResolutionSelector)}. It returns `null` if the value has not been set.

### getImageCaptureTargetSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@MainThread
fun [getImageCaptureTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureTargetSize())(): CameraController.OutputSize?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getImageCaptureResolutionSelector()` instead.

Returns the intended output size for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` set by `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureTargetSize(androidx.camera.view.CameraController.OutputSize)`, or `null` if not set.

### getInitializationFuture

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

```
fun getInitializationFuture(): ListenableFuture<Void!>
```

Gets a `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` that completes when camera initialization completes.

This future may fail with an `https://developer.android.com/reference/kotlin/androidx/camera/core/InitializationException` and associated cause that can be retrieved by `https://developer.android.com/reference/java/lang/Throwable.html#getCause()`. The cause will be a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException` if it fails to access any camera during initialization.

In the rare case that the future fails with `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraUnavailableException`, the camera will become unusable. This could happen for various reasons, for example hardware failure or the camera being held by another process. If the failure is temporary, killing and restarting the app might fix the issue.

The initialization also try to bind use cases before completing the `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html`. The `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` will complete successfully regardless of whether the use cases are ready to be bound, e.g. it will complete successfully even if the controller is not set on a `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`. However the `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` will fail if the enabled use cases are not supported by the current camera.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/lifecycle/ProcessCameraProvider#getInstance(android.content.Context)` |   |

### getPreviewResolutionSelector

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

```
@MainThread
fun getPreviewResolutionSelector(): ResolutionSelector?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`.

This method returns the value set by `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPreviewResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)`. It returns `null` if the value has not been set.

### getPreviewTargetSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@MainThread
fun [getPreviewTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getPreviewTargetSize())(): CameraController.OutputSize?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getPreviewResolutionSelector()` instead.

Returns the intended output size for `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview` set by `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPreviewTargetSize(androidx.camera.view.CameraController.OutputSize)`, or `null` if not set.

### getTapToFocusInfoState

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

```
@MainThread
fun getTapToFocusInfoState(): LiveData<TapToFocusInfo!>
```

Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` with a `https://developer.android.com/reference/kotlin/androidx/camera/view/TapToFocusInfo` containing the latest focus state and corresponding tap position.

When tap-to-focus feature is enabled, the `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` will receive updates of focusing states. This usually happens when the end user taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`, and then again when focusing is finished either successfully or unsuccessfully. The following table displays the states the `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` can be in, and the possible transitions between them.

| State | Transition cause | New State |
|---|---|---|
| TAP_TO_FOCUS_NOT_STARTED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_FOCUSED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_NOT_FOCUSED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_FAILED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_STARTED | Focusing succeeded | TAP_TO_FOCUS_FOCUSED |
| Focusing failed due to lighting and/or camera distance | TAP_TO_FOCUS_NOT_FOCUSED |
| Focusing failed due to device constraints | TAP_TO_FOCUS_FAILED |
| TAP_TO_FOCUS_FOCUSED | Auto-cancel duration elapses | TAP_TO_FOCUS_NOT_STARTED |
| TAP_TO_FOCUS_NOT_FOCUSED | Auto-cancel duration elapses | TAP_TO_FOCUS_NOT_STARTED |
| TAP_TO_FOCUS_FAILED | Auto-cancel duration elapses | TAP_TO_FOCUS_NOT_STARTED |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setTapToFocusEnabled(boolean)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#startFocusAndMetering(androidx.camera.core.FocusMeteringAction)` |   |

### getTapToFocusState

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
@MainThread
fun [getTapToFocusState](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTapToFocusState())(): LiveData<Int!>
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTapToFocusInfoState()` instead.

Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` with the latest tap-to-focus state.

When tap-to-focus feature is enabled, the `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` will receive updates of focusing states. This happens when the end user taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`, and then again when focusing is finished either successfully or unsuccessfully. The following table displays the states the `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` can be in, and the possible transitions between them.

| State | Transition cause | New State |
|---|---|---|
| TAP_TO_FOCUS_NOT_STARTED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_FOCUSED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_NOT_FOCUSED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_FAILED | User taps on `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` | TAP_TO_FOCUS_STARTED |
| TAP_TO_FOCUS_STARTED | Focusing succeeded | TAP_TO_FOCUS_FOCUSED |
| Focusing failed due to lighting and/or camera distance | TAP_TO_FOCUS_NOT_FOCUSED |
| Focusing failed due to device constraints | TAP_TO_FOCUS_FAILED |
| TAP_TO_FOCUS_FOCUSED | Auto-cancel duration elapses | TAP_TO_FOCUS_NOT_STARTED |
| TAP_TO_FOCUS_NOT_FOCUSED | Auto-cancel duration elapses | TAP_TO_FOCUS_NOT_STARTED |
| TAP_TO_FOCUS_FAILED | Auto-cancel duration elapses | TAP_TO_FOCUS_NOT_STARTED |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setTapToFocusEnabled(boolean)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#startFocusAndMetering(androidx.camera.core.FocusMeteringAction)` |   |

### getTorchState

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

```
@MainThread
fun getTorchState(): LiveData<Int!>
```

Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` of current `https://developer.android.com/reference/kotlin/androidx/camera/core/TorchState`.

The torch can be turned on and off via `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#enableTorch(boolean)` which will trigger the change event to the returned `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>` | A `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` containing current torch state. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#getTorchState()` |   |

### getVideoCaptureDynamicRange

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

```
@MainThread
fun getVideoCaptureDynamicRange(): DynamicRange
```

Gets the `https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange` for video capture.

### getVideoCaptureMirrorMode

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

```
@MainThread
fun getVideoCaptureMirrorMode(): Int
```

Gets the mirror mode for video capture.

### getVideoCaptureQualitySelector

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

```
@MainThread
fun getVideoCaptureQualitySelector(): QualitySelector
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` for `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` | the `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` provided to `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setVideoCaptureQualitySelector(androidx.camera.video.QualitySelector)` or the default value of `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder#DEFAULT_QUALITY_SELECTOR()` if no quality selector was provided. |

### getVideoCaptureTargetFrameRate

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

```
@MainThread
fun getVideoCaptureTargetFrameRate(): Range<Int!>
```

Gets the target frame rate in frames per second for video capture.

### getZoomState

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

```
@MainThread
fun getZoomState(): LiveData<ZoomState!>
```

Returns a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LiveData` of `https://developer.android.com/reference/kotlin/androidx/camera/core/ZoomState`.

The LiveData will be updated whenever the set zoom state has been changed. This can occur when the application updates the zoom via `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setZoomRatio(float)` or `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setLinearZoom(float)`. The zoom state can also change anytime a camera starts up, for example when `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setCameraSelector(androidx.camera.core.CameraSelector)` is called.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#getZoomState()` |   |

### hasCamera

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

```
@MainThread
fun hasCamera(cameraSelector: CameraSelector): Boolean
```

Checks if the given `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` can be resolved to a camera.

Use this method to check if the device has the given camera.

Only call this method after camera is initialized. e.g. after the `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` from `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getInitializationFuture()` is finished. Calling it prematurely throws `https://developer.android.com/reference/java/lang/IllegalStateException.html`. Example:

```kotlin
controller.getInitializationFuture().addListener(() -> {
    if (controller.hasCamera(cameraSelector)) {
        controller.setCameraSelector(cameraSelector);
    } else {
        // Update UI if the camera is not available.
    }
    // Attach PreviewView after we know the camera is available.
    previewView.setController(controller);
}, ContextCompat.getMainExecutor(requireContext()));
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` can be resolved to a camera. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the camera is not initialized. |

### isAutoRotationEnabled

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

```
@MainThread
fun isAutoRotationEnabled(): Boolean
```

Returns whether auto-rotation is enabled.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if auto-rotation is enabled, `false` otherwise. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setAutoRotationEnabled(boolean)` |   |

### isImageAnalysisEnabled

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

```
@MainThread
fun isImageAnalysisEnabled(): Boolean
```

Checks if `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` is enabled.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` |   |

### isImageCaptureEnabled

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

```
@MainThread
fun isImageCaptureEnabled(): Boolean
```

Checks if `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` is enabled.

`https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` is enabled by default. It has to be enabled before `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageSavedCallback)` can be called.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` |   |

### isPinchToZoomEnabled

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

```
@MainThread
fun isPinchToZoomEnabled(): Boolean
```

Returns whether pinch-to-zoom is enabled.

By default pinch-to-zoom is enabled.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if pinch-to-zoom is enabled. |

### isRecording

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

```
@MainThread
fun isRecording(): Boolean
```

Returns whether there is an in-progress video recording.

### isTapToFocusEnabled

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

```
@MainThread
fun isTapToFocusEnabled(): Boolean
```

Returns whether tap-to-focus is enabled.

By default tap-to-focus is enabled.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if tap-to-focus is enabled. |

### isVideoCaptureEnabled

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

```
@MainThread
fun isVideoCaptureEnabled(): Boolean
```

Checks if video capture is enabled.

Video capture is disabled by default. It has to be enabled before `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#startRecording(androidx.camera.video.FileOutputOptions,androidx.camera.view.video.AudioConfig,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.video.VideoRecordEvent>)` can be called.

### setAutoRotationEnabled

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

```
@MainThread
fun setAutoRotationEnabled(enabled: Boolean): Unit
```

Sets whether to enable auto-rotation.

When enabled, `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController` will monitor the device rotation changes and set the target rotation for non-preview use cases (e.g. image capture, video capture, and image analysis). This ensures the output images/videos are oriented correctly relative to the device.

Auto-rotation is enabled by default.

If a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` is set via `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setSessionConfig(androidx.camera.core.SessionConfig,androidx.camera.core.CameraSelector)`, the auto-rotation setting in the provided `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` will be overridden by the state of this controller.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to the lifecycle.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` to enable auto-rotation, `false` to disable. |

### setCameraSelector

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

```
@MainThread
fun setCameraSelector(cameraSelector: CameraSelector): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector`.

Calling this method with a `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` that resolves to a different camera will change the camera being used by the controller. If camera initialization is complete, the controller will immediately rebind use cases with the new `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector`; otherwise, the new `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` will be used when the camera becomes ready.

The default value is `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector#DEFAULT_BACK_CAMERA()`.

If a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` with advanced settings is set, it might only be supported on specific camera devices, it is recommended to check whether it can be supported via `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#isSessionConfigSupported(androidx.camera.core.SessionConfig)` before switching the camera selector. It is also recommended to use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setSessionConfig(androidx.camera.core.SessionConfig,androidx.camera.core.CameraSelector)` to switch camera with SessionConfig in one function call, in case the camera resolved by the new CameraSelector can't support current SessionConfig and then make the camera switching operation failed.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the provided camera selector is unable to resolve a camera to be used for the enabled use cases. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` |   |

### setEffects

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

```
@MainThread
fun setEffects(effects: (Mutable)Set<CameraEffect!>): Unit
```

Sets `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraEffect`.

Call this method to set a list of active effects. There is maximum one effect per `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`. Adding effects with duplicate or invalid targets throws `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`. Once called, CameraX will rebind the `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` with the effects applied. Effects not in the list are automatically removed.

The method throws `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` if the effects combination is not supported by CameraX. Please see the Javadoc of `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCaseGroup.Builder#addEffect(androidx.camera.core.CameraEffect)` to see the supported effects combinations.

| Parameters |
|---|---|
| `effects: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/camera/core/CameraEffect!>` | The effects applied to camera output. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the combination of effects is not supported by CameraX. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCaseGroup.Builder#addEffect(androidx.camera.core.CameraEffect)` |   |

### setEnabledUseCases

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

```
@MainThread
fun setEnabledUseCases(enabledUseCases: Int): Unit
```

Enables or disables use cases.

Use cases need to be enabled before they can be used. By default, `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#IMAGE_CAPTURE()` and `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#IMAGE_ANALYSIS()` are enabled, and `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()` is disabled. This is necessary because `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()` may affect the available resolutions for other use cases, especially on lower end devices.

To make sure getting the maximum resolution, only enable `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()` when shooting video. For example:

```kotlin
// By default, image capture is enabled. Taking picture works.
controller.takePicture(...);

// Switch to video capture to shoot video.
controller.setEnabledUseCases(VIDEO_CAPTURE);
controller.startRecording(...);

// Switch back to image capture and image analysis before taking another picture.
controller.setEnabledUseCases(IMAGE_CAPTURE|IMAGE_ANALYSIS);
controller.takePicture(...);
```

| Parameters |
|---|---|
| `enabledUseCases: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | one or more of the following use cases, bitwise-OR-ed together: `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#IMAGE_CAPTURE()`, `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#IMAGE_ANALYSIS()` and/or `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the current camera selector is unable to resolve a camera to be used for the enabled use cases, or if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` |   |

### setImageAnalysisAnalyzer

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

```
@MainThread
fun setImageAnalysisAnalyzer(
    executor: Executor,
    analyzer: ImageAnalysis.Analyzer
): Unit
```

Sets an analyzer to receive and analyze images.

Applications can process or copy the image by implementing the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer`. The image needs to be closed by calling `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy#close()` when the analyzing is done.

Setting an analyzer function replaces any previous analyzer. Only one analyzer can be set at any time.

If the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer#getTargetCoordinateSystem()` returns `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#COORDINATE_SYSTEM_VIEW_REFERENCED()`, the analyzer will receive a transformation via `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer#updateTransform(android.graphics.Matrix)` that converts coordinates from the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`'s coordinate system to the `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`'s coordinate system.

If the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer#getDefaultTargetResolution()` returns a non-null value, calling this method will reconfigure the camera which might cause additional latency. To avoid this, set the value before controller is bound to the lifecycle.

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor in which the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer#analyze(androidx.camera.core.ImageProxy)` will be run. |
| `analyzer: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer` | of the images. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#setAnalyzer(java.util.concurrent.Executor,androidx.camera.core.ImageAnalysis.Analyzer)` |   |

### setImageAnalysisBackgroundExecutor

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

```
@MainThread
fun setImageAnalysisBackgroundExecutor(executor: Executor?): Unit
```

Sets the executor that will be used for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` background tasks.

If not set, the background executor will default to an automatically generated `https://developer.android.com/reference/java/util/concurrent/Executor.html`.

Changing the value will reconfigure the camera, which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html?` | The executor for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` background tasks. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

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

### setImageAnalysisBackpressureStrategy

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

```
@MainThread
fun setImageAnalysisBackpressureStrategy(strategy: Int): Unit
```

Sets the backpressure strategy to apply to the image producer to deal with scenarios where images may be produced faster than they can be analyzed.

The available values are `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_BLOCK_PRODUCER()` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_KEEP_ONLY_LATEST()`. If not set, the backpressure strategy will default to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_KEEP_ONLY_LATEST()`.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `strategy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The strategy to use. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

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

### setImageAnalysisImageQueueDepth

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

```
@MainThread
fun setImageAnalysisImageQueueDepth(depth: Int): Unit
```

Sets the image queue depth of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

This sets the number of images available in parallel to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer`. The value is only used if the backpressure strategy is `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_BLOCK_PRODUCER()`.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `depth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The total number of images available. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

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

### setImageAnalysisOutputImageFormat

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

```
@MainThread
fun setImageAnalysisOutputImageFormat(imageAnalysisOutputImageFormat: Int): Unit
```

Sets the output image format for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

The supported output image format are `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_YUV_420_888()` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_RGBA_8888()`.

If not set, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_YUV_420_888()` will be used.

Requesting `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_RGBA_8888()` or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_NV21()` causes extra overhead because format conversion takes time.

Changing the value will reconfigure the camera, which may cause additional latency. To avoid this, set the value before controller is bound to lifecycle. If the value is changed when the camera is active, check the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy#getFormat()` value to determine when the new format takes effect.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

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

### setImageAnalysisResolutionSelector

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

```
@MainThread
fun setImageAnalysisResolutionSelector(
    resolutionSelector: ResolutionSelector?
): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

CameraX uses this value as a hint to select the resolution for images. The actual output may differ from the requested value due to device constraints. When set to `null`, CameraX will use the default config of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. ImageAnalysis has a default `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionStrategy` with bound size as 640x480 and fallback rule of `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionStrategy#FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER()`.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

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

### setImageAnalysisTargetSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@MainThread
fun [setImageAnalysisTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisTargetSize(androidx.camera.view.CameraController.OutputSize))(targetSize: CameraController.OutputSize?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageAnalysisResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` instead.

Sets the intended output size for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

The value is used as a hint when determining the resolution and aspect ratio of the output buffer. The actual output may differ from the requested value due to device constraints.

When set to `null`, the output will be based on the default config of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `targetSize: https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?` | The intended output size for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetAspectRatio(int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetResolution(android.util.Size)` |   |

### setImageCaptureFlashMode

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

```
@MainThread
fun setImageCaptureFlashMode(flashMode: Int): Unit
```

Sets the flash mode for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`.

If not set, the flash mode will default to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_OFF()`.

If `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is set, a valid `https://developer.android.com/reference/android/view/Window.html` instance must be set to a `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` or `https://developer.android.com/reference/kotlin/androidx/camera/view/ScreenFlashView` which this controller is set to. Trying to use `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` with a non-front camera or without setting a non-null window will throw an exception. While switching the camera, it is the application's responsibility to change flash mode to the desired one if it leads to a no-op case (e.g. switching to rear camera while `FLASH_MODE_SCREEN` is still set). Otherwise, `FLASH_MODE_OFF` will be set.

| Parameters |
|---|---|
| `flashMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the flash mode for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If flash mode is invalid or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is used without a front camera or a non-null window. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView#setScreenFlashWindow(android.view.Window)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/view/ScreenFlashView#setScreenFlashWindow(android.view.Window)` |   |

### setImageCaptureIoExecutor

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

```
@MainThread
fun setImageCaptureIoExecutor(executor: Executor?): Unit
```

Sets the default executor that will be used for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` IO tasks.

This executor will be used for any IO tasks specifically for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`, such as `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageSavedCallback)`. If no executor is set, then a default Executor specifically for IO will be used instead.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html?` | The executor which will be used for IO tasks. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

### setImageCaptureMode

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

```
@MainThread
fun setImageCaptureMode(captureMode: Int): Unit
```

Sets the image capture mode.

Valid capture modes are `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#CAPTURE_MODE_MINIMIZE_LATENCY()`, which prioritizes latency over image quality, or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#CAPTURE_MODE_MAXIMIZE_QUALITY()`, which prioritizes image quality over latency.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `captureMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The requested image capture mode. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

### setImageCaptureResolutionSelector

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

```
@MainThread
fun setImageCaptureResolutionSelector(
    resolutionSelector: ResolutionSelector?
): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`.

CameraX uses this value as a hint to select the resolution for captured images. The actual output may differ from the requested value due to device constraints. When set to `null`, CameraX will use the default config of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. The default resolution strategy for ImageCapture is `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionStrategy#HIGHEST_AVAILABLE_STRATEGY()`, which will select the largest available resolution to use.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

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

### setImageCaptureTargetSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@MainThread
fun [setImageCaptureTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureTargetSize(androidx.camera.view.CameraController.OutputSize))(targetSize: CameraController.OutputSize?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` instead.

Sets the intended image size for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`.

The value is used as a hint when determining the resolution and aspect ratio of the captured image. The actual output may differ from the requested value due to device constraints.

When set to `null`, the output will be based on the default config of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `targetSize: https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?` | The intended image size for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

### setLinearZoom

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

```
@MainThread
fun setLinearZoom(linearZoom: @FloatRange(from = 0.0, to = 1.0) Float): ListenableFuture<Void!>
```

Sets current zoom by a linear zoom value ranging from 0f to 1.0f.

LinearZoom 0f represents the minimum zoom while linearZoom 1.0f represents the maximum zoom. The advantage of linearZoom is that it ensures the field of view (FOV) varies linearly with the linearZoom value, for use with slider UI elements (while `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setZoomRatio(float)` works well for pinch-zoom gestures).

If the value is set before the camera is ready, `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController` waits for the camera to be ready and then sets the linear zoom.

| 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!>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` which is finished when camera is set to the given ratio. It fails with `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl.OperationCanceledException` if there is newer value being set or camera is closed. If the ratio is out of range, it fails with `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`. Cancellation of this future is a no-op. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#setLinearZoom(float)` |   |

### setPinchToZoomEnabled

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

```
@MainThread
fun setPinchToZoomEnabled(enabled: Boolean): Unit
```

Enables/disables pinch-to-zoom.

Once enabled, end user can pinch on the `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` to zoom in/out if the bound camera supports zooming.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` to enable pinch-to-zoom. |

### setPreviewResolutionSelector

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

```
@MainThread
fun setPreviewResolutionSelector(resolutionSelector: ResolutionSelector?): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` for `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`.

CameraX uses this value as a hint to select the resolution for preview. The actual output may differ from the requested value due to device constraints. When set to `null`, CameraX will use the default config of `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`. By default, the selected resolution will be limited by the `PREVIEW` size which is defined as the best size match to the device's screen resolution, or to 1080p (1920x1080), whichever is smaller.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

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

### setPreviewTargetSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
@MainThread
fun [setPreviewTargetSize](https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPreviewTargetSize(androidx.camera.view.CameraController.OutputSize))(targetSize: CameraController.OutputSize?): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPreviewResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` instead.

Sets the intended output size for `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`.

The value is used as a hint when determining the resolution and aspect ratio of the preview. The actual output may differ from the requested value due to device constraints.

When set to `null`, the output will be based on the default config of `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`.

Changing the value will reconfigure the camera which will cause additional latency. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `targetSize: https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController.OutputSize?` | the intended output size for `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview.Builder#setTargetAspectRatio(int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview.Builder#setTargetResolution(android.util.Size)` |   |

### setSessionConfig

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

```
@MainThread
fun setSessionConfig(
    sessionConfig: SessionConfig,
    cameraSelector: CameraSelector
): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` with the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` for the CameraController.

When a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` is provided, CameraController will connect to the `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase`s in the session config. This is useful for accessing the methods that are not exposed from the CameraController directly.

The following code sample shows how to create a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` with a `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview` and an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` use case and set it to the controller.

```kotlin
    // Create a LifecycleCameraController instance.
    LifecycleCameraController controller = new LifecycleCameraController(context);

    // Create the UseCases.
    Preview preview = new Preview.Builder().build();
    ImageCapture imageCapture = new ImageCapture.Builder().build();

    // Create the SessionConfig.
    SessionConfig sessionConfig = new SessionConfig.Builder()
            .addUseCase(preview)
            .addUseCase(imageCapture)
            .build();

    // Set the SessionConfig to the controller.
    controller.setSessionConfig(sessionConfig, CameraSelector.DEFAULT_BACK_CAMERA);

    // The controller can now be used with a PreviewView to display the preview.
    previewView.setController(controller);

    // Bind the controller to a LifecycleOwner.
    controller.bindToLifecycle(lifecycleOwner);
```

**Requirements:**

- The provided `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` must contain a `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`.
- The controller must be set on a `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` for the preview to be displayed. The `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`'s `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview.SurfaceProvider` will overwrite the one in the `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview` use case within the `SessionConfig`.
- If the `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` includes a `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapture` use case, it must be created with a `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder` instance for video recording to work correctly.

Once a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` is set, most setter functions will result in an `https://developer.android.com/reference/java/lang/IllegalStateException.html` because the `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` configuration is considered immutable. The only exceptions are methods that do not modify the `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` configuration. These methods are:

- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setImageCaptureFlashMode(int)`
- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setCameraSelector(androidx.camera.core.CameraSelector)`
- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setPinchToZoomEnabled(boolean)`
- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setTapToFocusEnabled(boolean)`
- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setTapToFocusAutoCancelDuration(long,java.util.concurrent.TimeUnit)`
- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setZoomRatio(float)`
- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setLinearZoom(float)`
- `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#enableTorch(boolean)`

The `https://developer.android.com/reference/kotlin/androidx/camera/core/ViewPort` in the given `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` will be overwritten by the value according to layout of the associated `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`. This is to maintain the WYSIWYG design purpose of CameraController.

For `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` with advanced settings that might only be supported on specific camera devices, it is recommended to check whether it can be supported via `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#isSessionConfigSupported(androidx.camera.core.SessionConfig)` before setting to the CameraController.

`https://developer.android.com/reference/kotlin/androidx/camera/video/HighSpeedVideoSessionConfig` is not supported because it is not compatible with `https://developer.android.com/reference/kotlin/androidx/camera/core/ViewPort`, which is always enabled by CameraController.

CameraController will override the autoRotationEnabled setting in the provided SessionConfig to match its current state. See `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setAutoRotationEnabled(boolean)` for more information.

| Parameters |
|---|---|
| `sessionConfig: https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` | The `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` to be used. This can be a standard `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` or an `https://developer.android.com/reference/kotlin/androidx/camera/extensions/ExtensionSessionConfig`. |
| `cameraSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` | The `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraSelector` for choosing the camera to which the `sessionConfig` is applied. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the provided `sessionConfig` is invalid (e.g. missing a required `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`, or containing an unsupported `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase` combination) or cannot be used to create a functional camera capture session. |

### setTapToFocusAutoCancelDuration

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

```
@MainThread
fun setTapToFocusAutoCancelDuration(
    duration: @IntRange(from = 0) Long,
    timeUnit: TimeUnit
): Unit
```

Sets the auto-cancel duration for tap-to-focus events.

By default, CameraX uses a value of 5 seconds.

| Parameters |
|---|---|
| `duration: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration after which CameraX automatically cancels a tap-to-focus event. A value of 0 will disable the auto-cancellation behavior. |
| `timeUnit: https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` | The `https://developer.android.com/reference/java/util/concurrent/TimeUnit.html` for the `duration` parameter. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getTapToFocusInfoState()` |   |

### setTapToFocusEnabled

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

```
@MainThread
fun setTapToFocusEnabled(enabled: Boolean): Unit
```

Enables/disables tap-to-focus.

Once enabled, end user can tap on the `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView` to set focus point.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` to enable tap-to-focus. |

### setVideoCaptureDynamicRange

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

```
@MainThread
fun setVideoCaptureDynamicRange(dynamicRange: DynamicRange): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange` for video capture.

The dynamic range specifies how the range of colors, highlights and shadows that are captured by the video producer are displayed on a display. Some dynamic ranges will allow the video to make full use of the extended range of brightness of a display when the video is played back.

The supported dynamic ranges for video capture can be queried through the `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapabilities` returned by `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder#getVideoCapabilities(androidx.camera.core.CameraInfo)` via `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapabilities#getSupportedDynamicRanges()`.

It is possible to choose a high dynamic range (HDR) with unspecified encoding by providing `https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange#HDR_UNSPECIFIED_10_BIT()`.

If the dynamic range is not provided, the default value is `https://developer.android.com/reference/kotlin/androidx/camera/core/DynamicRange#SDR()`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapture.Builder#setDynamicRange(androidx.camera.core.DynamicRange)` |   |

### setVideoCaptureMirrorMode

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

```
@MainThread
fun setVideoCaptureMirrorMode(mirrorMode: Int): Unit
```

Sets the mirror mode for video capture.

Valid values include: `https://developer.android.com/reference/kotlin/androidx/camera/core/MirrorMode#MIRROR_MODE_OFF()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/MirrorMode#MIRROR_MODE_ON()` and `https://developer.android.com/reference/kotlin/androidx/camera/core/MirrorMode#MIRROR_MODE_ON_FRONT_ONLY()`. If not set, it defaults to `https://developer.android.com/reference/kotlin/androidx/camera/core/MirrorMode#MIRROR_MODE_OFF()`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapture.Builder#setMirrorMode(int)` |   |

### setVideoCaptureQualitySelector

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

```
@MainThread
fun setVideoCaptureQualitySelector(qualitySelector: QualitySelector): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` for `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()`.

The provided quality selector is used to select the resolution of the recording depending on the resolutions supported by the camera and codec capabilities.

If no quality selector is provided, the default is `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder#DEFAULT_QUALITY_SELECTOR()`.

Changing the value will reconfigure the camera which will cause video capture to stop. To avoid this, set the value before controller is bound to lifecycle.

| Parameters |
|---|---|
| `qualitySelector: https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` | The quality selector for `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#VIDEO_CAPTURE()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/QualitySelector` |   |

### setVideoCaptureTargetFrameRate

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

```
@MainThread
fun setVideoCaptureTargetFrameRate(targetFrameRate: Range<Int!>): Unit
```

Sets the target frame rate range in frames per second for video capture.

This target will be used as a part of the heuristics for the algorithm that determines the final frame rate range and resolution of all concurrently bound use cases.

It is not guaranteed that this target frame rate will be the final range, as other use cases as well as frame rate restrictions of the device may affect the outcome of the algorithm that chooses the actual frame rate.

By default, the value is . For supported frame rates, see `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#getSupportedFrameRateRanges()`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if a `https://developer.android.com/reference/kotlin/androidx/camera/core/SessionConfig` has been set to the CameraController. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoCapture.Builder#setTargetFrameRate(android.util.Range<java.lang.Integer>)` |   |

### setZoomRatio

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

```
@MainThread
fun setZoomRatio(zoomRatio: Float): ListenableFuture<Void!>
```

Sets current zoom by ratio.

Valid zoom values range from `https://developer.android.com/reference/kotlin/androidx/camera/core/ZoomState#getMinZoomRatio()` to `https://developer.android.com/reference/kotlin/androidx/camera/core/ZoomState#getMaxZoomRatio()`.

If the value is set before the camera is ready, `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController` waits for the camera to be ready and then sets the zoom ratio.

| Parameters |
|---|---|
| `zoomRatio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The requested zoom ratio. |

| 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!>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` which is finished when camera is set to the given ratio. It fails with `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl.OperationCanceledException` if there is newer value being set or camera is closed. If the ratio is out of range, it fails with `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`. Cancellation of this future is a no-op. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#getZoomState()` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#setZoomRatio(float)` |   |

### startRecording

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

```
@RequiresApi(value = 26)
@MainThread
fun startRecording(
    outputOptions: FileDescriptorOutputOptions,
    audioConfig: AudioConfig,
    executor: Executor,
    listener: Consumer<VideoRecordEvent!>
): Recording
```

Takes a video to a given file descriptor.

Currently, file descriptors as output destinations are not supported on pre-Android O (API 26) devices.

Only a single recording can be active at a time, so if `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isRecording()` is true, this will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

Upon successfully starting the recording, a `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Start` event will be the first event sent to the provided event listener.

If errors occur while starting the recording, a `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize` event will be the first event sent to the provided listener, and information about the error can be found in that event's `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize#getError()` method.

Recording with audio requires the `https://developer.android.com/reference/android/Manifest.permission.html#RECORD_AUDIO` permission; without it, starting a recording will fail with a `https://developer.android.com/reference/java/lang/SecurityException.html`.

| Parameters |
|---|---|
| `outputOptions: https://developer.android.com/reference/kotlin/androidx/camera/video/FileDescriptorOutputOptions` | The options to store the newly captured video. |
| `audioConfig: https://developer.android.com/reference/kotlin/androidx/camera/view/video/AudioConfig` | The configuration of audio. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor that the event listener will be run on. |
| `listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent!>` | The event listener to handle video record events. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` | a `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` that provides controls for new active recordings. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if there is an unfinished active recording. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the audio config specifies audio should be enabled but the `https://developer.android.com/reference/android/Manifest.permission.html#RECORD_AUDIO` permission is denied. |

### startRecording

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

```
@MainThread
fun startRecording(
    outputOptions: FileOutputOptions,
    audioConfig: AudioConfig,
    executor: Executor,
    listener: Consumer<VideoRecordEvent!>
): Recording
```

Takes a video to a given file.

Only a single recording can be active at a time, so if `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isRecording()` is `true`, this will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

Upon successfully starting the recording, a `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Start` event will be the first event sent to the provided event listener.

If errors occur while starting the recording, a `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize` event will be the first event sent to the provided listener, and information about the error can be found in that event's `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize#getError()` method.

Recording with audio requires the `https://developer.android.com/reference/android/Manifest.permission.html#RECORD_AUDIO` permission; without it, starting a recording will fail with a `https://developer.android.com/reference/java/lang/SecurityException.html`.

| Parameters |
|---|---|
| `outputOptions: https://developer.android.com/reference/kotlin/androidx/camera/video/FileOutputOptions` | The options to store the newly captured video. |
| `audioConfig: https://developer.android.com/reference/kotlin/androidx/camera/view/video/AudioConfig` | The configuration of audio. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor that the event listener will be run on. |
| `listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent!>` | The event listener to handle video record events. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` | a `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` that provides controls for new active recordings. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if there is an unfinished active recording. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the audio config specifies audio should be enabled but the `https://developer.android.com/reference/android/Manifest.permission.html#RECORD_AUDIO` permission is denied. |

### startRecording

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

```
@MainThread
fun startRecording(
    outputOptions: MediaStoreOutputOptions,
    audioConfig: AudioConfig,
    executor: Executor,
    listener: Consumer<VideoRecordEvent!>
): Recording
```

Takes a video to MediaStore.

Only a single recording can be active at a time, so if `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#isRecording()` is `true`, this will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

Upon successfully starting the recording, a `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Start` event will be the first event sent to the provided event listener.

If errors occur while starting the recording, a `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize` event will be the first event sent to the provided listener, and information about the error can be found in that event's `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize#getError()` method.

Recording with audio requires the `https://developer.android.com/reference/android/Manifest.permission.html#RECORD_AUDIO` permission; without it, starting a recording will fail with a `https://developer.android.com/reference/java/lang/SecurityException.html`.

| Parameters |
|---|---|
| `outputOptions: https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions` | The options to store the newly captured video. |
| `audioConfig: https://developer.android.com/reference/kotlin/androidx/camera/view/video/AudioConfig` | The configuration of audio. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor that the event listener will be run on. |
| `listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent!>` | The event listener to handle video record events. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` | a `https://developer.android.com/reference/kotlin/androidx/camera/video/Recording` that provides controls for new active recordings. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if there is an unfinished active recording. |
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the audio config specifies audio should be enabled but the `https://developer.android.com/reference/android/Manifest.permission.html#RECORD_AUDIO` permission is denied. |

### takePicture

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

```
@MainThread
fun takePicture(
    executor: Executor,
    callback: ImageCapture.OnImageCapturedCallback
): Unit
```

Captures a new still image for in memory access.

The listener is responsible for calling `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy#close()` on the returned image.

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor in which the callback methods will be run. |
| `callback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback` | Callback to be invoked for the newly captured image |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is set to the `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController`, but a non-null `https://developer.android.com/reference/android/view/Window.html` instance has not been set with `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView#setScreenFlashWindow(android.view.Window)`. |

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

### takePicture

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

```
@MainThread
fun takePicture(
    outputFileOptions: ImageCapture.OutputFileOptions,
    executor: Executor,
    imageSavedCallback: ImageCapture.OnImageSavedCallback
): Unit
```

Captures a new still image and saves to a file along with application specified metadata.

The callback will be called only once for every invocation of this method.

By default, the saved image is mirrored to match the output of the preview if front camera is used. To override this behavior, the app needs to explicitly set the flag to `false` using `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Metadata#setReversedHorizontal(boolean)` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions.Builder#setMetadata(androidx.camera.core.ImageCapture.Metadata)`.

The saved image is cropped to match the aspect ratio of the `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`. To take a picture with the maximum available resolution, make sure that the `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView`'s aspect ratio matches the max JPEG resolution supported by the camera.

| Parameters |
|---|---|
| `outputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions` | Options to store the newly captured image. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor in which the callback methods will be run. |
| `imageSavedCallback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback` | Callback to be called for the newly captured image. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is set to the `https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController`, but a non-null `https://developer.android.com/reference/android/view/Window.html` instance has not been set with `https://developer.android.com/reference/kotlin/androidx/camera/view/PreviewView#setScreenFlashWindow(android.view.Window)`. |

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