DisplayOrientedMeteringPointFactory
class DisplayOrientedMeteringPointFactory : MeteringPointFactory
kotlin.Any | ||
↳ | 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.
Summary
Public constructors | |
---|---|
<init>(@NonNull display: Display, @NonNull cameraInfo: CameraInfo, width: Float, height: Float) Creates a |
Inherited functions | |
---|---|
Public constructors
<init>
DisplayOrientedMeteringPointFactory(
@NonNull display: Display,
@NonNull cameraInfo: CameraInfo,
width: Float,
height: Float)
Creates a DisplayOrientedMeteringPointFactory
for converting View (x, y) into a MeteringPoint
based on the current display's rotation and CameraInfo
.
The width/height of this factory forms a coordinate left-top (0, 0) - right-bottom (width, height) which represents the full camera preview FOV in the display's orientation. For apps showing full camera preview in a View
, it is as simple as passing View's width/height and passing View (x, y) directly to create a MeteringPoint
. Otherwise the (x, y) passed to MeteringPointFactory#createPoint(float, float)
should be adjusted to this coordinate system first.
Parameters | |
---|---|
display |
Display: Display to get the orientation from. This should be the current display where camera preview is showing. |
cameraInfo |
CameraInfo: the information for the Camera to generate the metering point for |
width |
Float: the width of the coordinate which are mapped to the full camera preview FOV in given display's orientation. |
height |
Float: the height of the coordinate which are mapped to the full camera preview FOV in given display's orientation. |