CoordinateTransform
public final class CoordinateTransform
This class represents the transform from one OutputTransform to another.
This class can be used to map the coordinates of one OutputTransform to another, given that they are associated with the same ViewPort. OutputTransform can represent the output of a UseCase or PreviewView. For example, mapping the coordinates of detected objects from ImageAnalysis output to the drawing location in PreviewView.
// imageProxy the output of an ImageAnalysis. OutputTransform source = ImageProxyTransformFactory().getOutputTransform(imageProxy); OutputTransform target = previewView.getOutputTransform(); // Build the transform from ImageAnalysis to PreviewView CoordinateTransform coordinateTransform = new CoordinateTransform(source, target); // Detect face in ImageProxy and transform the coordinates to PreviewView. // The value of faceBox can be used to highlight the face in PreviewView. RectF faceBox = detectFaceInImageProxy(imageProxy); coordinateTransform.mapRect(faceBox);
Summary
Public constructors |
|---|
CoordinateTransform(Creates the transform between the |
Public methods |
|
|---|---|
void |
Apply this transform to the |
void |
Apply this transform to the array of 2D points, and write the transformed points back into the array |
void |
Apply this transform to the rectangle, and write the transformed rectangle back into it. |
void |
Copies the current transform to the specified |
Public constructors
CoordinateTransform
public CoordinateTransform(
@NonNull OutputTransform source,
@NonNull OutputTransform target
)
Creates the transform between the source and the target.
The source and the target must be associated with the same ViewPort.
| Parameters | |
|---|---|
@NonNull OutputTransform source |
the source |
@NonNull OutputTransform target |
the target |
| See also | |
|---|---|
UseCaseGroup |
|
ViewPort |
Public methods
mapPoint
public void mapPoint(@NonNull PointF point)
Apply this transform to the PointF, and write the transformed points back into the array
mapPoints
public void mapPoints(@NonNull float[] points)
Apply this transform to the array of 2D points, and write the transformed points back into the array
| Parameters | |
|---|---|
@NonNull float[] points |
The array [x0, y0, x1, y1, ...] of points to transform. |
| See also | |
|---|---|
mapPoints |