# 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)

*** ** * ** ***


```
public final class DisplayOrientedMeteringPointFactory extends MeteringPointFactory
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.camera.core.MeteringPointFactory](https://developer.android.com/reference/androidx/camera/core/MeteringPointFactory) ||
|   | ↳ | [androidx.camera.core.DisplayOrientedMeteringPointFactory](https://developer.android.com/reference/androidx/camera/core/DisplayOrientedMeteringPointFactory) |

*** ** * ** ***

A `https://developer.android.com/reference/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/androidx/camera/core/MeteringPoint` which can then be used to construct a `https://developer.android.com/reference/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/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/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/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/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/androidx/camera/core/MeteringPoint` |   |

## Summary

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

| ### Inherited methods |
|---|
| From [androidx.camera.core.MeteringPointFactory](https://developer.android.com/reference/androidx/camera/core/MeteringPointFactory) |---|---| | `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/MeteringPoint` | `https://developer.android.com/reference/androidx/camera/core/MeteringPointFactory#createPoint(float,float)(float x, float y)` Creates a `https://developer.android.com/reference/androidx/camera/core/MeteringPoint` by x, y. | | `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/MeteringPoint` | `https://developer.android.com/reference/androidx/camera/core/MeteringPointFactory#createPoint(float,float,float)(float x, float y, float size)` Creates a `https://developer.android.com/reference/androidx/camera/core/MeteringPoint` by x, y, size. | | `static float` | `https://developer.android.com/reference/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)

```
public DisplayOrientedMeteringPointFactory(
    @NonNull Display display,
    @NonNull CameraInfo cameraInfo,
    float width,
    float height
)
```

Creates a `https://developer.android.com/reference/androidx/camera/core/DisplayOrientedMeteringPointFactory` for converting View (x, y) into a `https://developer.android.com/reference/androidx/camera/core/MeteringPoint` based on the current display's rotation and `https://developer.android.com/reference/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/androidx/camera/core/MeteringPoint`. Otherwise the (x, y) passed to `https://developer.android.com/reference/androidx/camera/core/MeteringPointFactory#createPoint(float,float)` should be adjusted to this coordinate system first.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Display.html display` | `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. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/CameraInfo cameraInfo` | the information for the `https://developer.android.com/reference/androidx/camera/core/Camera` to generate the metering point for |
| `float width` | the width of the coordinate which are mapped to the full camera preview FOV in given display's orientation. |
| `float height` | the height of the coordinate which are mapped to the full camera preview FOV in given display's orientation. |