ImageMath
Kotlin wrapper for ARDK ImageMath functions. Each function returns an [android.graphics.Matrix] corresponding to a 3×3 affine or projective transformation.
Declaration
object ImageMathFunctions
| Name | Type | Summary |
|---|---|---|
| affineCrop | Matrix | Returns an affine transformation that crops the source size to match the aspect ratio of the target size. |
| affineFit | Matrix | Returns an affine transformation that maps normalized coordinates in the source frame to normalized coordinates in the target frame. |
| affineInvertHorizontal | Matrix | Returns an affine matrix for horizontal mirroring. Maps (u, v) → (1 - u, v). |
| affineInvertVertical | Matrix | Returns an affine matrix for vertical mirroring. Maps (u, v) → (u, 1 - v). |
| affineRotation | Matrix | Returns an (u, v) -> (u', v') transformation that represents a 2D affine rotation. |
| affineScaling | Matrix | Returns an (u, v) -> (u', v') transformation that represents a 2D affine scaling. |
| affineTranslation | Matrix | Returns an (u, v) -> (u', v') transformation that represents a 2D affine translation. |
| calculateDeviceRotation | Matrix | Returns an affine transform that rotates between two interface orientations around the center. This method models physical device rotation. |
| calculateViewRotation | Matrix | Returns an affine transform that rotates between two interface orientations around the center. This method models UI rotation (opposite to physical device rotation). |
| concatenating | Matrix | Returns a new [Matrix] representing the concatenation of this matrix with another matrix, mimicking the behavior of CoreGraphics’ concatenating(_:) method on iOS. |
| displayTransform | Matrix | Returns an affine transform [Matrix] that maps normalized image coordinates into a coordinate space suitable for rendering the camera image in the given viewport and orientation. |
| logAffine | void | Logs the affine components of this [Matrix] in a readable format. Prints the matrix in iOS-style notation: a, b, c, d, tx, ty corresponding to the 2×3 affine transform: [ a c tx ] [ b d ty ] |
| logMatrix | void | Logs the contents of this [Matrix] as a 3×3 matrix. The matrix values are printed in row-major order, as used internally by [android.graphics.Matrix]. Useful for debugging transformations like scale, rotation, skew, and perspective. |
| reprojection | Matrix | Returns a 3×3 homography matrix ( android.graphics.Matrix) that reprojects image coordinates from a reference camera view into a target camera view. This is typically used to transform 2D image-space coordinates (normalized in [0..1]) from one camera perspective to another, e.g. for aligning visual overlays between AR frames. |
| reprojectPoints | void | Applies a full 3×3 projective transformation (homography) to a set of 2D points, using this [Matrix] as a homography matrix. Unlike [Matrix.mapPoints], this method correctly applies the bottom row of the matrix and performs the required perspective divide. Transformed points are clamped to the [-1f..2f] range to ensure compatibility with UI constraints. |