# DisplayOrientedMeteringPointFactory

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/DisplayOrientedMeteringPointFactory.java+class:androidx.camera.core.DisplayOrientedMeteringPointFactory) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

*** ** * ** ***


```
class DisplayOrientedMeteringPointFactory : MeteringPointFactory
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.camera.core.MeteringPointFactory](https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPointFactory) ||
|   | ↳ | [androidx.camera.core.DisplayOrientedMeteringPointFactory](https://developer.android.com/reference/kotlin/androidx/camera/core/DisplayOrientedMeteringPointFactory) |

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPointFactory` that can convert a `https://developer.android.com/reference/android/view/View.html` (x, y) into a `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` which can then be used to construct a `https://developer.android.com/reference/kotlin/androidx/camera/core/FocusMeteringAction` to start a focus and metering action.

For apps showing full camera preview in a View without any scaling, cropping or rotating applied, they can simply use view width and height to create the `https://developer.android.com/reference/kotlin/androidx/camera/core/DisplayOrientedMeteringPointFactory` and then pass `https://developer.android.com/reference/android/view/View.html` (x, y) to create a `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint`. This factory will convert the (x, y) into the sensor (x, y) based on display rotation and lensFacing.

If camera preview is scaled, cropped or rotated in the `https://developer.android.com/reference/android/view/View.html`, it is applications' duty to transform the coordinates properly so that the width and height of this factory represents the full Preview FOV and also the (x,y) passed to create `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` needs to be adjusted by apps to the coordinates left-top (0,0) - right-bottom (width, height). For example, if the preview is scaled to 2X from the center and is cropped in a `https://developer.android.com/reference/android/view/View.html`. Assuming that the dimension of View is (240, 320), then the width/height of this `https://developer.android.com/reference/kotlin/androidx/camera/core/DisplayOrientedMeteringPointFactory` should be (480, 640). And the (x, y) from the `https://developer.android.com/reference/android/view/View.html` should be converted to (x + (480-240)/2, y + (640 - 320)/2) first.

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/DisplayOrientedMeteringPointFactory#DisplayOrientedMeteringPointFactory(android.view.Display,androidx.camera.core.CameraInfo,float,float)( display: https://developer.android.com/reference/android/view/Display.html, cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/DisplayOrientedMeteringPointFactory` for converting View (x, y) into a `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` based on the current display's rotation and `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`. |

| ### Inherited functions |
|---|
| From [androidx.camera.core.MeteringPointFactory](https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPointFactory) |---|---| | `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` | `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPointFactory#createPoint(float,float)(x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` by x, y. | | `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` | `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPointFactory#createPoint(float,float,float)(x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` by x, y, size. | | `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPointFactory#getDefaultPointSize()()` Returns default point size. | |

## Public constructors

### DisplayOrientedMeteringPointFactory

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

```
DisplayOrientedMeteringPointFactory(
    display: Display,
    cameraInfo: CameraInfo,
    width: Float,
    height: Float
)
```

Creates a `https://developer.android.com/reference/kotlin/androidx/camera/core/DisplayOrientedMeteringPointFactory` for converting View (x, y) into a `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint` based on the current display's rotation and `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`.

The width/height of this factory forms a coordinate left-top (0, 0) - right-bottom (width, height) which represents the full camera preview FOV in the display's orientation. For apps showing full camera preview in a `https://developer.android.com/reference/android/view/View.html`, it is as simple as passing View's width/height and passing View (x, y) directly to create a `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPoint`. Otherwise the (x, y) passed to `https://developer.android.com/reference/kotlin/androidx/camera/core/MeteringPointFactory#createPoint(float,float)` should be adjusted to this coordinate system first.

| Parameters |
|---|---|
| `display: https://developer.android.com/reference/android/view/Display.html` | `https://developer.android.com/reference/android/view/Display.html` to get the orientation from. This should be the current display where camera preview is showing. |
| `cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` | the information for the `https://developer.android.com/reference/kotlin/androidx/camera/core/Camera` to generate the metering point for |
| `width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the width of the coordinate which are mapped to the full camera preview FOV in given display's orientation. |
| `height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the height of the coordinate which are mapped to the full camera preview FOV in given display's orientation. |