public final class DisplayOrientedMeteringPointFactory
extends MeteringPointFactory

   ↳ androidx.camera.core.MeteringPointFactory
     ↳ androidx.camera.core.DisplayOrientedMeteringPointFactory

A MeteringPointFactory that can convert a View (x, y) into a MeteringPoint which can then be used to construct a 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 DisplayOrientedMeteringPointFactory and then pass View (x, y) to create a 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 View, 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 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 View. Assuming that the dimension of View is (240, 320), then the width/height of this DisplayOrientedMeteringPointFactory should be (480, 640). And the (x, y) from the View should be converted to (x + (480-240)/2, y + (640 - 320)/2) first.

See also:


Public constructors

DisplayOrientedMeteringPointFactory(Display display, CameraInfo cameraInfo, float width, float height)

Creates a DisplayOrientedMeteringPointFactory for converting View (x, y) into a MeteringPoint based on the current display's rotation and CameraInfo.

Inherited methods