# Camera2TransformationInfo

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

*** ** * ** ***


```
object Camera2TransformationInfo
```

<br />

*** ** * ** ***

Utilities for generating `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` for use with {@docRoot\]media/camera/camera2

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` | `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/camera2/Camera2TransformationInfo#createFromCharacteristics(android.hardware.camera2.CameraCharacteristics,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)( cameraCharacteristics: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html, cropRectLeft: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, cropRectTop: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, cropRectRight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, cropRectBottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Creates `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` from the provided `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` and crop rect. |
| `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 33) https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/camera2/Camera2TransformationInfo#createFromCharacteristics(android.hardware.camera2.CameraCharacteristics,kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)( cameraCharacteristics: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html, mirrorMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, cropRectLeft: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, cropRectTop: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, cropRectRight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, cropRectBottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Creates `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` from the provided `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html`, crop rect, and mirror mode. |

## Public functions

### createFromCharacteristics

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

```
fun createFromCharacteristics(
    cameraCharacteristics: CameraCharacteristics,
    cropRectLeft: Float = TransformationInfo.CROP_NONE,
    cropRectTop: Float = TransformationInfo.CROP_NONE,
    cropRectRight: Float = TransformationInfo.CROP_NONE,
    cropRectBottom: Float = TransformationInfo.CROP_NONE
): TransformationInfo
```

Creates `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` from the provided `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` and crop rect.

When using a viewfinder with {@docRoot\]media/camera/camera2, this will generate the appropriate `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` to display the camera frames upright.

The crop rect will specify a region of interest (ROI) within the original buffer to treat as the buffer dimensions. When displaying the ROI in a viewfinder, depending on the scale mode, the crop rect bounding box should line up with the edges of the viewfinder, but pixels outside the bounding box will not necessarily be hidden if they still land within the bounds of the viewfinder.

| Parameters |
|---|---|
| `cameraCharacteristics: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` | the camera characteristics of the camera being used to produce frames |
| `cropRectLeft: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional left bound of a crop rect |
| `cropRectTop: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional top bound of a crop rect |
| `cropRectRight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional right bound of a crop rect |
| `cropRectBottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional bottom bound of a crop rect |

### createFromCharacteristics

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

```
@RequiresApi(value = 33)
fun createFromCharacteristics(
    cameraCharacteristics: CameraCharacteristics,
    mirrorMode: Int,
    cropRectLeft: Float = TransformationInfo.CROP_NONE,
    cropRectTop: Float = TransformationInfo.CROP_NONE,
    cropRectRight: Float = TransformationInfo.CROP_NONE,
    cropRectBottom: Float = TransformationInfo.CROP_NONE
): TransformationInfo
```

Creates `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` from the provided `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html`, crop rect, and mirror mode.

When using a viewfinder with {@docRoot\]media/camera/camera2, this will generate the appropriate `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/TransformationInfo` to display the camera frames upright.

The crop rect will specify a region of interest (ROI) within the original buffer to treat as the buffer dimensions. When displaying the ROI in a viewfinder, depending on the scale mode, the crop rect bounding box should line up with the edges of the viewfinder, but pixels outside the bounding box will not necessarily be hidden if they still land within the bounds of the viewfinder.

The mirror mode is one of `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#MIRROR_MODE_AUTO`, `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#MIRROR_MODE_NONE`, `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#MIRROR_MODE_H`, or `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#MIRROR_MODE_NONE`, and should match what was set on `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#setMirrorMode(android.view.Surface, int)`. Note that before API level 33, the default behavior was equivalent to `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#MIRROR_MODE_AUTO`.

| Parameters |
|---|---|
| `cameraCharacteristics: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html` | the camera characteristics of the camera being used to produce frames |
| `mirrorMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the mirror mode set on `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration.html#setMirrorMode(android.view.Surface, int)` Value is one of the following: - `0` - `1` - `2` - `3` <br /> |
| `cropRectLeft: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional left bound of a crop rect |
| `cropRectTop: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional top bound of a crop rect |
| `cropRectRight: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional right bound of a crop rect |
| `cropRectBottom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = TransformationInfo.CROP_NONE` | the optional bottom bound of a crop rect |