Companion

object Companion

Functions

Link copied to clipboard
fun approximatePolygonAspectRatio(polygon: List<PointF>, frameWidth: Int, frameHeight: Int, frameOrientation: Int): Float

Approximate polygon aspect ratio.

Link copied to clipboard

Provide (clockwise) polygon, covering whole image {(0,0), (0,1), (1,1), (1,0)}.

Link copied to clipboard

Provide counter-clockwise polygon, covering whole image {(0,0), (1,0), (1,1), (0,1)}.

Link copied to clipboard

Converts a pixel coordinate to a normalized coordinate in 0, 1 range. Uses (dimension - 1) as divisor so that the first pixel maps to 0.0 and the last pixel maps exactly to 1.0, making round-trips through operations like rotation around (0.5, 0.5) mathematically correct. Returns 0.0 if dimension is 1 or less (degenerate image — no meaningful range).

Link copied to clipboard
fun normalizedToImageCoordinates(normalizedCoord: Float, dimension: Float): Float

Converts a normalized coordinate in 0, 1 range to a pixel coordinate. Uses (dimension - 1) as multiplier — the inverse of imageToNormalizedCoordinates. Returns 0.0 if dimension is 1 or less (degenerate image — no meaningful range).

Link copied to clipboard
fun rotatePolygon(polygon: List<PointF>, rotation: Float = 0.0f): List<PointF>

Rotate polygon.