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

SensorOrientedMeteringPointFactory

public class SensorOrientedMeteringPointFactory
extends MeteringPointFactory

java.lang.Object
   ↳ androidx.camera.core.MeteringPointFactory
     ↳ androidx.camera.core.SensorOrientedMeteringPointFactory


A MeteringPointFactory that can create MeteringPoint by sensor oriented x, y , width and height.

This factory is suitable for apps that already have coordinates translated into sensor coordinates. It is also useful for apps that want to focus on something detected in ImageAnalysis. Apps can pass the ImageAnalysis instance for useCaseForFOV argument and CameraX will then adjust the final sensor coordinates by aspect ratio of ImageAnalysis.

Summary

Inherited constants

Inherited fields

Public constructors

SensorOrientedMeteringPointFactory(float width, float height)

Creates the SensorOrientedMeteringPointFactory by width and height

The width/height is the logical width/height of the preview FoV in sensor orientation and X/Y is the logical XY inside the FOV.

SensorOrientedMeteringPointFactory(float width, float height, UseCase useCaseForFOV)

Creates the SensorOrientedMeteringPointFactory by width, height and useCaseForFOV.

Protected methods

PointF translatePoint(float x, float y)

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

Inherited methods

Public constructors

SensorOrientedMeteringPointFactory

public SensorOrientedMeteringPointFactory (float width, 
                float height)

Creates the SensorOrientedMeteringPointFactory by width and height

The width/height is the logical width/height of the preview FoV in sensor orientation 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].

By default, it will use active Preview as the FoV for final coordinates translation.

Parameters
width float: the logical width of FoV in sensor orientation

height float: the logical height of FoV in sensor orientation

SensorOrientedMeteringPointFactory

public SensorOrientedMeteringPointFactory (float width, 
                float height, 
                UseCase useCaseForFOV)

Creates the SensorOrientedMeteringPointFactory by width, height and useCaseForFOV.

The width/height is the logical width/height of the preview FoV in sensor orientation 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].

useCaseForFOV is used to determine the FOV of this translation. This useCaseForFOV needs to be bound via CameraX.bindToLifecycle(LifecycleOwner, UseCase) first. Otherwise it will throw a IllegalStateException

Parameters
width float: the logical width of FOV in sensor orientation.

height float: the logical height of FOV in sensor orientation.

useCaseForFOV UseCase: the UseCase to be the FOV.

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,