Skip to main content
←API Reference ←NSDK

ImageMath


Declaration​

struct ImageMath

Summary​

Provides affine transformation utilities for image processing. All affine matrices returned by this class operate in normalized coordinates, where image space is mapped to the [0, 1] range in both axes with origin at top-left.


Methods​

NameTypeSummary
static affineCropCGAffineTransform
Returns an affine transformation that crops the source size to match the aspect ratio of the target size.
static affineFitCGAffineTransform
Returns an affine transformation that maps normalized coordinates in the source frame to normalized coordinates in the target frame.
static affineInvertHorizontalCGAffineTransform
Returns an (u, v) -> (u', v') transformation that represents a horizontal mirroring, i.e. (u, v) -> (1 - u, v).
static affineInvertVerticalCGAffineTransform
Returns an (u, v) -> (u', v') transformation that represents a vertical mirroring, i.e. (u, v) -> (u, 1 - v).
static affineRotationCGAffineTransform
Returns an (u, v) -> (u', v') transformation that represents a 2D affine rotation.
static affineScalingCGAffineTransform
Returns an (u, v) -> (u', v') transformation that represents a 2D affine scaling.
static affineTranslationCGAffineTransform
Returns an (u, v) -> (u', v') transformation that represents a 2D affine translation.
static deviceRotationCGAffineTransform
Returns an affine transform that rotates between two interface orientations around the center.
This method models physical device rotation.
For example, rotating from .landscapeRight to .portrait results in a clockwise transform.
static displayTransformCGAffineTransform
Returns an affine transform that maps normalized image coordinates
into a coordinate space suitable for rendering the camera image
in the given viewport and orientation.
This method replicates ARKit’s displayTransform(for:viewportSize:)
by computing a transform that accounts for the camera image’s
aspect ratio, the device’s interface orientation, and the desired
viewport size.
static reprojectionmatrix_float3x3
Returns a 3×3 homography matrix as matrix_float3x3 that reprojects
image coordinates from a reference camera view into a target camera view.
The image coordinates are expected to be normalized [0..1].
static viewRotationCGAffineTransform
Returns an affine transform that rotates between two interface orientations around the center.
This method models UI rotation (opposite to physical device rotation).
For example, rotating from .landscapeRight to .portrait results in a counter-clockwise transform.