Camera2TransformationInfo


object Camera2TransformationInfo


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

Summary

Public functions

TransformationInfo
createFromCharacteristics(
    cameraCharacteristics: CameraCharacteristics,
    cropRectLeft: Float,
    cropRectTop: Float,
    cropRectRight: Float,
    cropRectBottom: Float
)

Creates TransformationInfo from the provided CameraCharacteristics and crop rect.

TransformationInfo
@RequiresApi(value = 33)
createFromCharacteristics(
    cameraCharacteristics: CameraCharacteristics,
    mirrorMode: Int,
    cropRectLeft: Float,
    cropRectTop: Float,
    cropRectRight: Float,
    cropRectBottom: Float
)

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

Public functions

createFromCharacteristics

Added in 1.5.0-beta01
fun createFromCharacteristics(
    cameraCharacteristics: CameraCharacteristics,
    cropRectLeft: Float = TransformationInfo.CROP_NONE,
    cropRectTop: Float = TransformationInfo.CROP_NONE,
    cropRectRight: Float = TransformationInfo.CROP_NONE,
    cropRectBottom: Float = TransformationInfo.CROP_NONE
): TransformationInfo

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
cameraCharacteristics: CameraCharacteristics

the camera characteristics of the camera being used to produce frames

cropRectLeft: Float = TransformationInfo.CROP_NONE

the optional left bound of a crop rect

cropRectTop: Float = TransformationInfo.CROP_NONE

the optional top bound of a crop rect

cropRectRight: Float = TransformationInfo.CROP_NONE

the optional right bound of a crop rect

cropRectBottom: Float = TransformationInfo.CROP_NONE

the optional bottom bound of a crop rect

createFromCharacteristics

Added in 1.5.0-beta01
@RequiresApi(value = 33)
fun createFromCharacteristics(
    cameraCharacteristics: CameraCharacteristics,
    mirrorMode: Int,
    cropRectLeft: Float = TransformationInfo.CROP_NONE,
    cropRectTop: Float = TransformationInfo.CROP_NONE,
    cropRectRight: Float = TransformationInfo.CROP_NONE,
    cropRectBottom: Float = TransformationInfo.CROP_NONE
): TransformationInfo

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
cameraCharacteristics: CameraCharacteristics

the camera characteristics of the camera being used to produce frames

mirrorMode: Int

the mirror mode set on OutputConfiguration.setMirrorMode

cropRectLeft: Float = TransformationInfo.CROP_NONE

the optional left bound of a crop rect

cropRectTop: Float = TransformationInfo.CROP_NONE

the optional top bound of a crop rect

cropRectRight: Float = TransformationInfo.CROP_NONE

the optional right bound of a crop rect

cropRectBottom: Float = TransformationInfo.CROP_NONE

the optional bottom bound of a crop rect