ImageProxyTransformFactory

@RequiresApi(value = 21)
public final class ImageProxyTransformFactory


Factory for extracting transform info from ImageProxy.

This class is for extracting a OutputTransform from an ImageProxy object. The OutputTransform represents the transform being applied to the original camera buffer, which can be used by CoordinateTransform to transform coordinates between UseCases.

Summary

Public constructors

Public methods

@NonNull OutputTransform

Extracts the transform from the given ImageProxy.

boolean

Whether the factory respects the value of getCropRect.

boolean

Whether the factory respects the value of getRotationDegrees.

void
setUsingCropRect(boolean usingCropRect)

Whether to use the crop rect of the ImageProxy.

void
setUsingRotationDegrees(boolean usingRotationDegrees)

Whether to use the rotation degrees of the ImageProxy.

Public constructors

ImageProxyTransformFactory

Added in 1.1.0
public ImageProxyTransformFactory()

Public methods

getOutputTransform

Added in 1.1.0
public @NonNull OutputTransform getOutputTransform(@NonNull ImageProxy imageProxy)

Extracts the transform from the given ImageProxy.

This method returns a OutputTransform that represents the transform applied to the buffer of a ImageProxy based on factory settings. An ImageProxy can be the output of ImageAnalysis or in-memory ImageCapture.

isUsingCropRect

Added in 1.1.0
public boolean isUsingCropRect()

Whether the factory respects the value of getCropRect.

By default, the value is false.

isUsingRotationDegrees

Added in 1.1.0
public boolean isUsingRotationDegrees()

Whether the factory respects the value of getRotationDegrees.

By default, the value is false.

setUsingCropRect

Added in 1.1.0
public void setUsingCropRect(boolean usingCropRect)

Whether to use the crop rect of the ImageProxy.

By default, the value is false and the factory uses the ImageProxy's entire buffer. Only set this value if the coordinates to be transformed respect the crop rect. For example, top-left corner of the crop rect is (0, 0).

setUsingRotationDegrees

Added in 1.1.0
public void setUsingRotationDegrees(boolean usingRotationDegrees)

Whether to use the rotation degrees of the ImageProxy.

By default, the value is false and the factory uses a rotation degree of 0. Only set this value to true if the coordinates to be transformed is after the rotation degree is applied. For example, if the getRotationDegrees is 90 degrees, (0, 0) in the original buffer should be mapped to (height, 0) in the rotated image. Set this value to true if the input coordinates are based on the original image, and false if the coordinates are based on the rotated image.