Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

DisplayOrientedMeteringPointFactory

class DisplayOrientedMeteringPointFactory : MeteringPointFactory
kotlin.Any
   ↳ androidx.camera.core.MeteringPointFactory
   ↳ androidx.camera.core.DisplayOrientedMeteringPointFactory

A MeteringPointFactory that can create MeteringPoint by display oriented x, y.

This factory will consider the current display rotation and the lens facing to translate the x/y correctly. Using this factory, apps do not need to handle the device rotation. They can simply pass the x/y retrieved from their View. However if the camera preview is cropped, scaled or rotated, it is apps' duty to transform the coordinates first.

The width/height of this factory is the logical width/height of the preview FoV and X/Y is the logical XY inside the FOV. User can set the width and height to 1.0 which will make the XY the normalized coordinates [0..1].

Summary

Inherited constants

Public constructors

<init>(@NonNull context: Context, @NonNull lensFacing: CameraX.LensFacing, width: Float, height: Float)

Creates the MeteringPointFactory with default display orientation.

<init>(@NonNull display: Display, @NonNull lensFacing: CameraX.LensFacing, width: Float, height: Float)

Creates the MeteringPointFactory with custom display orientation.

Protected methods

PointF

Translates a logical x/y into the normalized crop region x/y.

Inherited functions

Inherited properties

Public constructors

<init>

DisplayOrientedMeteringPointFactory(@NonNull context: Context, @NonNull lensFacing: CameraX.LensFacing, width: Float, height: Float)

Creates the MeteringPointFactory with default display orientation.

The width/height is the logical width/height of the preview FoV and X/Y is the logical XY inside the FOV. User can set the width and height to 1.0 which will make the XY the normalized coordinates [0..1]. Or user can set the width/height to the View width/height and then X/Y becomes the X/Y in the view.

Parameters
context Context: context to get the WindowManager for default display rotation.
lensFacing Context: current lens facing.
width Context: the logical width of FoV in current display orientation.
height Context: the logical height of FoV in current display orientation.

<init>

DisplayOrientedMeteringPointFactory(@NonNull display: Display, @NonNull lensFacing: CameraX.LensFacing, width: Float, height: Float)

Creates the MeteringPointFactory with custom display orientation. This is used in multi-display situation.

The width/height is the logical width/height of the preview FoV and X/Y is the logical XY inside the FOV. User can set the width and height to 1.0 which will make the XY the normalized coordinates [0..1]. Or user can set the width/height to the View width/height and then X/Y becomes the X/Y in the view. Display is used to dete

Parameters
display Display: Display to get the orientation from.
lensFacing Display: current lens facing.
width Display: the logical width of FoV in current display orientation.
height Display: the logical height of FoV in current display orientation.

Protected methods

translatePoint

@NonNull protected fun translatePoint(x: Float, y: Float): PointF

Translates a logical x/y into the normalized crop region x/y.

The logical x/y is with respect to related to the implementations. Implementations specify the logical width/height and define the orientation of the area. Some are sensor-oriented and some are display-oriented. The logical x/y is the position from the area defined by the width , height and the orientation. Implementation must implement this method for coordinates translation.

Parameters
x Float: the logical x to be translated.
y Float: the logical y to be translated.
Return
PointF: a PointF consisting of translated normalized crop region x/y,