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

SensorOrientedMeteringPointFactory

open class SensorOrientedMeteringPointFactory : MeteringPointFactory
kotlin.Any
   ↳ 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

Public constructors

<init>(width: Float, height: Float)

Creates the SensorOrientedMeteringPointFactory by width and height

<init>(width: Float, height: Float, @NonNull useCaseForFOV: UseCase)

Creates the SensorOrientedMeteringPointFactory by width, height and useCaseForFOV.

Protected methods

open PointF

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

Inherited functions

Inherited properties

Public constructors

<init>

SensorOrientedMeteringPointFactory(width: Float, height: Float)

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

<init>

SensorOrientedMeteringPointFactory(width: Float, height: Float, @NonNull useCaseForFOV: UseCase)

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 Float: the UseCase to be the FOV.

Protected methods

translatePoint

@NonNull protected open 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,