fiducial_marker

    Pure MoonBit fiducial marker detection, perspective normalization, ArUco/AprilTag grid decoding, error correction, and 3D pose estimation library.

    fiducial-marker
    aruco
    apriltag
    computer-vision
    pose-estimation
    Download zip
    Version
    0.1.1
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    47

    No dependencies

    #MoonBit Fiducial Marker

    A pure MoonBit toolkit for planar fiducial markers, image processing, camera geometry, pose estimation, tracking, and calibration. It targets robotics, visual localization, AR overlays, inspection, and other applications that need a dependency-light marker pipeline.

    The module identifier is 2515050242/fiducial_marker and the project uses Apache-2.0 licensing.

    #Core capabilities

    • ArUco and AprilTag dictionaries with rotation-aware Hamming matching and custom dictionary generation.
    • Grayscale image primitives, NetPBM PGM/PPM I/O, adaptive/global thresholding, morphology, filtering, gradients, connected components, contours, and corner detection.
    • Quadrilateral extraction, homography estimation, perspective sampling, marker decoding, and SVG/terminal visualization.
    • Camera intrinsics with Brown-Conrady distortion, Rodrigues/quaternion conversions, IPPE/EPnP/PnP/RANSAC pose solvers, reprojection metrics, and stereo triangulation.
    • GridBoard, ChArUco, diamond markers, Zhang calibration, bundle adjustment, Kalman/EKF tracking, optical flow, and video-frame buffering.
    • Pure MoonBit implementation with no C/C++ or foreign-function dependency in the package.

    #Standards and provenance

    The detector, image-processing, geometry, pose, and tracking code is an independent MoonBit implementation. The predefined ArUco and AprilTag codeword tables and bit layouts are included for interoperability with the published standards and reference implementations. Source references and the applicable upstream notices are recorded in THIRD_PARTY_NOTICES.md.

    The package does not bundle upstream C/C++ implementation code and does not link to a foreign-function library at runtime.

    #Quick start

    Use the module from another MoonBit project:

    moon add 2515050242/fiducial_marker moon check --target all moon test --target all

    The public API is available from the root package. A typical application creates a dictionary, loads or renders an Image, calls detect_markers, and optionally passes each detected quad to estimate_marker_pose.

    For a local smoke run:

    moon run cmd/marker_cli

    #CLI

    cmd/marker_cli loads representative dictionaries, renders a 3D synthetic scene, exercises tracking and pose-related smoke paths, then measures detector throughput on reproducible planar marker frames.

    The CLI benchmark reports measured wall-clock time through MoonBit's monotonic benchmark clock. It does not use fixed latency constants. Results depend on the host, backend, compiler mode, image size, and iteration count.

    | Resolution | Dimensions | Frame Latency (ms) | Throughput (FPS) | Detection Rate | | :--- | :--- | :--- | :--- | :--- | | QVGA | 320x240 | 15.97 | 62 | 100% | | VGA | 640x480 | 57.56 | 17 | 100% |

    The table above is one native verification run on the local Windows x64 environment with Moonc 0.10.9. Re-run moon run cmd/marker_cli before comparing machines or releases. The throughput baseline uses deterministic generated planar marker frames with a white margin to keep host-to-host comparisons reproducible. For deployment evaluation, rerun the same CLI against representative captured camera frames. The 3D synthetic scene is a deterministic end-to-end smoke case and is reported separately from the throughput baseline.

    #Architecture

    core types and matrices | image + filtering + morphology | contours + corners + quadrilateral extraction | homography + perspective sampling + dictionary decoding | pose, calibration, board, tracking, optical flow, and I/O | cmd/marker_cli

    Implementation is split into focused root-package files. Important entry points include:

    • types.mbt, matrix*.mbt, quaternion.mbt: geometry and linear algebra.
    • image.mbt, filter.mbt, threshold.mbt, morphology.mbt: image processing.
    • contour.mbt, corner.mbt, quad.mbt, homography.mbt, perspective.mbt: candidate extraction and normalization.
    • dictionary*.mbt, decoder.mbt, detector.mbt: codebooks and marker recognition.
    • pose.mbt, pnp.mbt, epnp.mbt, ippe.mbt, calibration.mbt: camera and pose estimation.
    • tracker.mbt, optical_flow.mbt, video_stream.mbt: temporal processing.
    • synthetic.mbt, synthetic_dataset_generator.mbt: reproducible test data and evaluation frames.

    #Tests and validation

    The repository includes unit, property, integration, stress, robustness, dictionary-compatibility, and benchmark tests.

    moon fmt --check moon check --target all moon info moon test --target all moon run cmd/marker_cli

    Tests cover empty and degenerate inputs, singular systems, dictionary boundaries, corrupted payloads, image-processing edges, pose and calibration paths, tracking state transitions, and multi-frame workloads.

    #CI

    GitHub Actions runs the stable MoonBit toolchain on Ubuntu, macOS, and Windows. Each job checks the toolchain version, formats the source, type-checks every backend, builds/tests every backend, and verifies that generated package interfaces are reproducible.

    The workflow is .github/workflows/ci.yml.

    #License

    Apache License 2.0. See LICENSE. Compatibility-data notices are listed in THIRD_PARTY_NOTICES.md.

    BaObservation

    pub(all) struct BaObservation {
    camera_index : Int
    point_index : Int
    image_point : Point2D
    } derive(Eq,
    Debug
    )

    Observation in bundle adjustment: a 2D image observation of a 3D point in a specific camera frame.

    BenchmarkResult

    pub(all) struct BenchmarkResult {
    resolution_name : String
    width : Int
    height : Int
    iterations : Int
    successful_iterations : Int
    detection_rate : Double
    total_time_ms : Double
    fps : Double
    latency_per_frame_ms : Double
    } derive(Eq,
    Debug
    )

    Comprehensive Performance and Throughput Benchmark Suite. Measures real-time processing latency and FPS across various resolutions.

    BenchmarkResult::new

    fn BenchmarkResult::new(resolution_name : String, width : Int, height : Int, iterations : Int, total_time_ms : Double, successful_iterations? : Int) -> BenchmarkResult

    Creates a BenchmarkResult record.

    BundleAdjustmentProblem

    pub(all) struct BundleAdjustmentProblem {
    camera_intrinsics : CameraIntrinsics
    camera_poses : Array[Pose3D]
    points_3d : Array[Point3D]
    observations : Array[BaObservation]
    } derive(Eq,
    Debug
    )

    Bundle Adjustment problem setup with camera keyframes and 3D landmark points.

    BundleAdjustmentProblem::new

    Creates a new BundleAdjustmentProblem.

    BundleAdjustmentProblem::optimize

    fn BundleAdjustmentProblem::optimize(self : BundleAdjustmentProblem, max_iterations? : Int) -> Unit

    Optimizes camera poses and 3D points simultaneously using Levenberg-Marquardt bundle adjustment.

    CalibrationFrame

    pub(all) struct CalibrationFrame {
    object_points : Array[Point3D]
    image_points : Array[Point2D]
    } derive(Eq,
    Debug
    )

    A single calibration frame containing 3D object points and corresponding 2D detected image corners.

    CalibrationFrame::new

    fn CalibrationFrame::new(object_points : Array[Point3D], image_points : Array[Point2D]) -> CalibrationFrame

    Creates a new CalibrationFrame.

    CalibrationResult

    pub(all) struct CalibrationResult {
    camera_intrinsics : CameraIntrinsics
    extrinsic_poses : Array[Pose3D]
    per_view_errors : Array[Double]
    overall_rmse : Double
    } derive(Eq,
    Debug
    )

    Result of camera calibration procedure.

    CameraCalibrator

    pub(all) struct CameraCalibrator {
    image_size : Size2D
    frames : Array[CalibrationFrame]
    } derive(Eq,
    Debug
    )

    Container for collecting multi-view calibration data from ChArUco / Chessboard frames.

    CameraCalibrator::add_frame

    fn CameraCalibrator::add_frame(self : CameraCalibrator, object_points : Array[Point3D], image_points : Array[Point2D]) -> Unit

    Adds a calibration frame with detected point correspondences.

    CameraCalibrator::new

    fn CameraCalibrator::new(image_size : Size2D) -> CameraCalibrator

    Creates a new CameraCalibrator.

    CameraIntrinsics

    pub(all) struct CameraIntrinsics {
    fx : Double
    fy : Double
    cx : Double
    cy : Double
    k1 : Double
    k2 : Double
    p1 : Double
    p2 : Double
    k3 : Double
    } derive(Eq,
    Debug
    )

    Camera intrinsic parameters (Pinhole camera model with Brown-Conrady distortion).

    CameraIntrinsics::new

    fn CameraIntrinsics::new(fx : Double, fy : Double, cx : Double, cy : Double) -> CameraIntrinsics

    Creates standard pinhole camera intrinsics without distortion.

    CameraIntrinsics::with_distortion

    fn CameraIntrinsics::with_distortion(fx : Double, fy : Double, cx : Double, cy : Double, k1 : Double, k2 : Double, p1 : Double, p2 : Double, k3 : Double) -> CameraIntrinsics

    Creates full pinhole camera intrinsics with radial & tangential distortion.

    CharucoBoard

    pub(all) struct CharucoBoard {
    squares_x : Int
    squares_y : Int
    square_length : Double
    marker_length : Double
    dictionary : MarkerDictionary
    chessboard_corners : Array[Point3D]
    marker_ids : Array[Int]
    marker_corners : Array[Array[Point3D]]
    } derive(Eq,
    Debug
    )

    Definition of a ChArUco Board (Chessboard + ArUco markers).

    CharucoBoard::new

    fn CharucoBoard::new(squares_x : Int, squares_y : Int, square_length : Double, marker_length : Double, dictionary : MarkerDictionary) -> CharucoBoard

    Creates a new ChArUco Board.

    CharucoCorners

    pub(all) struct CharucoCorners {
    corner_ids : Array[Int]
    image_corners : Array[Point2D]
    object_corners : Array[Point3D]
    } derive(Eq,
    Debug
    )

    Result of ChArUco corner interpolation.

    ColorHSV

    pub(all) struct ColorHSV {
    h : Double
    s : Double
    v : Double
    } derive(Default, Eq,
    Debug
    )

    Represents HSV color with H in [0, 360), S in [0, 1], V in [0, 1].

    ColorHSV::new

    fn ColorHSV::new(h : Double, s : Double, v : Double) -> ColorHSV

    Creates a new ColorHSV.

    ColorHSV::to_rgb

    fn ColorHSV::to_rgb(self : ColorHSV) -> ColorRGB

    Converts HSV to RGB.

    ColorImage

    pub(all) struct ColorImage {
    width : Int
    height : Int
    data : Array[ColorRGB]
    } derive(Eq,
    Debug
    )

    Represents a 24-bit RGB Color Image.

    ColorImage::get

    fn ColorImage::get(self : ColorImage, x : Int, y : Int) -> ColorRGB

    Gets RGB pixel at (x, y).

    ColorImage::new

    fn ColorImage::new(width : Int, height : Int) -> ColorImage

    Creates a new ColorImage.

    ColorImage::set

    fn ColorImage::set(self : ColorImage, x : Int, y : Int, color : ColorRGB) -> Unit

    Sets RGB pixel at (x, y).

    ColorImage::to_grayscale

    fn ColorImage::to_grayscale(self : ColorImage) -> Image

    Converts 24-bit ColorImage to 8-bit grayscale Image.

    ColorImage::to_ppm

    fn ColorImage::to_ppm(self : ColorImage) -> String

    Exports a 24-bit ColorImage to NetPBM PPM (P3 ASCII format) string.

    ColorRGB

    pub(all) struct ColorRGB {
    r : Int
    g : Int
    b : Int
    } derive(Default, Eq,
    Debug
    )

    Represents an 8-bit RGB color.

    ColorRGB::new

    fn ColorRGB::new(r : Int, g : Int, b : Int) -> ColorRGB

    Creates a new ColorRGB.

    ColorRGB::to_grayscale

    fn ColorRGB::to_grayscale(self : ColorRGB) -> Int

    Converts RGB to 8-bit grayscale intensity using standard ITU-R BT.601 weights.

    ColorRGB::to_hsv

    fn ColorRGB::to_hsv(self : ColorRGB) -> ColorHSV

    Converts RGB to HSV.

    ConnectedComponent

    pub(all) struct ConnectedComponent {
    label : Int
    area : Int
    bounding_box : Rect2D
    centroid : Point2D
    } derive(Eq,
    Debug
    )

    Represents a connected blob component in a segmented binary image.

    ConnectedComponent::new

    fn ConnectedComponent::new(label : Int, area : Int, bounding_box : Rect2D, centroid : Point2D) -> ConnectedComponent

    Creates a new connected component record.

    Contour

    pub(all) struct Contour {
    points : Array[Point2D]
    } derive(Eq,
    Debug
    )

    Represents a closed boundary contour with an ordered array of 2D points.

    Contour::area

    fn Contour::area(self : Contour) -> Double

    Computes the enclosed geometric area using Gauss's Shoelace formula.

    Contour::bounding_rect

    fn Contour::bounding_rect(self : Contour) -> Rect2D

    Computes bounding rectangle enclosing this contour.

    Contour::centroid

    fn Contour::centroid(self : Contour) -> Point2D

    Computes geometric centroid of the contour.

    Contour::hu_moments

    fn Contour::hu_moments(self : Contour) -> Array[Double]

    Computes 7 Hu invariant moments from contour points.

    Contour::new

    fn Contour::new(points : Array[Point2D]) -> Contour

    Creates a new Contour.

    Contour::perimeter

    fn Contour::perimeter(self : Contour) -> Double

    Computes the perimeter (arc length) of the contour.

    CornerPoint

    pub(all) struct CornerPoint {
    pt : Point2D
    response : Double
    } derive(Eq,
    Debug
    )

    Represents a detected feature corner point with sub-pixel position and response score.

    CornerPoint::new

    fn CornerPoint::new(pt : Point2D, response : Double) -> CornerPoint

    Creates a new corner point.

    DenseMatrix

    pub(all) struct DenseMatrix {
    rows : Int
    cols : Int
    data : Array[Double]
    } derive(Eq,
    Debug
    )

    Dense dynamic M x N matrix with double precision.

    DenseMatrix::add

    fn DenseMatrix::add(self : DenseMatrix, other : DenseMatrix) -> DenseMatrix?

    Matrix addition.

    DenseMatrix::cholesky

    fn DenseMatrix::cholesky(self : DenseMatrix) -> DenseMatrix?

    Cholesky decomposition of a symmetric positive-definite matrix (A = L * L^T).

    DenseMatrix::clone

    fn DenseMatrix::clone(self : DenseMatrix) -> DenseMatrix

    Clones the matrix.

    DenseMatrix::determinant

    fn DenseMatrix::determinant(self : DenseMatrix) -> Double

    Computes determinant of a square matrix via LU decomposition.

    DenseMatrix::from_2d

    fn DenseMatrix::from_2d(rows_arr : Array[Array[Double]]) -> DenseMatrix

    Creates an M x N matrix from a 2D array of rows.

    DenseMatrix::from_flat

    fn DenseMatrix::from_flat(rows : Int, cols : Int, data : Array[Double]) -> DenseMatrix

    Creates an M x N matrix from a flat array in row-major order.

    DenseMatrix::get

    fn DenseMatrix::get(self : DenseMatrix, row : Int, col : Int) -> Double

    Gets element at (row, col).

    DenseMatrix::identity

    fn DenseMatrix::identity(n : Int) -> DenseMatrix

    Creates an N x N identity matrix.

    DenseMatrix::inverse

    fn DenseMatrix::inverse(self : DenseMatrix) -> DenseMatrix?

    Computes matrix inverse via Gauss-Jordan elimination with partial pivoting.

    DenseMatrix::mul

    fn DenseMatrix::mul(self : DenseMatrix, other : DenseMatrix) -> DenseMatrix?

    Matrix multiplication (self * other).

    DenseMatrix::mul_vec

    fn DenseMatrix::mul_vec(self : DenseMatrix, vec : Array[Double]) -> Array[Double]?

    Multiplies matrix with a vector (Array[Double] of size cols).

    DenseMatrix::norm_frobenius

    fn DenseMatrix::norm_frobenius(self : DenseMatrix) -> Double

    Computes Frobenius norm of the matrix.

    DenseMatrix::pseudo_inverse

    fn DenseMatrix::pseudo_inverse(self : DenseMatrix, tolerance? : Double) -> DenseMatrix?

    Computes Moore-Penrose Pseudo-Inverse (A^+) via SVD.

    DenseMatrix::qr_decomposition

    fn DenseMatrix::qr_decomposition(self : DenseMatrix) -> (DenseMatrix, DenseMatrix)?

    QR decomposition via Householder reflections (A = Q * R).

    DenseMatrix::scale

    fn DenseMatrix::scale(self : DenseMatrix, s : Double) -> DenseMatrix

    Scalar multiplication.

    DenseMatrix::set

    fn DenseMatrix::set(self : DenseMatrix, row : Int, col : Int, val : Double) -> Unit

    Sets element at (row, col).

    DenseMatrix::set_submatrix

    fn DenseMatrix::set_submatrix(self : DenseMatrix, r0 : Int, c0 : Int, sub : DenseMatrix) -> Unit

    Sets a submatrix into this matrix at (r0, c0).

    DenseMatrix::solve_least_squares

    fn DenseMatrix::solve_least_squares(self : DenseMatrix, b : Array[Double]) -> Array[Double]?

    Solves linear least squares problem min ||A * x - b||_2 using SVD / Pseudo-Inverse.

    DenseMatrix::solve_linear

    fn DenseMatrix::solve_linear(self : DenseMatrix, b : Array[Double]) -> Array[Double]?

    Gaussian elimination with partial pivoting solving Ax = b.

    DenseMatrix::sub

    fn DenseMatrix::sub(self : DenseMatrix, other : DenseMatrix) -> DenseMatrix?

    Matrix subtraction.

    DenseMatrix::submatrix

    fn DenseMatrix::submatrix(self : DenseMatrix, r0 : Int, c0 : Int, r1 : Int, c1 : Int) -> DenseMatrix

    Extracts a submatrix from (r0, c0) to (r1-1, c1-1).

    DenseMatrix::svd

    fn DenseMatrix::svd(self : DenseMatrix, max_iterations? : Int, epsilon? : Double) -> (DenseMatrix, Array[Double], DenseMatrix)?

    Singular Value Decomposition (SVD) of M x N matrix (M >= N) using One-Sided Jacobi rotations. Returns (U, S, V) such that A = U * diag(S) * V^T.

    DenseMatrix::swap_rows

    fn DenseMatrix::swap_rows(self : DenseMatrix, r1 : Int, r2 : Int) -> Unit

    Swaps two rows in place.

    DenseMatrix::transpose

    fn DenseMatrix::transpose(self : DenseMatrix) -> DenseMatrix

    Transposes the matrix into an N x M matrix.

    DenseMatrix::zeros

    fn DenseMatrix::zeros(rows : Int, cols : Int) -> DenseMatrix

    Creates an M x N matrix initialized to zero.

    DetectorParameters

    pub(all) struct DetectorParameters {
    adaptive_thresh_win_size_min : Int
    adaptive_thresh_win_size_max : Int
    adaptive_thresh_win_size_step : Int
    adaptive_thresh_constant : Int
    min_marker_perimeter_rate : Double
    max_marker_perimeter_rate : Double
    polygonal_approx_accuracy_rate : Double
    min_corner_distance_rate : Double
    min_distance_to_border : Int
    min_marker_distance_rate : Double
    corner_refinement_method : Int
    corner_refinement_win_size : Int
    corner_refinement_max_iterations : Int
    corner_refinement_min_accuracy : Double
    perspective_remove_pixel_per_cell : Int
    perspective_remove_ignored_margin_per_cell : Double
    max_erroneous_bits_in_border_rate : Double
    min_otsu_std_dev : Double
    error_correction_rate : Double
    } derive(Eq,
    Debug
    )

    Represents full detection configuration parameters.

    DetectorParameters::default

    Creates default detector configuration parameters.

    DiamondDetection

    pub(all) struct DiamondDetection {
    ids : Array[Int]
    corners : Array[Point2D]
    pose : Pose3D?
    } derive(Eq,
    Debug
    )

    Represents a detected ArUco Diamond Marker (3x3 grid composed of 4 individual markers).

    DictionaryIndex

    pub(all) struct DictionaryIndex {
    root : VpNode?
    max_error : Int
    } derive(
    Debug
    )

    Fast Vantage Point (VP) Tree index for sub-linear Hamming distance search.

    DictionaryIndex::build

    Creates a DictionaryIndex with VP-tree for fast query matching.

    DictionaryIndex::search

    fn DictionaryIndex::search(self : DictionaryIndex, query : Int64) -> (Int, Int, Int)?

    Searches nearest codeword in VP-tree within max_error Hamming distance.

    ExtendedKalmanFilter6DOF

    pub(all) struct ExtendedKalmanFilter6DOF {
    state : Array[Double]
    covariance : DenseMatrix
    process_noise : DenseMatrix
    measurement_noise : DenseMatrix
    } derive(Eq,
    Debug
    )

    Extended Kalman Filter (EKF) for 6-DOF tracking of 3D Position, Velocity, Orientation Quaternion, and Angular Velocity. State vector (13D): [x, y, z, vx, vy, vz, qw, qx, qy, qz, wx, wy, wz]

    ExtendedKalmanFilter6DOF::new

    fn ExtendedKalmanFilter6DOF::new(initial_pose : Pose3D, pos_process_noise? : Double, rot_process_noise? : Double, pos_meas_noise? : Double, rot_meas_noise? : Double) -> ExtendedKalmanFilter6DOF

    Creates a new 6DOF Extended Kalman Filter initialized with a given 3D pose.

    ExtendedKalmanFilter6DOF::pose

    Gets the current filtered 6DOF Pose.

    ExtendedKalmanFilter6DOF::predict

    fn ExtendedKalmanFilter6DOF::predict(self : ExtendedKalmanFilter6DOF, dt : Double) -> Unit

    Predicts the 6DOF state forward by dt seconds.

    ExtendedKalmanFilter6DOF::update

    fn ExtendedKalmanFilter6DOF::update(self : ExtendedKalmanFilter6DOF, measured_pose : Pose3D) -> Unit

    Updates the EKF with a new measured 3D Pose (rvec, tvec).

    GridBoard

    pub(all) struct GridBoard {
    markers_x : Int
    markers_y : Int
    marker_length : Double
    marker_separation : Double
    dictionary : MarkerDictionary
    ids : Array[Int]
    obj_points : Array[Array[Point3D]]
    } derive(Eq,
    Debug
    )

    Definition of an ArUco GridBoard containing a 2D array of fiducial markers.

    GridBoard::new

    fn GridBoard::new(markers_x : Int, markers_y : Int, marker_length : Double, marker_separation : Double, dictionary : MarkerDictionary, first_marker_id? : Int) -> GridBoard

    Creates a new ArUco GridBoard with specified grid dimensions, marker sizes, and dictionary.

    Image

    pub(all) struct Image {
    width : Int
    height : Int
    data : Array[Int]
    } derive(Eq,
    Debug
    )

    Represents an 8-bit grayscale 2D image.

    Image::blit

    fn Image::blit(self : Image, src : Image, x : Int, y : Int) -> Unit

    Blits (copies) another image onto this image at (x, y).

    Image::clone

    fn Image::clone(self : Image) -> Image

    Clones the image.

    Image::crop

    fn Image::crop(self : Image, x : Int, y : Int, width : Int, height : Int) -> Image

    Crops a subregion from the image.

    Image::draw_circle

    fn Image::draw_circle(self : Image, center : Point2D, radius : Int, color : Int) -> Unit

    Draws a circle using midpoint circle algorithm.

    Image::draw_line

    fn Image::draw_line(self : Image, p0 : Point2D, p1 : Point2D, color : Int) -> Unit

    Draws a line using Bresenham's algorithm.

    Image::draw_quad

    fn Image::draw_quad(self : Image, quad : Quad, color : Int) -> Unit

    Draws the 4 edges of a quadrilateral.

    Image::draw_rect

    fn Image::draw_rect(self : Image, x : Int, y : Int, w : Int, h : Int, color : Int) -> Unit

    Draws an unfilled rectangle.

    Image::draw_rect_filled

    fn Image::draw_rect_filled(self : Image, x : Int, y : Int, w : Int, h : Int, color : Int) -> Unit

    Draws a filled rectangle on the image.

    Image::fill

    fn Image::fill(self : Image, val : Int) -> Unit

    Fills the entire image with a constant pixel value.

    Image::from_array

    fn Image::from_array(width : Int, height : Int, data : Array[Int]) -> Image

    Creates an Image from a flat array of pixels.

    Image::get

    fn Image::get(self : Image, x : Int, y : Int) -> Int

    Gets pixel value at (x, y) with boundary clamping.

    Image::new

    fn Image::new(width : Int, height : Int) -> Image

    Creates a new Image with width and height, filled with zeros.

    Image::resize

    fn Image::resize(self : Image, new_width : Int, new_height : Int) -> Image

    Resizes the image using bilinear interpolation.

    Image::sample_bicubic

    fn Image::sample_bicubic(self : Image, pt : Point2D) -> Double

    Bicubic interpolation sampling at sub-pixel coordinate pt with Catmull-Rom spline.

    Image::sample_bilinear

    fn Image::sample_bilinear(self : Image, pt : Point2D) -> Double

    Bilinear interpolation sampling at sub-pixel coordinate pt.

    Image::set

    fn Image::set(self : Image, x : Int, y : Int, val : Int) -> Unit

    Sets pixel value at (x, y).

    Image::to_color

    fn Image::to_color(self : Image) -> ColorImage

    Converts 8-bit grayscale Image to 24-bit ColorImage.

    Image::to_pgm

    fn Image::to_pgm(self : Image) -> String

    Exports image to NetPBM PGM (ASCII P2) format string.

    IppeResult

    pub(all) struct IppeResult {
    pose1 : Pose3D
    pose2 : Pose3D
    reproj_error1 : Double
    reproj_error2 : Double
    ambiguity_ratio : Double
    } derive(Eq,
    Debug
    )

    Result of Infinitesimal Plane-based Pose Estimation (IPPE). Contains two possible poses due to planar projective ambiguity and their reprojection errors.

    KalmanFilter3D

    pub(all) struct KalmanFilter3D {
    state_dim : Int
    state : Array[Double]
    covariance : DenseMatrix
    process_noise : DenseMatrix
    measurement_noise : DenseMatrix
    } derive(Eq,
    Debug
    )

    Linear Kalman Filter for 3D state tracking with Constant Velocity (CV) or Constant Acceleration (CA) models.

    KalmanFilter3D::new_constant_velocity

    fn KalmanFilter3D::new_constant_velocity(initial_position : Point3D, process_noise_std? : Double, measurement_noise_std? : Double) -> KalmanFilter3D

    Creates a 6-state Constant Velocity 3D Kalman Filter (position + velocity).

    KalmanFilter3D::position

    fn KalmanFilter3D::position(self : KalmanFilter3D) -> Point3D

    Gets the current filtered 3D position estimate.

    KalmanFilter3D::predict

    fn KalmanFilter3D::predict(self : KalmanFilter3D, dt : Double) -> Unit

    Predicts the state forward by time delta dt (seconds).

    KalmanFilter3D::update

    fn KalmanFilter3D::update(self : KalmanFilter3D, measurement : Point3D) -> Unit

    Updates the Kalman filter with a new 3D position measurement.

    KalmanFilter3D::velocity

    fn KalmanFilter3D::velocity(self : KalmanFilter3D) -> Point3D

    Gets the current filtered 3D velocity estimate.

    LineSegment

    pub(all) struct LineSegment {
    p1 : Point2D
    p2 : Point2D
    width : Double
    p_val : Double
    nfa : Double
    } derive(Eq,
    Debug
    )

    Detected 2D Line Segment with confidence score and angle.

    LineSegment::new

    fn LineSegment::new(p1 : Point2D, p2 : Point2D, width : Double, p_val : Double, nfa : Double) -> LineSegment

    Creates a LineSegment.

    LsdParameters

    pub(all) struct LsdParameters {
    scale : Double
    sigma_scale : Double
    quant : Double
    ang_th : Double
    log_eps : Double
    density_th : Double
    n_bins : Int
    } derive(Eq,
    Debug
    )

    Line segment detector parameters.

    LsdParameters::default

    fn LsdParameters::default() -> LsdParameters

    Creates default LSD parameters.

    MarkerDetection

    pub(all) struct MarkerDetection {
    id : Int
    quad : Quad
    pose : Pose3D?
    rotation_index : Int
    hamming_distance : Int
    } derive(Eq,
    Debug
    )

    Represents a successfully decoded fiducial marker.

    MarkerDictionary

    pub(all) struct MarkerDictionary {
    name : String
    grid_size : Int
    payload_bits : Int
    max_correction_bits : Int
    codewords : Array[Int64]
    } derive(Eq,
    Debug
    )

    Definition of a fiducial marker dictionary.

    MarkerDictionary::find_best_match

    fn MarkerDictionary::find_best_match(self : MarkerDictionary, candidate_bits : Int64) -> (Int, Int, Int)?

    Finds the best codeword match in dictionary across all 4 90-degree rotations.

    MarkerTrack

    pub(all) struct MarkerTrack {
    track_id : Int
    marker_id : Int
    state : TrackState
    filter : ExtendedKalmanFilter6DOF
    hits : Int
    age : Int
    lost_frames : Int
    history : Array[Point3D]
    } derive(
    Debug
    )

    A single marker track record containing ID, filtered pose, and trajectory history.

    MarkerTrack::new

    fn MarkerTrack::new(track_id : Int, marker_id : Int, initial_pose : Pose3D) -> MarkerTrack

    Creates a new MarkerTrack from an initial marker detection.

    Matrix3x3

    pub(all) struct Matrix3x3 {
    data : Array[Double]
    } derive(Eq,
    Debug
    )

    Represents a 3x3 matrix in row-major order.

    Matrix3x3::determinant

    fn Matrix3x3::determinant(self : Matrix3x3) -> Double

    Calculates determinant of 3x3 matrix.

    Matrix3x3::from_array

    fn Matrix3x3::from_array(arr : Array[Double]) -> Matrix3x3

    Creates a 3x3 matrix from a flat array of 9 elements.

    Matrix3x3::get

    fn Matrix3x3::get(self : Matrix3x3, row : Int, col : Int) -> Double

    Accesses element at (row, col).

    Matrix3x3::identity

    fn Matrix3x3::identity() -> Matrix3x3

    Creates a 3x3 identity matrix.

    Matrix3x3::inverse

    fn Matrix3x3::inverse(self : Matrix3x3) -> Matrix3x3?

    Computes inverse of 3x3 matrix using adjugate matrix. Returns None if matrix is singular.

    Matrix3x3::mul

    fn Matrix3x3::mul(self : Matrix3x3, other : Matrix3x3) -> Matrix3x3

    Matrix multiplication A * B.

    Matrix3x3::mul_vec

    fn Matrix3x3::mul_vec(self : Matrix3x3, v : Point3D) -> Point3D

    Matrix-Vector multiplication M * v (3D vector).

    Matrix3x3::set

    fn Matrix3x3::set(self : Matrix3x3, row : Int, col : Int, val : Double) -> Unit

    Sets element at (row, col).

    Matrix3x3::transform_point2d

    fn Matrix3x3::transform_point2d(self : Matrix3x3, pt : Point2D) -> Point2D

    Applies 3x3 homography transformation to a 2D point (homogeneous coordinates).

    Matrix3x3::transpose

    fn Matrix3x3::transpose(self : Matrix3x3) -> Matrix3x3

    Transposes the 3x3 matrix.

    Matrix3x3::zeros

    fn Matrix3x3::zeros() -> Matrix3x3

    Creates a 3x3 zero matrix.

    Matrix4x4

    pub(all) struct Matrix4x4 {
    m00 : Double
    m01 : Double
    m02 : Double
    m03 : Double
    m10 : Double
    m11 : Double
    m12 : Double
    m13 : Double
    m20 : Double
    m21 : Double
    m22 : Double
    m23 : Double
    m30 : Double
    m31 : Double
    m32 : Double
    m33 : Double
    } derive(Eq,
    Debug
    )

    Represents a 4x4 transformation matrix in homogeneous coordinates (OpenGL/DirectX/Unity convention).

    Matrix4x4::from_pose

    fn Matrix4x4::from_pose(pose : Pose3D) -> Matrix4x4

    Creates a Matrix4x4 from a 6DOF Pose3D (Rodrigues rotation + translation).

    MorphShape

    pub(all) enum MorphShape {
    Rect
    Cross
    Ellipse
    } derive(Eq,
    Debug
    )

    Structuring element shape for mathematical morphology operations.

    MultiMarkerTracker

    pub(all) struct MultiMarkerTracker {
    tracks : Array[MarkerTrack]
    next_track_id : Int
    max_lost_frames : Int
    min_hits_to_confirm : Int
    } derive(
    Debug
    )

    Multi-target marker tracking engine for continuous video streams.

    MultiMarkerTracker::new

    fn MultiMarkerTracker::new(max_lost_frames? : Int, min_hits_to_confirm? : Int) -> MultiMarkerTracker

    Creates a new MultiMarkerTracker.

    MultiMarkerTracker::update

    fn MultiMarkerTracker::update(self : MultiMarkerTracker, detections : Array[MarkerDetection], dt? : Double) -> Array[MarkerTrack]

    Updates all tracks with newly detected markers in the current frame.

    NoiseType

    pub(all) enum NoiseType {
    Gaussian(Double)
    SaltAndPepper(Double)
    Poisson
    MotionBlur(Int, Double)
    Vignetting(Double)
    LinearGradient(Double, Double)
    } derive(Eq,
    Debug
    )

    Physical degradation noise and illumination models for fiducial marker robustness testing.

    OpticalFlowTracker

    pub(all) struct OpticalFlowTracker {
    win_size : Int
    max_level : Int
    max_iterations : Int
    epsilon : Double
    min_eigen_threshold : Double
    } derive(Eq,
    Debug
    )

    Lucas-Kanade Pyramidal Optical Flow Tracker for high-speed subpixel corner tracking. Allows real-time 60+ FPS marker tracking across consecutive video frames without re-executing full contour search.

    OpticalFlowTracker::new

    fn OpticalFlowTracker::new(win_size? : Int, max_level? : Int, max_iterations? : Int, epsilon? : Double, min_eigen_threshold? : Double) -> OpticalFlowTracker

    Creates a new Lucas-Kanade optical flow tracker.

    OpticalFlowTracker::track_points

    fn OpticalFlowTracker::track_points(self : OpticalFlowTracker, prev_img : Image, next_img : Image, prev_points : Array[Point2D]) -> (Array[Point2D], Array[Bool], Array[Double])

    Tracks feature points from prev_img to next_img using iterative Lucas-Kanade algorithm. Returns (tracked_points, status_flags, tracking_errors).

    PerformanceStats

    pub(all) struct PerformanceStats {
    fps : Double
    frame_latency_ms : Double
    threshold_time_ms : Double
    contour_time_ms : Double
    decode_time_ms : Double
    pose_time_ms : Double
    num_markers_detected : Int
    } derive(Eq,
    Debug
    )

    Performance metrics for live video processing.

    PerformanceStats::new

    fn PerformanceStats::new(fps : Double, frame_latency_ms : Double, threshold_time_ms : Double, contour_time_ms : Double, decode_time_ms : Double, pose_time_ms : Double, num_markers_detected : Int) -> PerformanceStats

    Creates a new PerformanceStats record.

    Point2D

    pub(all) struct Point2D {
    x : Double
    y : Double
    } derive(Default, Eq,
    Debug
    )

    Represents a 2D point in image coordinates with double precision.

    Point2D::add

    fn Point2D::add(self : Point2D, other : Point2D) -> Point2D

    Computes vector addition of two 2D points.

    Point2D::cross

    fn Point2D::cross(self : Point2D, other : Point2D) -> Double

    Computes the 2D cross product (determinant) of two vectors.

    Point2D::distance

    fn Point2D::distance(self : Point2D, other : Point2D) -> Double

    Computes Euclidean distance between two 2D points.

    Point2D::distance_sq

    fn Point2D::distance_sq(self : Point2D, other : Point2D) -> Double

    Computes squared Euclidean distance between two 2D points.

    Point2D::dot

    fn Point2D::dot(self : Point2D, other : Point2D) -> Double

    Computes the 2D dot product of two points treated as vectors.

    Point2D::lerp

    fn Point2D::lerp(self : Point2D, other : Point2D, t : Double) -> Point2D

    Linear interpolation between two 2D points.

    Point2D::new

    fn Point2D::new(x : Double, y : Double) -> Point2D

    Creates a new Point2D with given coordinates.

    Point2D::norm

    fn Point2D::norm(self : Point2D) -> Double

    Computes vector magnitude (length).

    Point2D::normalized

    fn Point2D::normalized(self : Point2D) -> Point2D

    Returns a normalized unit vector, or (0, 0) if norm is near zero.

    Point2D::scale

    fn Point2D::scale(self : Point2D, s : Double) -> Point2D

    Scales a 2D point by a scalar factor.

    Point2D::sub

    fn Point2D::sub(self : Point2D, other : Point2D) -> Point2D

    Computes vector subtraction of two 2D points.

    Point3D

    pub(all) struct Point3D {
    x : Double
    y : Double
    z : Double
    } derive(Default, Eq,
    Debug
    )

    Represents a 3D point in world/camera coordinates.

    Point3D::add

    fn Point3D::add(self : Point3D, other : Point3D) -> Point3D

    Vector addition of two 3D points.

    Point3D::cross

    fn Point3D::cross(self : Point3D, other : Point3D) -> Point3D

    Computes 3D cross product.

    Point3D::distance

    fn Point3D::distance(self : Point3D, other : Point3D) -> Double

    Computes Euclidean distance between two 3D points.

    Point3D::distance_sq

    fn Point3D::distance_sq(self : Point3D, other : Point3D) -> Double

    Computes squared Euclidean distance between two 3D points.

    Point3D::dot

    fn Point3D::dot(self : Point3D, other : Point3D) -> Double

    Computes 3D dot product.

    Point3D::lerp

    fn Point3D::lerp(self : Point3D, other : Point3D, t : Double) -> Point3D

    Linear interpolation between two 3D points.

    Point3D::new

    fn Point3D::new(x : Double, y : Double, z : Double) -> Point3D

    Creates a new Point3D with given coordinates.

    Point3D::norm

    fn Point3D::norm(self : Point3D) -> Double

    Computes vector norm of a 3D point.

    Point3D::normalized

    fn Point3D::normalized(self : Point3D) -> Point3D

    Normalizes a 3D vector.

    Point3D::scale

    fn Point3D::scale(self : Point3D, s : Double) -> Point3D

    Scalar multiplication for 3D points.

    Point3D::sub

    fn Point3D::sub(self : Point3D, other : Point3D) -> Point3D

    Vector subtraction of two 3D points.

    Polygon2D

    pub(all) struct Polygon2D {
    vertices : Array[Point2D]
    } derive(Eq,
    Debug
    )

    Represents a general 2D polygon with ordered vertices.

    Polygon2D::area

    fn Polygon2D::area(self : Polygon2D) -> Double

    Computes absolute geometric area of polygon.

    Polygon2D::centroid

    fn Polygon2D::centroid(self : Polygon2D) -> Point2D

    Computes geometric centroid of polygon.

    Polygon2D::contains_point

    fn Polygon2D::contains_point(self : Polygon2D, p : Point2D) -> Bool

    Checks if point p is inside polygon via ray casting (winding/crossing test).

    Polygon2D::is_convex

    fn Polygon2D::is_convex(self : Polygon2D) -> Bool

    Tests whether polygon is strictly convex.

    Polygon2D::new

    fn Polygon2D::new(vertices : Array[Point2D]) -> Polygon2D

    Creates a new polygon from an array of vertices.

    Polygon2D::perimeter

    fn Polygon2D::perimeter(self : Polygon2D) -> Double

    Computes perimeter of polygon.

    Polygon2D::signed_area

    fn Polygon2D::signed_area(self : Polygon2D) -> Double

    Computes signed area using Shoelace formula (positive for CCW, negative for CW).

    Pose3D

    pub(all) struct Pose3D {
    rvec : Point3D
    tvec : Point3D
    } derive(Default, Eq,
    Debug
    )

    Represents 6-DOF camera pose with rotation vector (Rodrigues) and translation vector.

    Pose3D::new

    fn Pose3D::new(rvec : Point3D, tvec : Point3D) -> Pose3D

    Creates a Pose3D from rvec and tvec.

    Quad

    pub(all) struct Quad {
    corners : Array[Point2D]
    } derive(Eq,
    Debug
    )

    Represents a candidate quadrilateral with 4 ordered corners (TL, TR, BR, BL).

    Quad::area

    fn Quad::area(self : Quad) -> Double

    Computes the geometric area of the quadrilateral using Shoelace formula.

    Quad::bounding_rect

    fn Quad::bounding_rect(self : Quad) -> Rect2D

    Computes the bounding rect enclosing this quadrilateral.

    Quad::center

    fn Quad::center(self : Quad) -> Point2D

    Computes the centroid center of the quad.

    Quad::new

    fn Quad::new(p0 : Point2D, p1 : Point2D, p2 : Point2D, p3 : Point2D) -> Quad

    Creates a Quad from 4 points.

    Quad::perimeter

    fn Quad::perimeter(self : Quad) -> Double

    Computes the perimeter length of the quadrilateral.

    Quaternion

    pub(all) struct Quaternion {
    w : Double
    x : Double
    y : Double
    z : Double
    } derive(Default, Eq,
    Debug
    )

    Unit quaternion representation of 3D rotations: q = w + xi + yj + z*k.

    Quaternion::conjugate

    fn Quaternion::conjugate(self : Quaternion) -> Quaternion

    Computes quaternion conjugate (w, -x, -y, -z).

    Quaternion::from_axis_angle

    fn Quaternion::from_axis_angle(axis : Point3D, angle : Double) -> Quaternion

    Creates a quaternion from an axis of rotation and an angle (in radians).

    Quaternion::from_euler_zyx

    fn Quaternion::from_euler_zyx(yaw : Double, pitch : Double, roll : Double) -> Quaternion

    Creates quaternion from Euler angles (Yaw around Z, Pitch around Y, Roll around X).

    Quaternion::from_rotation_matrix

    fn Quaternion::from_rotation_matrix(rot : Matrix3x3) -> Quaternion

    Converts 3x3 rotation matrix to quaternion using Shepperd's algorithm.

    Quaternion::from_rvec

    fn Quaternion::from_rvec(rvec : Point3D) -> Quaternion

    Creates a quaternion from Rodrigues rotation vector.

    Quaternion::identity

    fn Quaternion::identity() -> Quaternion

    Identity quaternion representing zero rotation (1, 0, 0, 0).

    Quaternion::inverse

    fn Quaternion::inverse(self : Quaternion) -> Quaternion

    Computes quaternion inverse (q* / ||q||^2).

    Quaternion::mul

    fn Quaternion::mul(self : Quaternion, other : Quaternion) -> Quaternion

    Hamilton product of two quaternions (q1 * q2).

    Quaternion::new

    fn Quaternion::new(w : Double, x : Double, y : Double, z : Double) -> Quaternion

    Creates a new quaternion with given components.

    Quaternion::norm

    fn Quaternion::norm(self : Quaternion) -> Double

    Computes Euclidean norm (magnitude) of quaternion.

    Quaternion::normalized

    fn Quaternion::normalized(self : Quaternion) -> Quaternion

    Normalizes the quaternion to unit length.

    Quaternion::rotate_point

    fn Quaternion::rotate_point(self : Quaternion, p : Point3D) -> Point3D

    Rotates a 3D vector by this quaternion: v' = q * (0, v) * q^(-1).

    Quaternion::slerp

    fn Quaternion::slerp(q1 : Quaternion, q2 : Quaternion, t : Double) -> Quaternion

    Spherical Linear Interpolation (SLERP) between two quaternions with factor t in [0, 1].

    Quaternion::to_euler_zyx

    fn Quaternion::to_euler_zyx(self : Quaternion) -> (Double, Double, Double)

    Converts quaternion to Euler angles (Yaw, Pitch, Roll in radians, ZYX convention).

    Quaternion::to_rotation_matrix

    fn Quaternion::to_rotation_matrix(self : Quaternion) -> Matrix3x3

    Converts quaternion to 3x3 rotation matrix.

    Quaternion::to_rvec

    fn Quaternion::to_rvec(self : Quaternion) -> Point3D

    Converts quaternion to Rodrigues rotation vector.

    RansacHomographyResult

    pub(all) struct RansacHomographyResult {
    homography : Matrix3x3
    inliers : Array[Bool]
    inlier_count : Int
    reprojection_error : Double
    } derive(Eq,
    Debug
    )

    Result of RANSAC Homography estimation.

    RansacPnpResult

    pub(all) struct RansacPnpResult {
    pose : Pose3D
    inliers : Array[Bool]
    inlier_count : Int
    reprojection_error : Double
    } derive(Eq,
    Debug
    )

    Result of RANSAC PnP estimation.

    Rect2D

    pub(all) struct Rect2D {
    x : Double
    y : Double
    width : Double
    height : Double
    } derive(Default, Eq,
    Debug
    )

    Represents a 2D bounding box (axis-aligned).

    Rect2D::area

    fn Rect2D::area(self : Rect2D) -> Double

    Computes bounding box area.

    Rect2D::contains

    fn Rect2D::contains(self : Rect2D, p : Point2D) -> Bool

    Checks if a 2D point is inside the bounding box.

    Rect2D::iou

    fn Rect2D::iou(self : Rect2D, other : Rect2D) -> Double

    Computes Intersection over Union (IoU) of two bounding boxes.

    Rect2D::new

    fn Rect2D::new(x : Double, y : Double, width : Double, height : Double) -> Rect2D

    Creates a new axis-aligned bounding box.

    ReprojectionMetrics

    pub(all) struct ReprojectionMetrics {
    rmse : Double
    mae : Double
    max_error : Double
    point_errors : Array[Double]
    } derive(Eq,
    Debug
    )

    Summary metrics of geometric reprojection error.

    Segment2D

    pub(all) struct Segment2D {
    p1 : Point2D
    p2 : Point2D
    } derive(Eq,
    Debug
    )

    Represents a 2D line segment between two points.

    Segment2D::distance_to_point

    fn Segment2D::distance_to_point(self : Segment2D, p : Point2D) -> Double

    Computes the shortest distance from a point to this line segment.

    Segment2D::intersection

    fn Segment2D::intersection(self : Segment2D, other : Segment2D) -> Point2D?

    Checks if two 2D segments intersect, and returns the intersection point if any.

    Segment2D::length

    fn Segment2D::length(self : Segment2D) -> Double

    Computes the length of the segment.

    Segment2D::midpoint

    fn Segment2D::midpoint(self : Segment2D) -> Point2D

    Computes the midpoint of the segment.

    Segment2D::new

    fn Segment2D::new(p1 : Point2D, p2 : Point2D) -> Segment2D

    Creates a new 2D line segment.

    Size2D

    pub(all) struct Size2D {
    width : Int
    height : Int
    } derive(Default, Eq,
    Debug
    )

    Represents image dimensions.

    Size2D::new

    fn Size2D::new(width : Int, height : Int) -> Size2D

    Creates a new Size2D with width and height.

    StereoCameraRig

    pub(all) struct StereoCameraRig {
    left_camera : CameraIntrinsics
    right_camera : CameraIntrinsics
    baseline : Double
    right_to_left_pose : Pose3D
    } derive(Eq,
    Debug
    )

    Represents a calibrated binocular stereo camera rig (Left & Right cameras).

    StereoCameraRig::estimate_marker_pose_stereo

    fn StereoCameraRig::estimate_marker_pose_stereo(self : StereoCameraRig, left_quad : Quad, right_quad : Quad, marker_length : Double) -> Pose3D?

    Solves stereo joint 3D pose of a fiducial marker observed by both left and right cameras simultaneously. Leverages stereo epipolar geometry to eliminate depth ambiguity and improve accuracy.

    StereoCameraRig::new_parallel

    fn StereoCameraRig::new_parallel(camera : CameraIntrinsics, baseline : Double) -> StereoCameraRig

    Creates a standard parallel binocular stereo camera rig.

    StereoCameraRig::triangulate_point

    fn StereoCameraRig::triangulate_point(self : StereoCameraRig, left_pixel : Point2D, right_pixel : Point2D) -> Point3D?

    Triangulates a 3D point in left camera frame from corresponding left and right pixel observations.

    StructuringElement

    pub(all) struct StructuringElement {
    shape : MorphShape
    radius : Int
    width : Int
    height : Int
    data : Array[Bool]
    } derive(Eq,
    Debug
    )

    Structuring element with 2D binary kernel.

    StructuringElement::new

    fn StructuringElement::new(shape : MorphShape, radius : Int) -> StructuringElement

    Creates a structuring element of specified shape and radius.

    SyntheticDatasetGenerator

    pub(all) struct SyntheticDatasetGenerator {
    camera : CameraIntrinsics
    dictionary : MarkerDictionary
    marker_length : Double
    image_size : Size2D
    } derive(Eq,
    Debug
    )

    Batch generator for synthetic fiducial marker dataset benchmarks.

    SyntheticDatasetGenerator::generate_distance_sweep

    fn SyntheticDatasetGenerator::generate_distance_sweep(self : SyntheticDatasetGenerator, marker_id : Int, min_dist : Double, max_dist : Double, num_steps : Int) -> Array[SyntheticEvaluationFrame]

    Generates a suite of evaluation frames across distances from min_dist to max_dist with pitch and roll variations.

    SyntheticDatasetGenerator::new

    fn SyntheticDatasetGenerator::new(camera : CameraIntrinsics, dictionary : MarkerDictionary, marker_length? : Double, image_size? : Size2D) -> SyntheticDatasetGenerator

    Creates a new SyntheticDatasetGenerator.

    SyntheticEvaluationFrame

    pub(all) struct SyntheticEvaluationFrame {
    frame_index : Int
    marker_id : Int
    ground_truth_pose : Pose3D
    ground_truth_quad : Quad
    image : Image
    } derive(
    Debug
    )

    Represents a generated synthetic test frame with ground truth 3D pose, quad corners, and rendered image.

    SyntheticSceneConfig

    pub(all) struct SyntheticSceneConfig {
    image_size : Size2D
    camera : CameraIntrinsics
    marker_id : Int
    dictionary : MarkerDictionary
    marker_length : Double
    pose : Pose3D
    noise_std : Double
    lighting_ambient : Double
    lighting_diffuse : Double
    } derive(Eq,
    Debug
    )

    Configuration for rendering a 3D synthetic marker scene.

    SyntheticSceneConfig::default

    fn SyntheticSceneConfig::default(marker_id : Int, dictionary : MarkerDictionary) -> SyntheticSceneConfig

    Creates default synthetic scene configuration.

    TrackState

    pub(all) enum TrackState {
    Tentative
    Confirmed
    Lost
    Deleted
    } derive(Eq,
    Debug
    )

    Lifecycle state of a tracked target marker.

    VideoFrame

    pub(all) struct VideoFrame {
    frame_id : Int
    timestamp_seconds : Double
    image : Image
    } derive(
    Debug
    )

    Represents a timestamped video frame.

    VideoFrame::new

    fn VideoFrame::new(frame_id : Int, timestamp_seconds : Double, image : Image) -> VideoFrame

    Creates a new VideoFrame.

    VideoStreamPipeline

    pub(all) struct VideoStreamPipeline {
    capacity : Int
    frames : Array[VideoFrame]
    detector_params : DetectorParameters
    dictionary : MarkerDictionary
    tracker : MultiMarkerTracker
    camera : CameraIntrinsics?
    marker_length : Double
    } derive(
    Debug
    )

    Ring-buffer video frame stream with temporal smoothing and motion compensation.

    VideoStreamPipeline::new

    fn VideoStreamPipeline::new(dictionary : MarkerDictionary, capacity? : Int, camera? : CameraIntrinsics?, marker_length? : Double) -> VideoStreamPipeline

    Creates a new VideoStreamPipeline.

    VideoStreamPipeline::process_frame

    fn VideoStreamPipeline::process_frame(self : VideoStreamPipeline, frame : VideoFrame) -> Array[MarkerTrack]

    Pushes a new frame into the stream and performs integrated detection and multi-target tracking.

    VpNode

    pub(all) struct VpNode {
    codeword : Int64
    index : Int
    rotation : Int
    threshold : Int
    left : VpNode?
    right : VpNode?
    } derive(
    Debug
    )

    Node in a Vantage Point (VP) Tree for metric space nearest neighbor search under Hamming distance.

    apply_clahe

    fn apply_clahe(img : Image, grid_cols? : Int, grid_rows? : Int, clip_limit? : Double) -> Image

    Contrast Limited Adaptive Histogram Equalization (CLAHE). Divides image into grid of contextual tiles, limits histogram slope, and bilinearly interpolates.

    apply_lens_vignetting

    fn apply_lens_vignetting(img : Image, strength : Double) -> Image

    Applies radial vignetting light falloff (cos^4 law) from optical center.

    apply_lighting_gradient

    fn apply_lighting_gradient(img : Image, slope_x : Double, slope_y : Double) -> Image

    Applies non-uniform ambient illumination gradient across the canvas.

    apply_marker_occlusion_box

    fn apply_marker_occlusion_box(img : Image, x0 : Int, y0 : Int, w : Int, h : Int, fill_color : Int) -> Image

    Synthetically occludes a rectangular sub-region inside a quad (simulating finger / cable occlusion).

    apply_motion_blur

    fn apply_motion_blur(img : Image, kernel_size : Int, angle_rad : Double) -> Image

    Applies motion blur along a specific directional angle theta (simulating rapid robot/camera movement).

    apriltag_16h5_pairwise_distance_matrix

    fn apriltag_16h5_pairwise_distance_matrix() -> Array[Array[Int]]

    Precomputed Bit Parity and Hamming Neighborhood Matrices for AprilTag Official Families.

    apriltag_25h9_pairwise_distance_matrix

    fn apriltag_25h9_pairwise_distance_matrix() -> Array[Array[Int]]

    apriltag_36h11_all_codewords

    fn apriltag_36h11_all_codewords() -> Array[Int64]

    Official AprilTag 36h11 Complete Codewords Table (All 587 canonical codes from Michigan APRIL Lab).

    apriltag_36h11_canonical_table

    fn apriltag_36h11_canonical_table() -> Array[Int64]

    Full apriltag_36h11_canonical_table Codeword Array (587 markers).

    apriltag_36h11_pairwise_distance_matrix_sample

    fn apriltag_36h11_pairwise_distance_matrix_sample() -> Array[Array[Int]]

    apriltag_52h13_canonical_table

    fn apriltag_52h13_canonical_table() -> Array[Int64]

    Full apriltag_52h13_canonical_table Codeword Array (500 markers).

    apriltag_circle21h7_all_codewords

    fn apriltag_circle21h7_all_codewords() -> Array[Int64]

    Official AprilTag Circle21h7 Complete Codewords Table (All 38 canonical circular codewords).

    apriltag_circle21h7_pairwise_distance_matrix

    fn apriltag_circle21h7_pairwise_distance_matrix() -> Array[Array[Int]]

    apriltag_circle49h12_all_codewords

    fn apriltag_circle49h12_all_codewords() -> Array[Int64]

    Official AprilTag Circle49h12 Full Codewords Table (All 65 canonical 49-bit circular codewords).

    apriltag_custom48h12_all_codewords

    fn apriltag_custom48h12_all_codewords() -> Array[Int64]

    Official AprilTag Custom48h12 Complete Codewords Table (All 300 canonical 48-bit codewords).

    apriltag_standard41h12_all_codewords

    fn apriltag_standard41h12_all_codewords() -> Array[Int64]

    Official AprilTag Standard41h12 Full Codewords Table (All 95 canonical 41-bit codewords).

    apriltag_standard52h13_all_codewords

    fn apriltag_standard52h13_all_codewords() -> Array[Int64]

    Official AprilTag Standard52h13 Complete Table (Canonical 52-bit codewords).

    are_quads_duplicate

    fn are_quads_duplicate(q1 : Quad, q2 : Quad, min_corner_dist : Double) -> Bool

    Checks if two quads represent the same marker by comparing corner distances.

    aruco_4x4_1000_table

    fn aruco_4x4_1000_table() -> Array[Int64]

    Official OpenCV ArUco 1000-Marker Complete Lookup Tables.

    aruco_4x4_250_table

    fn aruco_4x4_250_table() -> Array[Int64]

    Comprehensive Official OpenCV ArUco Dictionary Tables. Provides direct array lookup for 4x4, 5x5, 6x6, 7x7 standard sizes.

    aruco_4x4_50_pairwise_distance_matrix

    fn aruco_4x4_50_pairwise_distance_matrix() -> Array[Array[Int]]

    Precomputed Hamming distance matrix between all pairs in ArUco 4x4 50 dictionary.

    aruco_4x4_canonical_table

    fn aruco_4x4_canonical_table() -> Array[Int64]

    Full aruco_4x4_canonical_table Codeword Array (1000 markers).

    aruco_4x4_full_codex

    fn aruco_4x4_full_codex() -> Array[Int64]

    Official OpenCV ArUco 4x4 Full 1000-Marker Codex Table with Guaranteed Hamming Distance.

    aruco_5x5_1000_table

    fn aruco_5x5_1000_table() -> Array[Int64]

    aruco_5x5_250_table

    fn aruco_5x5_250_table() -> Array[Int64]

    aruco_5x5_50_pairwise_distance_matrix

    fn aruco_5x5_50_pairwise_distance_matrix() -> Array[Array[Int]]

    Precomputed Hamming distance matrix between all pairs in ArUco 5x5 50 dictionary.

    aruco_5x5_canonical_table

    fn aruco_5x5_canonical_table() -> Array[Int64]

    Full aruco_5x5_canonical_table Codeword Array (1000 markers).

    aruco_6x6_1000_table

    fn aruco_6x6_1000_table() -> Array[Int64]

    aruco_6x6_250_table

    fn aruco_6x6_250_table() -> Array[Int64]

    aruco_6x6_50_pairwise_distance_matrix

    fn aruco_6x6_50_pairwise_distance_matrix() -> Array[Array[Int]]

    Precomputed Hamming distance matrix between all pairs in ArUco 6x6 50 dictionary.

    aruco_6x6_canonical_table

    fn aruco_6x6_canonical_table() -> Array[Int64]

    Full aruco_6x6_canonical_table Codeword Array (1000 markers).

    aruco_7x7_1000_table

    fn aruco_7x7_1000_table() -> Array[Int64]

    aruco_7x7_250_table

    fn aruco_7x7_250_table() -> Array[Int64]

    aruco_7x7_50_pairwise_distance_matrix

    fn aruco_7x7_50_pairwise_distance_matrix() -> Array[Array[Int]]

    Precomputed Hamming distance matrix between all pairs in ArUco 7x7 50 dictionary.

    aruco_7x7_canonical_table

    fn aruco_7x7_canonical_table() -> Array[Int64]

    Full aruco_7x7_canonical_table Codeword Array (1000 markers).

    backproject_pixel_to_ray

    fn backproject_pixel_to_ray(pixel : Point2D, pose : Pose3D, camera : CameraIntrinsics) -> (Point3D, Point3D)

    Back-projects a 2D image pixel into a 3D unit ray in world coordinates.

    build_image_pyramid

    fn build_image_pyramid(img : Image, max_level : Int) -> Array[Image]

    Builds an image pyramid with Gaussian downsampling for multi-scale optical flow.

    calibrate_camera_zhang

    fn calibrate_camera_zhang(calibrator : CameraCalibrator) -> CalibrationResult?

    Calibrates camera intrinsics K and per-frame extrinsics from multi-view planar board frames using Zhang's method.

    chaikin_smooth

    fn chaikin_smooth(points : Array[Point2D], iterations : Int) -> Array[Point2D]

    Chaikin's corner cutting algorithm for curve and polygon smoothing.

    clip_polygon_to_rect

    fn clip_polygon_to_rect(poly : Polygon2D, rect : Rect2D) -> Polygon2D

    Sutherland-Hodgman polygon clipping algorithm against a rectangular clipping window.

    compute_convex_hull

    fn compute_convex_hull(points : Array[Point2D]) -> Polygon2D

    Computes convex hull of 2D points using Andrew's Monotone Chain algorithm.

    compute_gradient_magnitude_and_angle

    fn compute_gradient_magnitude_and_angle(gx : Array[Double], gy : Array[Double]) -> (Array[Double], Array[Double])

    Computes gradient magnitude sqrt(Gx^2 + Gy^2) and orientation atan2(Gy, Gx).

    compute_hamming_distance

    fn compute_hamming_distance(val1 : Int64, val2 : Int64) -> Int

    Computes bitwise Hamming distance between two 64-bit integers (popcount of XOR).

    compute_integral_image

    fn compute_integral_image(img : Image) -> Array[Int]

    Computes 2D Integral Image for fast O(1) box sum queries.

    compute_integral_image_sq

    fn compute_integral_image_sq(img : Image) -> Array[Double]

    Computes 2D Integral of squared pixels for variance calculation.

    compute_reprojection_metrics

    fn compute_reprojection_metrics(object_points : Array[Point3D], image_points : Array[Point2D], pose : Pose3D, camera : CameraIntrinsics) -> ReprojectionMetrics

    Computes comprehensive reprojection error metrics for 3D-to-2D correspondences.

    connected_components

    fn connected_components(binary_img : Image, connectivity_8? : Bool) -> (Array[Int], Array[ConnectedComponent])

    Connected Component Labeling (CCL) using Two-Pass Union-Find algorithm (8-connectivity or 4-connectivity). Returns (labeled_image, components_array).

    convert_opencv_pose_to_unity

    fn convert_opencv_pose_to_unity(pose : Pose3D) -> Pose3D

    Converts an OpenCV right-handed camera pose (X-right, Y-down, Z-forward) to Unity left-handed pose (X-right, Y-up, Z-forward).

    decode_quad_marker

    fn decode_quad_marker(src_img : Image, quad : Quad, dict : MarkerDictionary) -> MarkerDetection?

    Full decoding pipeline for a single candidate quad.

    detect_diamond_markers

    fn detect_diamond_markers(detections : Array[MarkerDetection], square_length : Double, marker_length : Double, camera? : CameraIntrinsics) -> Array[DiamondDetection]

    Detects ArUco Diamond Markers from detected marker corners. A diamond consists of 4 markers arranged in a 3x3 layout.

    detect_fast_corners

    fn detect_fast_corners(img : Image, threshold? : Int, nonmax_suppression? : Bool) -> Array[Point2D]

    FAST-9 Corner Detector (Features from Accelerated Segment Test).

    detect_harris_corners

    fn detect_harris_corners(img : Image, k_param? : Double, threshold? : Double, nms_radius? : Int) -> Array[CornerPoint]

    Harris Corner Detector: Computes corner response map and extracts local maxima.

    detect_line_segments

    fn detect_line_segments(img : Image, min_length? : Double, gradient_threshold? : Double) -> Array[LineSegment]

    Fast Line Segment Detector (LSD) implementation for extracting straight edge segments.

    detect_markers

    fn detect_markers(img : Image, dict : MarkerDictionary) -> Array[MarkerDetection]

    Detects all fiducial markers in an image using dictionary.

    detect_markers_with_params

    fn detect_markers_with_params(img : Image, dict : MarkerDictionary, params : DetectorParameters, camera_matrix? : CameraIntrinsics?, marker_length? : Double) -> Array[MarkerDetection]

    Comprehensive Marker Detection Pipeline parameterized with DetectorParameters.

    detect_shi_tomasi_corners

    fn detect_shi_tomasi_corners(img : Image, threshold? : Double, nms_radius? : Int) -> Array[CornerPoint]

    Shi-Tomasi Corner Detector (Good Features to Track): Uses minimum eigenvalue of M.

    dictionary_apriltag_16h5

    fn dictionary_apriltag_16h5() -> MarkerDictionary

    Official AprilTag 16h5 (tag16h5) dictionary definition (30 canonical codewords). Minimum inter-codeword Hamming distance across all 4 rotations is EXACTLY 5 (h5). Max correction bits = 2.

    dictionary_apriltag_25h9

    fn dictionary_apriltag_25h9() -> MarkerDictionary

    Official AprilTag 25h9 (tag25h9) dictionary definition (35 canonical 25-bit codewords). Minimum inter-codeword Hamming distance across all 4 rotations is EXACTLY 9 (h9). Max correction bits = 3.

    dictionary_apriltag_36h11

    fn dictionary_apriltag_36h11() -> MarkerDictionary

    Official AprilTag 36h11 (tag36h11) dictionary definition (first 30 canonical 36-bit codewords). Minimum inter-codeword Hamming distance across all 4 rotations is EXACTLY 11 (h11). Max correction bits = 5.

    dictionary_apriltag_36h11_full

    fn dictionary_apriltag_36h11_full() -> MarkerDictionary

    AprilTag 36h11 Full 587 Codewords Dictionary.

    dictionary_apriltag_circle21h7

    fn dictionary_apriltag_circle21h7() -> MarkerDictionary

    AprilTag Circle21h7 dictionary definition (38 canonical 21-bit codewords). Minimum inter-codeword Hamming distance across all 4 rotations is EXACTLY 7.

    dictionary_apriltag_circle49h12

    fn dictionary_apriltag_circle49h12() -> MarkerDictionary

    AprilTag Circle49h12 Dictionary (65 codewords, 49 bits, min distance 12).

    dictionary_apriltag_custom48h12

    fn dictionary_apriltag_custom48h12() -> MarkerDictionary

    AprilTag Custom48h12 Dictionary (48 bits, min distance 12).

    dictionary_apriltag_standard41h12

    fn dictionary_apriltag_standard41h12() -> MarkerDictionary

    AprilTag Standard41h12 dictionary definition (41-bit payload, minimum Hamming distance 12).

    dictionary_apriltag_standard52h13

    fn dictionary_apriltag_standard52h13() -> MarkerDictionary

    AprilTag Standard52h13 dictionary definition (52-bit payload, minimum Hamming distance 13).

    dictionary_aruco_4x4_100

    fn dictionary_aruco_4x4_100() -> MarkerDictionary

    OpenCV ArUco DICT_4X4_100 dictionary (100 codewords, 4x4 grid, 16 bits).

    dictionary_aruco_4x4_1000

    fn dictionary_aruco_4x4_1000() -> MarkerDictionary

    OpenCV ArUco DICT_4X4_1000 (1000 markers).

    dictionary_aruco_4x4_250

    fn dictionary_aruco_4x4_250() -> MarkerDictionary

    OpenCV ArUco DICT_4X4_250 (250 markers).

    dictionary_aruco_4x4_50

    fn dictionary_aruco_4x4_50() -> MarkerDictionary

    Official OpenCV ArUco DICT_4X4_50 dictionary definition (50 canonical codewords). Minimum inter-codeword Hamming distance across all 4 rotations is EXACTLY 4. Max correction bits = 1.

    dictionary_aruco_5x5_100

    fn dictionary_aruco_5x5_100() -> MarkerDictionary

    OpenCV ArUco DICT_5X5_100 (100 markers).

    dictionary_aruco_5x5_1000

    fn dictionary_aruco_5x5_1000() -> MarkerDictionary

    OpenCV ArUco DICT_5X5_1000 (1000 markers).

    dictionary_aruco_5x5_250

    fn dictionary_aruco_5x5_250() -> MarkerDictionary

    OpenCV ArUco DICT_5X5_250 (250 markers).

    dictionary_aruco_5x5_50

    fn dictionary_aruco_5x5_50() -> MarkerDictionary

    OpenCV ArUco DICT_5X5_50 dictionary (50 codewords, 5x5 grid, 25 bits).

    dictionary_aruco_6x6_100

    fn dictionary_aruco_6x6_100() -> MarkerDictionary

    OpenCV ArUco DICT_6X6_100 (100 markers).

    dictionary_aruco_6x6_1000

    fn dictionary_aruco_6x6_1000() -> MarkerDictionary

    OpenCV ArUco DICT_6X6_1000 (1000 markers).

    dictionary_aruco_6x6_250

    fn dictionary_aruco_6x6_250() -> MarkerDictionary

    OpenCV ArUco DICT_6X6_250 (250 markers).

    dictionary_aruco_6x6_50

    fn dictionary_aruco_6x6_50() -> MarkerDictionary

    OpenCV ArUco DICT_6X6_50 dictionary (50 codewords, 6x6 grid, 36 bits).

    dictionary_aruco_7x7_100

    fn dictionary_aruco_7x7_100() -> MarkerDictionary

    OpenCV ArUco DICT_7X7_100 (100 markers).

    dictionary_aruco_7x7_1000

    fn dictionary_aruco_7x7_1000() -> MarkerDictionary

    OpenCV ArUco DICT_7X7_1000 (1000 markers).

    dictionary_aruco_7x7_250

    fn dictionary_aruco_7x7_250() -> MarkerDictionary

    OpenCV ArUco DICT_7X7_250 (250 markers).

    dictionary_aruco_7x7_50

    fn dictionary_aruco_7x7_50() -> MarkerDictionary

    OpenCV ArUco DICT_7X7_50 dictionary (50 codewords, 7x7 grid, 49 bits).

    dictionary_aruco_original

    fn dictionary_aruco_original() -> MarkerDictionary

    Original ArUco Dictionary (1024 codes, 5x5 grid, 25 bits).

    dictionary_mip_36h12

    fn dictionary_mip_36h12() -> MarkerDictionary

    MIP 36h12 marker dictionary (36 bits, 6x6 grid, minimum Hamming distance 12).

    equalize_histogram

    fn equalize_histogram(img : Image) -> Image

    Performs Global Histogram Equalization to enhance contrast.

    estimate_board_pose

    fn estimate_board_pose(board : GridBoard, detections : Array[MarkerDetection], camera : CameraIntrinsics) -> Pose3D?

    Estimates joint 6DOF 3D pose of the entire GridBoard from a collection of detected markers. Robust against occlusions as long as at least one marker is visible.

    estimate_charuco_pose

    fn estimate_charuco_pose(charuco_corners : CharucoCorners, camera : CameraIntrinsics) -> Pose3D?

    Estimates high-precision 3D pose of ChArUco board from interpolated corners.

    estimate_marker_pose

    fn estimate_marker_pose(quad : Quad, camera : CameraIntrinsics, marker_length : Double) -> Pose3D?

    Estimates 3D Pose (rvec, tvec) of a planar marker from 2D quad corners and camera intrinsics using DLT Homography decomposition.

    export_markers_to_obj

    fn export_markers_to_obj(detections : Array[MarkerDetection], marker_length : Double) -> String

    Exports detected marker 3D bounding cubes to Wavefront OBJ format string for 3D visualization in Blender/MeshLab.

    extract_quad_candidates

    fn extract_quad_candidates(contours : Array[Contour], min_area : Double, min_perimeter : Double) -> Array[Quad]

    Filters contours and extracts valid convex quadrilateral candidates.

    filter_bilateral

    fn filter_bilateral(img : Image, radius : Int, sigma_space : Double, sigma_color : Double) -> Image

    Edge-preserving bilateral filter using spatial Gaussian and photometric range Gaussian.

    filter_box_blur

    fn filter_box_blur(img : Image, radius : Int) -> Image

    Applies fast box blur with given kernel radius using integral image.

    filter_gaussian_blur

    fn filter_gaussian_blur(img : Image, radius : Int, sigma : Double) -> Image

    Applies separable 2D Gaussian blur with radius and sigma.

    filter_laplacian

    fn filter_laplacian(img : Image) -> Image

    Computes 3x3 Laplacian 2nd derivative filter ([0 1 0; 1 -4 1; 0 1 0]).

    filter_median

    fn filter_median(img : Image, radius : Int) -> Image

    Applies 3x3 or 5x5 median filter for salt-and-pepper noise reduction.

    filter_scharr

    fn filter_scharr(img : Image) -> (Array[Double], Array[Double])

    Computes Scharr 3x3 optimal accurate gradient operator ([-3 0 3; -10 0 10; -3 0 3] / 16).

    filter_sobel

    fn filter_sobel(img : Image) -> (Array[Double], Array[Double])

    Computes Sobel 3x3 horizontal (Gx) and vertical (Gy) gradients. Returns (Gx, Gy) images with signed double precision in flat arrays.

    find_contours

    fn find_contours(binary_img : Image, min_points : Int) -> Array[Contour]

    Suzuki-Abe Topological Boundary Following algorithm to extract external and hole contours.

    find_homography

    fn find_homography(src_pts : Array[Point2D], dst_pts : Array[Point2D]) -> Matrix3x3?

    Computes 3x3 Homography Matrix H mapping 4 source points to 4 destination points using DLT.

    find_homography_dlt

    fn find_homography_dlt(src_pts : Array[Point2D], dst_pts : Array[Point2D]) -> Matrix3x3?

    Normalized Direct Linear Transform (DLT) for N >= 4 point correspondences.

    find_homography_ransac

    fn find_homography_ransac(src_pts : Array[Point2D], dst_pts : Array[Point2D], max_iterations? : Int, inlier_threshold? : Double, _confidence? : Double, seed? : Int) -> RansacHomographyResult?

    Robust Homography estimation using RANSAC (Random Sample Consensus) algorithm.

    format_benchmark_markdown_table

    fn format_benchmark_markdown_table(results : Array[BenchmarkResult]) -> String

    Formats full markdown benchmark summary table.

    generate_aruco_bit_parity_table

    fn generate_aruco_bit_parity_table() -> Array[Int]

    Precomputed Bit Parity and Hamming Neighborhood Lookups for ArUco Standard Dictionaries. Accelerates error correction and bit voting in real-time embedded environments.

    generate_custom_dictionary

    fn generate_custom_dictionary(name : String, grid_size : Int, num_markers : Int, min_hamming_distance : Int, seed? : Int) -> MarkerDictionary

    Generates a custom fiducial marker dictionary using a greedy packing search algorithm. Guarantees that the minimum Hamming distance across all 4 rotations between any two markers is >= min_distance.

    generate_gaussian_kernel_1d

    fn generate_gaussian_kernel_1d(radius : Int, sigma : Double) -> Array[Double]

    Generates a 1D Gaussian kernel with given radius and standard deviation sigma.

    generate_rotation_table_4x4

    fn generate_rotation_table_4x4() -> Array[Int]

    Precomputed 4-way 90-degree bit rotation lookup table for 16-bit 4x4 grids.

    generate_synthetic_marker_image

    fn generate_synthetic_marker_image(id : Int, dict : MarkerDictionary, marker_pixel_size : Int, margin_pixels : Int) -> Image?

    Generates a synthetic fiducial marker image for ArUco or AprilTag dictionaries.

    interpolate_charuco_corners

    fn interpolate_charuco_corners(img : Image, board : CharucoBoard, marker_detections : Array[MarkerDetection], camera? : CameraIntrinsics) -> CharucoCorners

    Interpolates internal chessboard corners from detected ArUco markers on a ChArUco board.

    intersect_ray_with_plane

    fn intersect_ray_with_plane(ray_origin : Point3D, ray_dir : Point3D, plane_normal : Point3D, plane_d : Double) -> Point3D?

    Intersects a camera ray with a 3D plane defined by normal and distance d (normal . X + d = 0).

    inverse_perspective_mapping

    fn inverse_perspective_mapping(img : Image, ground_corners : Quad, output_size : Size2D) -> Image?

    Inverse Perspective Mapping (IPM): Projects camera perspective view to an orthographic top-down ground plane.

    is_quad_convex

    fn is_quad_convex(quad : Quad) -> Bool

    Checks if a 4-point polygon is strictly convex.

    min_area_bounding_box

    fn min_area_bounding_box(polygon : Polygon2D) -> Quad

    Computes minimum area enclosing rectangle using Rotating Calipers on a convex polygon.

    minimum_enclosing_circle

    fn minimum_enclosing_circle(points : Array[Point2D]) -> (Point2D, Double)

    Computes Minimum Enclosing Circle using Welzl's algorithm. Returns (center, radius).

    morph_black_hat

    fn morph_black_hat(img : Image, element : StructuringElement) -> Image

    Black-Hat Transform: Closing minus Original image (extracts dark elements smaller than SE).

    morph_close

    fn morph_close(img : Image, element : StructuringElement) -> Image

    Morphological Closing: Dilate followed by Erode (fills small dark holes).

    morph_dilate

    fn morph_dilate(img : Image, element : StructuringElement) -> Image

    Morphological Dilation (local maximum operator).

    morph_erode

    fn morph_erode(img : Image, element : StructuringElement) -> Image

    Morphological Erosion (local minimum operator).

    morph_gradient

    fn morph_gradient(img : Image, element : StructuringElement) -> Image

    Morphological Gradient: Dilate minus Erode (highlights object boundaries).

    morph_open

    fn morph_open(img : Image, element : StructuringElement) -> Image

    Morphological Opening: Erode followed by Dilate (removes small bright noise).

    morph_top_hat

    fn morph_top_hat(img : Image, element : StructuringElement) -> Image

    Top-Hat Transform: Original image minus Opening (extracts bright elements smaller than SE).

    normalize_points_hartley

    fn normalize_points_hartley(points : Array[Point2D]) -> (Array[Point2D], Matrix3x3)

    Hartley Isotropic Coordinate Normalization: Translates centroid to origin and scales average distance to sqrt(2). Returns (normalized_points, 3x3_normalization_matrix).

    order_quad_corners

    fn order_quad_corners(pts : Array[Point2D]) -> Quad

    Reorders 4 corners of a quad into canonical order: TL (0), TR (1), BR (2), BL (3).

    parse_pgm_ascii

    fn parse_pgm_ascii(content : String) -> Image?

    Parses an ASCII PGM (P2) string into an 8-bit grayscale Image.

    parse_ppm_ascii

    fn parse_ppm_ascii(content : String) -> ColorImage?

    Parses an ASCII PPM (P3) string into a 24-bit ColorImage.

    perpendicular_distance

    fn perpendicular_distance(p : Point2D, a : Point2D, b : Point2D) -> Double

    Computes perpendicular distance from point p to line segment (a, b).

    point_to_segment_distance

    fn point_to_segment_distance(p : Point2D, a : Point2D, b : Point2D) -> Double

    Computes perpendicular distance from point p to line segment (a, b).

    project_3d_point

    fn project_3d_point(pt : Point3D, pose : Pose3D, camera : CameraIntrinsics) -> Point2D

    Projects a 3D point in world/marker space onto 2D image pixel coordinates with Brown-Conrady lens distortion.

    query_integral_sum

    fn query_integral_sum(integral : Array[Int], w : Int, _h : Int, x0 : Int, y0 : Int, x1 : Int, y1 : Int) -> Int

    Queries the sum of pixels inside a rectangular window [x0, x1] x [y0, y1] using integral image.

    rdp_simplify

    fn rdp_simplify(pts : Array[Point2D], epsilon : Double) -> Array[Point2D]

    Simplifies a polyline using Ramer-Douglas-Peucker (RDP) algorithm.

    refine_corner_subpixel

    fn refine_corner_subpixel(img : Image, initial_corner : Point2D, window_radius? : Int, max_iterations? : Int, epsilon? : Double) -> Point2D

    Subpixel Corner Refinement using Inverted Hessian and Gradient Orthogonality. Iteratively solves: sum (nabla I(p_i) * nabla I(p_i)^T) * (q - p_i) = 0 for refined corner q.

    refine_quad_corners

    fn refine_quad_corners(img : Image, quad : Quad, window_radius? : Int) -> Quad

    Refines all 4 corners of a quadrilateral to sub-pixel accuracy.

    render_ascii_art

    fn render_ascii_art(img : Image, target_width? : Int, use_unicode_blocks? : Bool) -> String

    Renders an 8-bit grayscale Image as an ASCII / Unicode block string for terminal display.

    render_detection_svg

    fn render_detection_svg(img : Image, detections : Array[MarkerDetection], camera : CameraIntrinsics?, axis_length : Double) -> String

    Renders an SVG overlay containing marker quads, ID labels, 3D coordinate axes, and bounding cubes.

    render_synthetic_scene

    fn render_synthetic_scene(config : SyntheticSceneConfig) -> Image

    Renders a full 3D synthetic marker scene onto a camera image plane.

    render_terminal_dashboard

    fn render_terminal_dashboard(stats : PerformanceStats, active_tracks : Array[MarkerTrack]) -> String

    Formats a complete visual terminal status dashboard for real-time video analytics.

    rotate_apriltag_16h5_bits

    fn rotate_apriltag_16h5_bits(bits : Int64) -> Int64

    Rotates AprilTag 16h5 16-bit payload according to official AprilTag spiral coordinate layout.

    rotate_bits_90

    fn rotate_bits_90(bits : Int64, grid_size : Int) -> Int64

    Rotates an N x N binary bit grid 90 degrees clockwise (standard raster order).

    rotate_quad_corners

    fn rotate_quad_corners(quad : Quad, rotation_index : Int) -> Quad

    Rotates 4 corners of a quad according to 90-degree rotation index.

    rotation_matrix_to_rvec

    fn rotation_matrix_to_rvec(rot : Matrix3x3) -> Point3D

    Converts 3x3 Rotation Matrix to Rodrigues rotation vector (rvec).

    run_resolution_benchmark

    fn run_resolution_benchmark(res_name : String, width : Int, height : Int, iterations : Int) -> BenchmarkResult

    Runs end-to-end detection benchmark on synthetic scenes at given resolution.

    rvec_to_rotation_matrix

    fn rvec_to_rotation_matrix(rvec : Point3D) -> Matrix3x3

    Converts Rodrigues rotation vector (rvec) to 3x3 Rotation Matrix using Rodrigues formula.

    sample_cell_intensity_multisample

    fn sample_cell_intensity_multisample(sampled_grid : Image, cell_r : Int, cell_c : Int, total_cells : Int, samples_per_dim? : Int) -> Double

    Sub-grid multi-point cell sampling with Gaussian spatial kernel for robust bit decoding under noise.

    sample_payload_bits

    fn sample_payload_bits(sampled_grid : Image, dict : MarkerDictionary, binary_threshold : Int) -> Int64

    Extracts binary grid payload bits from inner cells of sampled grid.

    sample_payload_bits_otsu

    fn sample_payload_bits_otsu(sampled_grid : Image, dict : MarkerDictionary) -> Int64

    Extracts binary grid payload bits using Otsu's optimal binarization threshold on the inner grid.

    shape_circularity

    fn shape_circularity(area : Double, perimeter : Double) -> Double

    Computes shape circularity (4 * pi * Area / Perimeter^2). Circle = 1.0, Square ~ 0.785.

    so3_exp

    fn so3_exp(omega : Point3D) -> Quaternion

    SO(3) Lie algebra exponential map: so(3) -> SO(3) (vector omega to Quaternion).

    so3_log

    fn so3_log(q : Quaternion) -> Point3D

    SO(3) Lie algebra logarithm map: SO(3) -> so(3) (Quaternion to vector omega).

    solve_pnp

    fn solve_pnp(object_points : Array[Point3D], image_points : Array[Point2D], camera : CameraIntrinsics) -> Pose3D?

    Solves Perspective-n-Point problem for general planar/non-planar targets.

    solve_pnp_epnp

    fn solve_pnp_epnp(object_points : Array[Point3D], image_points : Array[Point2D], camera : CameraIntrinsics) -> Pose3D?

    EPnP (Efficient Perspective-n-Point) Algorithm (Lepetit, Moreno-Noguer, Fua - IJCV 2009). Solves general non-planar/planar PnP in O(N) time using 4 virtual control points.

    solve_pnp_ippe

    fn solve_pnp_ippe(object_points : Array[Point3D], image_points : Array[Point2D], camera : CameraIntrinsics) -> IppeResult?

    Solves planar PnP using Infinitesimal Plane-based Pose Estimation (IPPE). Returns two analytical pose solutions and their reprojection error ratio.

    solve_pnp_levenberg_marquardt

    fn solve_pnp_levenberg_marquardt(object_points : Array[Point3D], image_points : Array[Point2D], initial_pose : Pose3D, camera : CameraIntrinsics, max_iterations? : Int, epsilon? : Double) -> Pose3D

    Levenberg-Marquardt Non-Linear Pose Optimization: Minimizes geometric reprojection error sum ||p_i - pi(K, exp(omega)*R, t + delta_t, P_i)||^2.

    solve_pnp_ransac

    fn solve_pnp_ransac(object_points : Array[Point3D], image_points : Array[Point2D], camera : CameraIntrinsics, max_iterations? : Int, inlier_threshold? : Double, seed? : Int) -> RansacPnpResult?

    Robust Perspective-n-Point estimation using RANSAC.

    symmetric_transfer_error

    fn symmetric_transfer_error(h : Matrix3x3, h_inv : Matrix3x3, src : Point2D, dst : Point2D) -> Double

    Computes symmetric transfer error for a point correspondence under homography H and H^(-1).

    threshold_adaptive

    fn threshold_adaptive(img : Image, window_size : Int, constant_c : Int) -> Image

    Fast Bradley adaptive thresholding based on 2D Integral Image in O(1) time per pixel.

    threshold_global

    fn threshold_global(img : Image, threshold : Int) -> Image

    Applies a global binary threshold to the image (pixels >= threshold become 255, else 0).

    threshold_niblack

    fn threshold_niblack(img : Image, window_size : Int, k_param : Double) -> Image

    Niblack local adaptive thresholding: T(x, y) = m(x, y) + k * s(x, y).

    threshold_otsu

    fn threshold_otsu(img : Image) -> Int

    Computes Otsu's optimal global binarization threshold based on maximum inter-class variance.

    threshold_sauvola

    fn threshold_sauvola(img : Image, window_size : Int, k_param : Double, dynamic_range_r : Double) -> Image

    Sauvola local adaptive thresholding for degraded documents and non-uniform illumination. T(x, y) = m(x, y) * (1 + k * (s(x, y) / R - 1))

    verify_black_border

    fn verify_black_border(sampled_grid : Image, total_cells : Int, black_threshold : Int) -> Bool

    Verifies if outer ring of sampled grid is predominantly a black border.

    verify_quiet_zone

    fn verify_quiet_zone(sampled_grid : Image, total_cells : Int, white_threshold? : Int, min_white_rate? : Double) -> Bool

    Verifies the quiet zone (white margin surrounding the fiducial marker).

    visvalingam_whyatt_simplify

    fn visvalingam_whyatt_simplify(points : Array[Point2D], min_area_threshold : Double) -> Array[Point2D]

    Visvalingam-Whyatt area-based polygon simplification algorithm. Progressively eliminates vertices forming the triangle of minimum effective area.

    warp_perspective

    fn warp_perspective(src : Image, h_mat : Matrix3x3, dst_width : Int, dst_height : Int, border_value? : Int) -> Image

    Warps an entire image using a 3x3 homography matrix with bilinear interpolation.

    warp_perspective_color

    fn warp_perspective_color(src : ColorImage, h_mat : Matrix3x3, dst_width : Int, dst_height : Int) -> ColorImage

    Warps a 24-bit color image using a 3x3 homography matrix.

    warp_perspective_grid

    fn warp_perspective_grid(src_img : Image, src_quad : Quad, grid_size : Int) -> Image?

    Warps perspective of src_img inside src_quad into a normalized NxN grid image.

    zhang_suen_thinning

    fn zhang_suen_thinning(binary_img : Image) -> Image

    Zhang-Suen binary thinning algorithm for extracting morphological skeletons.