DisplayOrientedMeteringPointFactory

public final class DisplayOrientedMeteringPointFactory
extends MeteringPointFactory

java.lang.Object
   ↳ 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

Inherited fields

Public constructors

DisplayOrientedMeteringPointFactory(Context context, CameraX.LensFacing lensFacing, float width, float height)

Creates the MeteringPointFactory with default display orientation.

DisplayOrientedMeteringPointFactory(Display display, CameraX.LensFacing lensFacing, float width, float height)

Creates the MeteringPointFactory with custom display orientation.

Protected methods

PointF translatePoint(float x, float y)

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

Inherited methods

Public constructors

DisplayOrientedMeteringPointFactory

public DisplayOrientedMeteringPointFactory (Context context, 
                CameraX.LensFacing lensFacing, 
                float width, 
                float height)

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 CameraX.LensFacing: current lens facing.

width float: the logical width of FoV in current display orientation.

height float: the logical height of FoV in current display orientation.

DisplayOrientedMeteringPointFactory

public DisplayOrientedMeteringPointFactory (Display display, 
                CameraX.LensFacing lensFacing, 
                float width, 
                float height)

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 CameraX.LensFacing: current lens facing.

width float: the logical width of FoV in current display orientation.

height float: the logical height of FoV in current display orientation.

Protected methods

translatePoint

protected PointF translatePoint (float x, 
                float y)

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.

Returns
PointF a PointF consisting of translated normalized crop region x/y,