# CameraMath

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/CameraMath.kt+class:androidx.camera.common.CameraMath) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
public static class CameraMath
```

<br />

*** ** * ** ***

Utility functions for doing common transformations of camera and sensor coordinate spaces.

When doing camera coordinate transformations, there are three main "coordinate spaces" that a developer may need to understand and work with:

- **Sensor-relative** coordinates: These are integer-pixel coordinates that correspond to the physical active pixel array of a camera device. Most operations in Camera2 (like 3A metering regions or crop regions) define coordinates relative to the physical sensor (with `(0,0)` being the top-left active pixel).

- **Stream-relative** coordinates: When configuring camera output streams, they are configured with a specific resolution. The stream coordinate space is axially aligned and centered within the crop region of the sensor, but may be further cropped either horizontally or vertically to maintain square pixels and its own aspect ratio (see Android's camera cropping specification at [Output streams, cropping, and zoom](https://source.android.com/docs/core/camera/camera3_crop_reprocess)). Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries.

- **UI-relative** coordinates: These represent the display area of a stream on a UI surface (like a viewfinder). UI coordinates are scaled, potentially mirrored, and rotated relative to the coordinate system of the screen or window the viewfinder is currently displayed on. *Note* : The `uiWidth` and `uiHeight` used in calculations represent the UI-relative size of the viewfinder, without accounting for any viewport clipping or padding. Callers must normalize UI coordinates to account for clipping or padding before calling these functions.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#DEFAULT_MIN_SENSOR_PIXELS() = 32` When converting to sensor coordinates, this is the minimum width/height for rectangles that will be sent to the sensor. |
| `static final float` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#DEFAULT_POINT_TO_RECT_RATIO() = 0.18375f` It's common to need to convert a point into a sensor-relative rectangle for things like touch-to-focus, which often starts from a touch point that then needs to be converted into a sensor-relative rectangle. |

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraMath` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#INSTANCE()` |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/DiscreteRotation` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)( int displayRotation, int sensorOrientation, boolean sensorIsFacingScreen )` Computes the rotation required to rotate coordinates from sensor space to the display coordinate system. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/DiscreteRotation` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToJpegOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)( int deviceOrientation, int sensorOrientation, boolean sensorIsFacingScreen )` Computes the clockwise rotation required to be applied to the captured image to be viewed upright. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorPointToStreamPointF(android.graphics.Point,android.util.Size,android.graphics.Rect)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html sensorPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop )` Converts a point relative to the camera sensor to an equivalent point relative to a specific camera stream. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorPointToUiPointF(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html sensorPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop )` Converts a point relative to the camera sensor to an equivalent point relative to a UI element. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorRectToStreamRectF(android.graphics.Rect,android.util.Size,android.graphics.Rect)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorRect, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop )` Converts a rectangle relative to the camera sensor to an equivalent rectangle relative to a specific camera stream. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorRectToUiRectF(android.graphics.Rect,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorRect, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop )` Converts a rectangle relative to the camera sensor to an equivalent rectangle relative to a UI element. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SizeF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorSizeToStreamSizeF(android.util.Size,android.util.Size,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, int sensorCropWidth, int sensorCropHeight )` Converts a size relative to the camera sensor to an equivalent size relative to a specific camera stream. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SizeF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorSizeToUiSizeF(android.util.Size,android.util.Size,android.util.Size,kotlin.Int,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, int sensorRotationToDisplayOrientation, int sensorCropWidth, int sensorCropHeight )` Converts a size relative to the camera sensor to an equivalent size relative to a UI element. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamPointToSensorPoint(android.graphics.PointF,android.util.Size,android.graphics.Rect,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html streamPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop, boolean coerceToCropRegion )` Converts a point relative to a specific camera stream to an equivalent point relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamPointToSensorRect(android.graphics.PointF,android.util.Size,android.graphics.Rect,kotlin.Int,kotlin.Boolean,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html streamPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop, int minimumSensorSize, boolean coerceToCropRegion, float touchToFocusRatio )` Converts a point relative to a specific camera stream to an equivalent rectangle relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamPointToUiPointF(android.graphics.PointF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html streamPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation )` Converts a point relative to a specific camera stream to an equivalent point relative to a UI element. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamRectToSensorRect(android.graphics.RectF,android.util.Size,android.graphics.Rect,kotlin.Int,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html streamRect, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop, int minimumSensorSize, boolean coerceToCropRegion )` Converts a rectangle relative to a specific camera stream to an equivalent rectangle relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamRectToUiRectF(android.graphics.RectF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html streamRect, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation )` Converts a rectangle relative to a specific camera stream to an equivalent rectangle relative to a UI element. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamSizeToSensorSize(android.util.Size,android.util.Size,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, int sensorCropWidth, int sensorCropHeight )` Converts a size relative to a specific camera stream to an equivalent size relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SizeF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamSizeToUiSizeF(android.util.Size,android.util.Size,android.util.Size,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, int sensorRotationToDisplayOrientation )` Converts a size relative to a specific camera stream to an equivalent size relative to a UI element. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToSensorPoint(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop, boolean coerceToCropRegion )` Converts a point relative to a UI element to an equivalent point relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToSensorRect(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Int,kotlin.Boolean,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop, int minimumSensorSize, boolean coerceToCropRegion, float touchToFocusRatio )` Converts a point relative to a UI element to an equivalent rectangle relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToStreamPointF(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation )` Converts a point relative to a UI element to an equivalent point relative to a specific camera stream. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToStreamRectF(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation, float touchToFocusRatio )` Converts a point relative to a UI element to an equivalent rectangle relative to a specific camera stream. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiRectToSensorRect(android.graphics.RectF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Int,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html uiRect, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop, int minimumSensorSize, boolean coerceToCropRegion )` Converts a rectangle relative to a UI element to an equivalent rectangle relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiRectToStreamRectF(android.graphics.RectF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html uiRect, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, boolean streamMirroring, int sensorRotationToDisplayOrientation )` Converts a rectangle relative to a UI element to an equivalent rectangle relative to a specific camera stream. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiSizeToSensorSize(android.util.Size,android.util.Size,android.util.Size,kotlin.Int,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, int sensorRotationToDisplayOrientation, int sensorCropWidth, int sensorCropHeight )` Converts a size relative to a UI element to an equivalent size relative to the camera sensor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SizeF.html` | `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiSizeToStreamSizeF(android.util.Size,android.util.Size,android.util.Size,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize, int sensorRotationToDisplayOrientation )` Converts a size relative to a UI element to an equivalent size relative to a specific camera stream. |

## Constants

### DEFAULT_MIN_SENSOR_PIXELS

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

```
public static final int DEFAULT_MIN_SENSOR_PIXELS = 32
```

When converting to sensor coordinates, this is the minimum width/height for rectangles that will be sent to the sensor. This helps prevent scenarios where rectangles need to be clamped to the sensor, but where setting a small, or zero, size can lead to unexpected or bad behavior.

### DEFAULT_POINT_TO_RECT_RATIO

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

```
public static final float DEFAULT_POINT_TO_RECT_RATIO = 0.18375f
```

It's common to need to convert a point into a sensor-relative rectangle for things like touch-to-focus, which often starts from a touch point that then needs to be converted into a sensor-relative rectangle.

This ratio is used to compute a rectangle based on the short dimension of the current stream.

## Public fields

### INSTANCE

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

```
public static @NonNull CameraMath INSTANCE
```

## Public methods

### computeSensorRotationToDisplayOrientation

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

```
public static final @NonNull DiscreteRotation computeSensorRotationToDisplayOrientation(
    int displayRotation,
    int sensorOrientation,
    boolean sensorIsFacingScreen
)
```

Computes the rotation required to rotate coordinates from sensor space to the display coordinate system.

| Parameters |
|---|---|
| `int displayRotation` | The rotation of the display in degrees. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be obtained from `https://developer.android.com/reference/android/view/Display.html#getRotation()` and converted using `https://developer.android.com/reference/androidx/camera/common/DiscreteRotation#fromSurfaceRotation(kotlin.Int)` (e.g., `DiscreteRotation.fromSurfaceRotation(display.rotation).degrees`). (Note: do not pass `https://developer.android.com/reference/android/view/Surface.html#ROTATION_0`, `https://developer.android.com/reference/android/view/Surface.html#ROTATION_90`, etc. constants directly as they represent index values rather than degrees). Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `int sensorOrientation` | The physical orientation of the sensor in degrees (typically `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_ORIENTATION`). Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `boolean sensorIsFacingScreen` | Whether the camera sensor is facing the screen (front-facing). |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)` or `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)` is not one of `0`, `90`, `180`, or `270`. |

### computeSensorRotationToJpegOrientation

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

```
public static final @NonNull DiscreteRotation computeSensorRotationToJpegOrientation(
    int deviceOrientation,
    int sensorOrientation,
    boolean sensorIsFacingScreen
)
```

Computes the clockwise rotation required to be applied to the captured image to be viewed upright.

See `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#JPEG_ORIENTATION` for more details.

| Parameters |
|---|---|
| `int deviceOrientation` | The physical orientation of the device in degrees. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This is typically obtained from an `https://developer.android.com/reference/android/view/OrientationEventListener.html` and rounded to the nearest 90 degrees using `https://developer.android.com/reference/androidx/camera/common/DiscreteRotation#round(kotlin.Int)`. See the [Camera Orientation Guide](https://chromeos.dev/en/android/camera-orientation#jpeg-orientation) for more details. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `int sensorOrientation` | The physical orientation of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_ORIENTATION`). Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `boolean sensorIsFacingScreen` | Whether the camera sensor is facing the screen (front-facing). |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToJpegOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)` or `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToJpegOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)` is not one of `0`, `90`, `180`, or `270`. |

### mapSensorPointToStreamPointF

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

```
public static final @NonNull PointF mapSensorPointToStreamPointF(
    @NonNull Point sensorPoint,
    @NonNull Size streamSize,
    @NonNull Rect sensorCrop
)
```

Converts a point relative to the camera sensor to an equivalent point relative to a specific camera stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html sensorPoint` | The point on the sensor. Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). |

### mapSensorPointToUiPointF

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

```
public static final @NonNull PointF mapSensorPointToUiPointF(
    @NonNull Point sensorPoint,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation,
    @NonNull Rect sensorCrop
)
```

Converts a point relative to the camera sensor to an equivalent point relative to a UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html sensorPoint` | The point on the sensor. Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorPointToUiPointF(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect)` is not one of `0`, `90`, `180`, or `270`. |

### mapSensorRectToStreamRectF

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

```
public static final @NonNull RectF mapSensorRectToStreamRectF(
    @NonNull Rect sensorRect,
    @NonNull Size streamSize,
    @NonNull Rect sensorCrop
)
```

Converts a rectangle relative to the camera sensor to an equivalent rectangle relative to a specific camera stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorRect` | The rectangle on the sensor. Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). |

### mapSensorRectToUiRectF

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

```
public static final @NonNull RectF mapSensorRectToUiRectF(
    @NonNull Rect sensorRect,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation,
    @NonNull Rect sensorCrop
)
```

Converts a rectangle relative to the camera sensor to an equivalent rectangle relative to a UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorRect` | The rectangle on the sensor. Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorRectToUiRectF(android.graphics.Rect,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect)` is not one of `0`, `90`, `180`, or `270`. |

### mapSensorSizeToStreamSizeF

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

```
public static final @NonNull SizeF mapSensorSizeToStreamSizeF(
    @NonNull Size size,
    @NonNull Size streamSize,
    int sensorCropWidth,
    int sensorCropHeight
)
```

Converts a size relative to the camera sensor to an equivalent size relative to a specific camera stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size` | The size on the sensor. Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `int sensorCropWidth` | The width of the sensor crop region. |
| `int sensorCropHeight` | The height of the sensor crop region. |

### mapSensorSizeToUiSizeF

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

```
public static final @NonNull SizeF mapSensorSizeToUiSizeF(
    @NonNull Size size,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    int sensorRotationToDisplayOrientation,
    int sensorCropWidth,
    int sensorCropHeight
)
```

Converts a size relative to the camera sensor to an equivalent size relative to a UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size` | The size on the sensor. Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `int sensorCropWidth` | The width of the sensor crop region. |
| `int sensorCropHeight` | The height of the sensor crop region. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapSensorSizeToUiSizeF(android.util.Size,android.util.Size,android.util.Size,kotlin.Int,kotlin.Int,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |

### mapStreamPointToSensorPoint

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

```
public static final @NonNull Point mapStreamPointToSensorPoint(
    @NonNull PointF streamPoint,
    @NonNull Size streamSize,
    @NonNull Rect sensorCrop,
    boolean coerceToCropRegion
)
```

Converts a point relative to a specific camera stream to an equivalent point relative to the camera sensor.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html streamPoint` | The point in the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `boolean coerceToCropRegion` | Whether to coerce the output point into the crop region. |

### mapStreamPointToSensorRect

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

```
public static final @NonNull Rect mapStreamPointToSensorRect(
    @NonNull PointF streamPoint,
    @NonNull Size streamSize,
    @NonNull Rect sensorCrop,
    int minimumSensorSize,
    boolean coerceToCropRegion,
    float touchToFocusRatio
)
```

Converts a point relative to a specific camera stream to an equivalent rectangle relative to the camera sensor.

The output rectangle will have a size determined by the `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamPointToSensorRect(android.graphics.PointF,android.util.Size,android.graphics.Rect,kotlin.Int,kotlin.Boolean,kotlin.Float)` and will be centered on the mapped point. If the calculated rectangle is smaller than `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamPointToSensorRect(android.graphics.PointF,android.util.Size,android.graphics.Rect,kotlin.Int,kotlin.Boolean,kotlin.Float)` in either dimension, it will be expanded symmetrically from its center to reach the minimum.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html streamPoint` | The point in the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). |
| `int minimumSensorSize` | The minimum allowed width and height for the output rectangle in sensor pixels. If the calculated rectangle is smaller than this value in either dimension, it will be expanded symmetrically from its center to reach the minimum. Defaults to `https://developer.android.com/reference/androidx/camera/common/CameraMath#DEFAULT_MIN_SENSOR_PIXELS()`. Set to `0` or less to disable this behavior. |
| `boolean coerceToCropRegion` | Whether to coerce the output rectangle into the crop region. |
| `float touchToFocusRatio` | The ratio to use when computing a rectangle based on the short dimension of the stream. |

### mapStreamPointToUiPointF

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

```
public static final @NonNull PointF mapStreamPointToUiPointF(
    @NonNull PointF streamPoint,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation
)
```

Converts a point relative to a specific camera stream to an equivalent point relative to a UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html streamPoint` | The point in the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamPointToUiPointF(android.graphics.PointF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |

### mapStreamRectToSensorRect

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

```
public static final @NonNull Rect mapStreamRectToSensorRect(
    @NonNull RectF streamRect,
    @NonNull Size streamSize,
    @NonNull Rect sensorCrop,
    int minimumSensorSize,
    boolean coerceToCropRegion
)
```

Converts a rectangle relative to a specific camera stream to an equivalent rectangle relative to the camera sensor.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html streamRect` | The rectangle in the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `int minimumSensorSize` | The minimum allowed width and height for the output rectangle in sensor pixels. If the calculated rectangle is smaller than this value in either dimension, it will be expanded symmetrically from its center to reach the minimum. Defaults to `https://developer.android.com/reference/androidx/camera/common/CameraMath#DEFAULT_MIN_SENSOR_PIXELS()`. Set to `0` or less to disable this behavior. |
| `boolean coerceToCropRegion` | Whether to coerce the output rectangle into the crop region. |

### mapStreamRectToUiRectF

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

```
public static final @NonNull RectF mapStreamRectToUiRectF(
    @NonNull RectF streamRect,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation
)
```

Converts a rectangle relative to a specific camera stream to an equivalent rectangle relative to a UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html streamRect` | The rectangle in the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamRectToUiRectF(android.graphics.RectF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |

### mapStreamSizeToSensorSize

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

```
public static final @NonNull Size mapStreamSizeToSensorSize(
    @NonNull Size size,
    @NonNull Size streamSize,
    int sensorCropWidth,
    int sensorCropHeight
)
```

Converts a size relative to a specific camera stream to an equivalent size relative to the camera sensor.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size` | The size in the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. |
| `int sensorCropWidth` | The width of the sensor crop region. |
| `int sensorCropHeight` | The height of the sensor crop region. |

### mapStreamSizeToUiSizeF

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

```
public static final @NonNull SizeF mapStreamSizeToUiSizeF(
    @NonNull Size size,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    int sensorRotationToDisplayOrientation
)
```

Converts a size relative to a specific camera stream to an equivalent size relative to a UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size` | The size in the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapStreamSizeToUiSizeF(android.util.Size,android.util.Size,android.util.Size,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiPointToSensorPoint

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

```
public static final @NonNull Point mapUiPointToSensorPoint(
    @NonNull Point uiPoint,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation,
    @NonNull Rect sensorCrop,
    boolean coerceToCropRegion
)
```

Converts a point relative to a UI element to an equivalent point relative to the camera sensor.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint` | The point in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `boolean coerceToCropRegion` | Whether to coerce the output point into the crop region. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToSensorPoint(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Boolean)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiPointToSensorRect

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

```
public static final @NonNull Rect mapUiPointToSensorRect(
    @NonNull Point uiPoint,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation,
    @NonNull Rect sensorCrop,
    int minimumSensorSize,
    boolean coerceToCropRegion,
    float touchToFocusRatio
)
```

Converts a point relative to a UI element to an equivalent rectangle relative to the camera sensor.

The output rectangle will have a size determined by the `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToSensorRect(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Int,kotlin.Boolean,kotlin.Float)` and will be centered on the mapped point. If the calculated rectangle is smaller than `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToSensorRect(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Int,kotlin.Boolean,kotlin.Float)` in either dimension, it will be expanded symmetrically from its center to reach the minimum.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint` | The point in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `int minimumSensorSize` | The minimum allowed width and height for the output rectangle in sensor pixels. If the calculated rectangle is smaller than this value in either dimension, it will be expanded symmetrically from its center to reach the minimum. Defaults to `https://developer.android.com/reference/androidx/camera/common/CameraMath#DEFAULT_MIN_SENSOR_PIXELS()`. Set to `0` or less to disable this behavior. |
| `boolean coerceToCropRegion` | Whether to coerce the output rectangle into the crop region. |
| `float touchToFocusRatio` | The ratio to use when computing a rectangle based on the short dimension of the stream. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToSensorRect(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Int,kotlin.Boolean,kotlin.Float)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiPointToStreamPointF

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

```
public static final @NonNull PointF mapUiPointToStreamPointF(
    @NonNull Point uiPoint,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation
)
```

Converts a point relative to a UI element to an equivalent point relative to a specific camera stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint` | The point in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored (e.g., for front-facing camera). |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToStreamPointF(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiPointToStreamRectF

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

```
public static final @NonNull RectF mapUiPointToStreamRectF(
    @NonNull Point uiPoint,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation,
    float touchToFocusRatio
)
```

Converts a point relative to a UI element to an equivalent rectangle relative to a specific camera stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Point.html uiPoint` | The point in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `float touchToFocusRatio` | The ratio to use when computing a rectangle based on the short dimension of the stream. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiPointToStreamRectF(android.graphics.Point,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,kotlin.Float)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiRectToSensorRect

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

```
public static final @NonNull Rect mapUiRectToSensorRect(
    @NonNull RectF uiRect,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation,
    @NonNull Rect sensorCrop,
    int minimumSensorSize,
    boolean coerceToCropRegion
)
```

Converts a rectangle relative to a UI element to an equivalent rectangle relative to the camera sensor.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html uiRect` | The rectangle in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html sensorCrop` | The crop region of the sensor (typically `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#SCALER_CROP_REGION`, or `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` if no crop is applied). Sensor coordinates are relative to the sensor's top-left active pixel `(0,0)`. |
| `int minimumSensorSize` | The minimum allowed width and height for the output rectangle in sensor pixels. If the calculated rectangle is smaller than this value in either dimension, it will be expanded symmetrically from its center to reach the minimum. Defaults to `https://developer.android.com/reference/androidx/camera/common/CameraMath#DEFAULT_MIN_SENSOR_PIXELS()`. Set to `0` or less to disable this behavior. |
| `boolean coerceToCropRegion` | Whether to coerce the output rectangle into the crop region. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiRectToSensorRect(android.graphics.RectF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int,android.graphics.Rect,kotlin.Int,kotlin.Boolean)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiRectToStreamRectF

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

```
public static final @NonNull RectF mapUiRectToStreamRectF(
    @NonNull RectF uiRect,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    boolean streamMirroring,
    int sensorRotationToDisplayOrientation
)
```

Converts a rectangle relative to a UI element to an equivalent rectangle relative to a specific camera stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/RectF.html uiRect` | The rectangle in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `boolean streamMirroring` | Whether the camera stream is mirrored. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiRectToStreamRectF(android.graphics.RectF,android.util.Size,android.util.Size,kotlin.Boolean,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiSizeToSensorSize

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

```
public static final @NonNull Size mapUiSizeToSensorSize(
    @NonNull Size size,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    int sensorRotationToDisplayOrientation,
    int sensorCropWidth,
    int sensorCropHeight
)
```

Converts a size relative to a UI element to an equivalent size relative to the camera sensor.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size` | The size in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |
| `int sensorCropWidth` | The width of the sensor crop region. |
| `int sensorCropHeight` | The height of the sensor crop region. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiSizeToSensorSize(android.util.Size,android.util.Size,android.util.Size,kotlin.Int,kotlin.Int,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |

### mapUiSizeToStreamSizeF

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

```
public static final @NonNull SizeF mapUiSizeToStreamSizeF(
    @NonNull Size size,
    @NonNull Size uiSize,
    @NonNull Size streamSize,
    int sensorRotationToDisplayOrientation
)
```

Converts a size relative to a UI element to an equivalent size relative to a specific camera stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html size` | The size in the UI. UI coordinates are relative to `uiSize` and do not account for the positioning of the UI. Callers must normalize coordinates to account for clipping or padding before calling this function. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html uiSize` | The size of the UI (specifically the UI-relative size of the viewfinder, without accounting for clipping or padding). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Size.html streamSize` | The size of the camera stream. Stream coordinates are relative to the `streamWidth` and `streamHeight` boundaries. |
| `int sensorRotationToDisplayOrientation` | The orientation from sensor to display. Must be one of `0`, `90`, `180`, or `270`. Negative values are not supported. This can be computed using `https://developer.android.com/reference/androidx/camera/common/CameraMath#computeSensorRotationToDisplayOrientation(kotlin.Int,kotlin.Int,kotlin.Boolean)`. Value is one of the following: - `0` - `90` - `180` - `270` <br /> |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/androidx/camera/common/CameraMath#mapUiSizeToStreamSizeF(android.util.Size,android.util.Size,android.util.Size,kotlin.Int)` is not one of `0`, `90`, `180`, or `270`. |