ImageProxyTransformFactory

public final class ImageProxyTransformFactory
extends Object

java.lang.Object
   ↳ androidx.camera.view.transform.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

ImageProxyTransformFactory()

Public methods

OutputTransform getOutputTransform(ImageProxy imageProxy)

Extracts the transform from the given ImageProxy.

boolean isUsingCropRect()

Whether the factory respects the value of ImageProxy.getCropRect().

boolean isUsingRotationDegrees()

Whether the factory respects the value of ImageInfo.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.

Inherited methods

Public constructors

ImageProxyTransformFactory

public ImageProxyTransformFactory ()

Public methods

getOutputTransform

public OutputTransform getOutputTransform (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.

Parameters
imageProxy ImageProxy

Returns
OutputTransform

isUsingCropRect

public boolean isUsingCropRect ()

Whether the factory respects the value of ImageProxy.getCropRect().

By default, the value is false.

Returns
boolean

isUsingRotationDegrees

public boolean isUsingRotationDegrees ()

Whether the factory respects the value of ImageInfo.getRotationDegrees().

By default, the value is false.

Returns
boolean

setUsingCropRect

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).

Parameters
usingCropRect boolean

setUsingRotationDegrees

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 ImageInfo.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.

Parameters
usingRotationDegrees boolean