Camera2TransformationInfo


public static class Camera2TransformationInfo


Utilities for generating TransformationInfo for use with {@docRoot]media/camera/camera2

Summary

Public methods

static final @NonNull TransformationInfo
createFromCharacteristics(
    @NonNull CameraCharacteristics cameraCharacteristics,
    float cropRectLeft,
    float cropRectTop,
    float cropRectRight,
    float cropRectBottom
)

Creates TransformationInfo from the provided CameraCharacteristics and crop rect.

static final @NonNull TransformationInfo
@RequiresApi(value = 33)
createFromCharacteristics(
    @NonNull CameraCharacteristics cameraCharacteristics,
    int mirrorMode,
    float cropRectLeft,
    float cropRectTop,
    float cropRectRight,
    float cropRectBottom
)

Creates TransformationInfo from the provided CameraCharacteristics, crop rect, and mirror mode.

Public fields

INSTANCE

Added in 1.5.0-beta01
public static @NonNull Camera2TransformationInfo INSTANCE

Public methods

createFromCharacteristics

Added in 1.5.0-beta01
public static final @NonNull TransformationInfo createFromCharacteristics(
    @NonNull CameraCharacteristics cameraCharacteristics,
    float cropRectLeft,
    float cropRectTop,
    float cropRectRight,
    float cropRectBottom
)

Creates TransformationInfo from the provided CameraCharacteristics and crop rect.

When using a viewfinder with {@docRoot]media/camera/camera2, this will generate the appropriate TransformationInfo to display the camera frames upright.

The crop rect will specify a region of interest (ROI) within the original buffer to treat as the buffer dimensions. When displaying the ROI in a viewfinder, depending on the scale mode, the crop rect bounding box should line up with the edges of the viewfinder, but pixels outside the bounding box will not necessarily be hidden if they still land within the bounds of the viewfinder.

Parameters
@NonNull CameraCharacteristics cameraCharacteristics

the camera characteristics of the camera being used to produce frames

float cropRectLeft

the optional left bound of a crop rect

float cropRectTop

the optional top bound of a crop rect

float cropRectRight

the optional right bound of a crop rect

float cropRectBottom

the optional bottom bound of a crop rect

createFromCharacteristics

Added in 1.5.0-beta01
@RequiresApi(value = 33)
public static final @NonNull TransformationInfo createFromCharacteristics(
    @NonNull CameraCharacteristics cameraCharacteristics,
    int mirrorMode,
    float cropRectLeft,
    float cropRectTop,
    float cropRectRight,
    float cropRectBottom
)

Creates TransformationInfo from the provided CameraCharacteristics, crop rect, and mirror mode.

When using a viewfinder with {@docRoot]media/camera/camera2, this will generate the appropriate TransformationInfo to display the camera frames upright.

The crop rect will specify a region of interest (ROI) within the original buffer to treat as the buffer dimensions. When displaying the ROI in a viewfinder, depending on the scale mode, the crop rect bounding box should line up with the edges of the viewfinder, but pixels outside the bounding box will not necessarily be hidden if they still land within the bounds of the viewfinder.

The mirror mode is one of OutputConfiguration.MIRROR_MODE_AUTO, OutputConfiguration.MIRROR_MODE_NONE, OutputConfiguration.MIRROR_MODE_H, or OutputConfiguration.MIRROR_MODE_NONE, and should match what was set on OutputConfiguration.setMirrorMode. Note that before API level 33, the default behavior was equivalent to OutputConfiguration.MIRROR_MODE_AUTO.

Parameters
@NonNull CameraCharacteristics cameraCharacteristics

the camera characteristics of the camera being used to produce frames

int mirrorMode

the mirror mode set on OutputConfiguration.setMirrorMode

float cropRectLeft

the optional left bound of a crop rect

float cropRectTop

the optional top bound of a crop rect

float cropRectRight

the optional right bound of a crop rect

float cropRectBottom

the optional bottom bound of a crop rect