# ImageAnalysis.Builder

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

*** ** * ** ***


```
class ImageAnalysis.Builder : ExtendableBuilder, UseCase.InteropConfigurable<ImageAnalysis.Builder!>
```

<br />

*** ** * ** ***

Builder for a `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#Builder()()` Creates a new Builder object. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#build()()` Builds an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` from the current state. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setBackgroundExecutor(java.util.concurrent.Executor)(executor: https://developer.android.com/reference/java/util/concurrent/Executor.html)` Sets the default executor that will be used for background tasks. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setBackpressureStrategy(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://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setImageQueueDepth(int)(depth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the number of images available to the camera pipeline for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_BLOCK_PRODUCER()` mode. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setOutputImageFormat(int)(outputImageFormat: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets output image format. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 23) https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setOutputImageRotationEnabled(boolean)(outputImageRotationEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Enable or disable output image rotation. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)(resolutionSelector: https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector)` Sets the resolution selector to select the preferred supported resolution. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `[setTargetAspectRatio](https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetAspectRatio(int))(aspectRatio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` with `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/AspectRatioStrategy` to specify the preferred aspect ratio settings instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetName(java.lang.String)(targetName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the name of the target object being configured, used only for debug logging. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `[setTargetResolution](https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetResolution(android.util.Size))(resolution: https://developer.android.com/reference/android/util/Size.html)` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` with `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionStrategy` to specify the preferred resolution settings instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetRotation(int)(rotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the rotation of the intended target for images from this configuration. |

### Inherited functions

From [androidx.camera.core.UseCase.InteropConfigurable](https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase.InteropConfigurable) `B` `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase.InteropConfigurable#setInterop(androidx.camera.core.InteropConfigurator<? super B>)(configurator: https://developer.android.com/reference/kotlin/androidx/camera/core/InteropConfigurator<B!>)`

Applies interoperability configuration to this builder.

## Public constructors

### Builder

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

```
Builder()
```

Creates a new Builder object.

## Public functions

### build

```
fun build(): ImageAnalysis
```

Builds an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` from the current state.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` | A `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` populated with the current state. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if attempting to set both target aspect ratio and target resolution. |

### setBackgroundExecutor

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

```
fun setBackgroundExecutor(executor: Executor): ImageAnalysis.Builder
```

Sets the default executor that will be used for background tasks.

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | the current Builder. |

### setBackpressureStrategy

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

```
fun setBackpressureStrategy(strategy: Int): ImageAnalysis.Builder
```

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

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

### setImageQueueDepth

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

```
fun setImageQueueDepth(depth: Int): ImageAnalysis.Builder
```

Sets the number of images available to the camera pipeline for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_BLOCK_PRODUCER()` mode.

The image queue depth is the number of images available to the camera to fill with data. This includes the image currently being analyzed by `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer#analyze(androidx.camera.core.ImageProxy)`. Increasing the image queue depth may make camera operation smoother, depending on the backpressure strategy, at the cost of increased memory usage.

When the backpressure strategy is set to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_BLOCK_PRODUCER()`, increasing the image queue depth may make the camera pipeline run smoother on systems under high load. However, the time spent analyzing an image should still be kept under a single frame period for the current frame rate, *on average*, to avoid stalling the camera pipeline.

The value only applies to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_BLOCK_PRODUCER()` mode. For `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#STRATEGY_KEEP_ONLY_LATEST()` the value is ignored.

If not set, and this option is used by the selected backpressure strategy, the default will be a queue depth of 6 images.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

### setOutputImageFormat

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

```
fun setOutputImageFormat(outputImageFormat: Int): ImageAnalysis.Builder
```

Sets output image format.

The supported output image format is `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()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_NV21()` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_PRIVATE()`.

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()` will have extra overhead because format conversion takes time.

When the output image format is set to `OUTPUT_IMAGE_FORMAT_PRIVATE`, the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` passed to the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer` will have `https://developer.android.com/reference/android/graphics/ImageFormat.html#PRIVATE` format. This format is not CPU accessible and should be used with GPU-based processing. Note that when this format is used, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setOutputImageRotationEnabled(boolean)` is not allowed to be set to true.

The following code snippet demonstrates how to use the PRIVATE format for GPU-based processing:

```kotlin
ImageAnalysisCapabilities capabilities =
    ImageAnalysis.getImageAnalysisCapabilities(camera.getCameraInfo());
if (capabilities.isOutputFormatSupported(ImageAnalysis.OUTPUT_IMAGE_FORMAT_PRIVATE)) {
    ImageAnalysis imageAnalysis = new ImageAnalysis.Builder()
        .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_PRIVATE)
        .build();

    imageAnalysis.setAnalyzer(executor, image -> {
        // Access the HardwareBuffer for GPU processing
        if (Build.VERSION.SDK_INT >= 28) {
            HardwareBuffer hardwareBuffer = image.getHardwareBuffer();
            if (hardwareBuffer != null) {
                // Do GPU processing with hardwareBuffer
            }
        }
        image.close();
    });
}
```

| Parameters |
|---|---|
| `outputImageFormat: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The output image format. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

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

### setOutputImageRotationEnabled

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

```
@RequiresApi(value = 23)
fun setOutputImageRotationEnabled(outputImageRotationEnabled: Boolean): ImageAnalysis.Builder
```

Enable or disable output image rotation.

On API 22 and below, this API has no effect. User needs to handle the image rotation based on the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageInfo#getRotationDegrees()`.

`https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#setTargetRotation(int)` is to adjust the rotation degree information returned by `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageInfo#getRotationDegrees()` based on sensor rotation and user still needs to rotate the output image to achieve the target rotation. Once this is enabled, user doesn't need to handle the rotation, the output image will be a rotated `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageInfo#getRotationDegrees()` will return 0.

Turning this on will add more processing overhead to every image analysis frame. The average processing time is about 10-15ms for 640x480 image on a mid-range device.

By default, the rotation is disabled.

Note that when the output image format is set to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_PRIVATE()`, this API is not allowed to be set to true.

| Parameters |
|---|---|
| `outputImageRotationEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | flag to enable or disable. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

| See also |
|---|---|
| `https://developer.android.com/training/camerax/orientation-rotation#imageanalysis` | [ImageAnalysis](https://developer.android.com/training/camerax/orientation-rotation#imageanalysis) |

### setResolutionSelector

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

```
fun setResolutionSelector(resolutionSelector: ResolutionSelector): ImageAnalysis.Builder
```

Sets the resolution selector to select the preferred supported resolution.

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()`. Applications can override this default strategy with a different resolution strategy.

When using the `camera-camera2` CameraX implementation, which resolution is finally selected depends on the camera device's hardware level, capabilities and the bound use cases combination. The device hardware level and capabilities information can be retrieved via the interop class `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key<T>)` with `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL` and `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#REQUEST_AVAILABLE_CAPABILITIES`.

A `LIMITED-level` above device can support a `RECORD` size resolution for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` when it is bound together with `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. The trade-off is the selected resolution for the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` is also restricted by the `RECORD` size. To successfully select a `RECORD` size resolution for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`, a `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionStrategy` of selecting `RECORD` size resolution should be set on both `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. This indicates that the application clearly understand the trade-off and prefer the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` to have a larger resolution rather than the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` to have a `MAXIMUM
` size resolution. For the definitions of `RECORD`, `MAXIMUM` sizes and more details see the [Regular capture](https://developer.android.com/reference/android/hardware/camera2/CameraDevice#regular-capture) section in `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html`'s. The `RECORD` size refers to the camera device's maximum supported recording resolution, as determined by `https://developer.android.com/reference/android/media/CamcorderProfile.html`. The `MAXIMUM` size refers to the camera device's maximum output resolution for that format or target from `https://developer.android.com/reference/android/hardware/camera2/params/StreamConfigurationMap.html#getOutputSizes(int)`.

The existing `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetResolution(android.util.Size)` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetAspectRatio(int)` APIs are deprecated and are not compatible with `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)`. Calling either of these APIs together with `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` will result in an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` being thrown when you attempt to build the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` instance.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

### setTargetAspectRatio

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

```
fun [setTargetAspectRatio](https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetAspectRatio(int))(aspectRatio: Int): ImageAnalysis.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` with `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/AspectRatioStrategy` to specify the preferred aspect ratio settings instead.

Sets the aspect ratio of the intended target for images from this configuration.

The aspect ratio is the ratio of width to height in the sensor orientation.

It is not allowed to set both target aspect ratio and target resolution on the same use case. Attempting so will throw an IllegalArgumentException when building the Config.

The target aspect ratio is used as a hint when determining the resulting output aspect ratio which may differ from the request, possibly due to device constraints. Application code should check the resulting output's resolution and the resulting aspect ratio may not be exactly as requested.

If not set, or `https://developer.android.com/reference/kotlin/androidx/camera/core/AspectRatio#RATIO_DEFAULT()` is supplied, resolutions with aspect ratio 4:3 will be considered in higher priority.

| Parameters |
|---|---|
| `aspectRatio: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The desired ImageAnalysis `https://developer.android.com/reference/kotlin/androidx/camera/core/AspectRatio` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

### setTargetName

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

```
fun setTargetName(targetName: String): ImageAnalysis.Builder
```

Sets the name of the target object being configured, used only for debug logging.

The name should be a value that can uniquely identify an instance of the object being configured.

If not set, the target name will default to a unique name automatically generated with the class canonical name and random UUID.

| Parameters |
|---|---|
| `targetName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | A unique string identifier for the instance of the class being configured. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | the current Builder. |

### setTargetResolution

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

```
fun [setTargetResolution](https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder#setTargetResolution(android.util.Size))(resolution: Size): ImageAnalysis.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` with `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionStrategy` to specify the preferred resolution settings instead.

Sets the resolution of the intended target from this configuration.

The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen. Resolutions with the same aspect ratio of the provided `https://developer.android.com/reference/android/util/Size.html` will be considered in higher priority before resolutions of different aspect ratios.

It is not allowed to set both target aspect ratio and target resolution on the same use case. Attempting so will throw an IllegalArgumentException when building the Config.

The resolution `https://developer.android.com/reference/android/util/Size.html` should be expressed in the coordinate frame after rotating the supported sizes by the target rotation. For example, a device with portrait natural orientation in natural target rotation requesting a portrait image may specify 480x640, and the same device, rotated 90 degrees and targeting landscape orientation may specify 640x480.

If not set, resolution of 640x480 will be selected to use in priority.

When using the `camera-camera2` CameraX implementation, which resolution will be finally selected will depend on the camera device's hardware level and the bound use cases combination. The device hardware level information can be retrieved by `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL` from the interop class `https://developer.android.com/reference/kotlin/androidx/camera/camera2/interop/Camera2CameraInfo#getCameraCharacteristic(android.hardware.camera2.CameraCharacteristics.Key<T>)`. A `LIMITED-level` above device can support a `RECORD` size resolution for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` when it is bound together with `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. The trade-off is the selected resolution for the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` will also be restricted by the `RECORD` size. To successfully select a `RECORD` size resolution for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`, a `RECORD` size target resolution should be set on both `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` and `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis`. This indicates that the application clearly understand the trade-off and prefer the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis` to have a larger resolution rather than the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` to have a `MAXIMUM` size resolution. For the definitions of `RECORD`, `MAXIMUM` sizes and more details see the [Regular capture](https://developer.android.com/reference/android/hardware/camera2/CameraDevice#regular-capture) section in `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html`'s. The `RECORD` size refers to the camera device's maximum supported recording resolution, as determined by `https://developer.android.com/reference/android/media/CamcorderProfile.html`. The `MAXIMUM` size refers to the camera device's maximum output resolution for that format or target from `https://developer.android.com/reference/android/hardware/camera2/params/StreamConfigurationMap.html#getOutputSizes(int)`.

| Parameters |
|---|---|
| `resolution: https://developer.android.com/reference/android/util/Size.html` | The target resolution to choose from supported output sizes list. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

### setTargetRotation

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

```
fun setTargetRotation(rotation: Int): ImageAnalysis.Builder
```

Sets the rotation of the intended target for images from this configuration.

This adjust the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageInfo#getRotationDegrees()` of the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` passed to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Analyzer#analyze(androidx.camera.core.ImageProxy)`. The rotation value of ImageInfo will be the rotation, which if applied to the output image, will make the image match target rotation specified here.

This is one of four valid values: `https://developer.android.com/reference/android/view/Surface.html#ROTATION_0`, `https://developer.android.com/reference/android/view/Surface.html#ROTATION_90`, `https://developer.android.com/reference/android/view/Surface.html#ROTATION_180`, `https://developer.android.com/reference/android/view/Surface.html#ROTATION_270`. Rotation values are relative to the "natural" rotation, `https://developer.android.com/reference/android/view/Surface.html#ROTATION_0`.

In general, it is best to additionally set the target rotation dynamically on the use case. See `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#setTargetRotation(int)` for additional documentation.

If not set, the target rotation will default to the value of `https://developer.android.com/reference/android/view/Display.html#getRotation()` of the default display at the time the use case is created. The use case is fully created once it has been attached to a camera.

| Parameters |
|---|---|
| `rotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The rotation of the intended target. Value is one of the following: - `Surface.ROTATION_0` - `Surface.ROTATION_90` - `Surface.ROTATION_180` - `Surface.ROTATION_270` <br /> |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis.Builder` | The current Builder. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageAnalysis#setTargetRotation(int)` |   |
| `https://developer.android.com/reference/android/view/OrientationEventListener.html` |   |