MoonBit-native industrial visual caliper toolkit for edge-based measurement and tolerance reports.
moon update
moon check --target all --deny-warn
moon test --target all --deny-warn
moon run cmd/main///|
test "measure a synthetic bracket" {
let image = make_demo_part()
let pixels = gauge_width(
image,
Point::Point(x=10.0, y=20.0),
Point::Point(x=70.0, y=20.0),
)
let scale = calibration_from_reference(pixels, 22.0)
let tolerance = Tolerance::Tolerance(nominal=22.0, lower=21.8, upper=22.2)
let result = analyze_gap("outer width", pixels, scale, tolerance)
assert_eq(result.decision, MeasurementDecision::Pass)
}moon run cmd/mainmoon run cmd/benchmark| Layer | Responsibilities |
|---|---|
| types.mbt, numeric.mbt | Domain records, vectors, matrices, statistics, tolerances |
| image.mbt, image_ops.mbt, image_statistics.mbt, image_pyramid.mbt | Image storage, filtering, gradients, thresholds, pyramids |
| mask.mbt, morphology_advanced.mbt, components.mbt, contours.mbt | Binary operations, regions, boundaries, shape descriptors |
| profile.mbt, signal_profiles.mbt, caliper_pipeline.mbt, advanced_calipers.mbt | Profile calipers, edge policies, quality and repeatability |
| geometry.mbt, transforms.mbt, geometry_fit.mbt, geometry_primitives.mbt | Fitting, transforms, projections and geometric metrics |
| calibration*.mbt, uncertainty.mbt | Pixel-to-unit models, residuals and uncertainty |
| measurements.mbt, measurement_suite.mbt, batch*.mbt | Feature measurements and batch analytics |
| serialization.mbt, report*.mbt, diagnostics.mbt | Human-readable and machine-readable outputs |
| fixtures.mbt, benchmark_workloads.mbt, cmd/ | Reproducible examples and executable entry points |
moon run cmd/benchmarkmoon fmt --check
moon check --target all --deny-warn
moon test --target all --deny-warn
moon info
git diff --exit-codepub(all) struct AffineTransform {
a : Double
b : Double
c : Double
d : Double
tx : Double
ty : Double
} derive(Debug)fn AffineTransform::AffineTransform(a~ : Double, b~ : Double, c~ : Double, d~ : Double, tx~ : Double, ty~ : Double) -> AffineTransformfn AffineTransform::from_correspondences(source : Array[Point], target : Array[Point]) -> AffineTransformfn AffineTransform::try_from_correspondences(source : Array[Point], target : Array[Point]) -> AffineTransform?pub(all) struct BatchStatistics {
id : String
total : Int
accepted : Int
rejected : Int
mean : Double
standard_deviation : Double
minimum : Double
maximum : Double
} derive(Debug)pub(all) struct CalibrationFit {
transform : AffineTransform
residuals : Array[Double]
rms_error : Double
max_error : Double
} derive(Debug)fn CaliperConfig::new(start~ : Point, finish~ : Point, threshold~ : Double, mode? : EdgeMode, expected_edges? : Int, unit? : String) -> CaliperConfigpub(all) struct DiagnosticEvent {
code : String
stage : String
detail : String
value : Double
} derive(Debug)pub(all) struct EdgeMapSummary {
edges : BinaryMask
count : Int
density : Double
mean_strength : Double
} derive(Debug)fn EdgePolicy::new(low_threshold~ : Double, high_threshold~ : Double, mode? : EdgeMode, min_strength? : Double) -> EdgePolicypub(all) struct FeatureMeasurement {
name : String
value : Double
unit : String
confidence : Double
decision : MeasurementDecision
} derive(Debug)pub(all) struct Measurement {
name : String
value : Double
unit : String
decision : MeasurementDecision
deviation : Double
} derive(Debug)pub(all) struct MeasurementReport {
part_id : String
measurements : Array[Measurement]
notes : Array[String]
} derive(Debug)pub(all) struct MeasurementSummary {
total : Int
pass : Int
warn : Int
fail : Int
acceptance_rate : Double
values : StatsSummary
} derive(Debug)pub(all) struct PipelineDiagnostic {
stage : String
message : String
severity : MeasurementDecision
} derive(Debug)pub(all) struct PipelineResult {
measurements : Array[Measurement]
diagnostics : Array[PipelineDiagnostic]
accepted : Bool
confidence : Double
} derive(Debug)fn ProfileSample::detect_edges(samples : Array[ProfileSample], threshold : Double, mode? : EdgeMode) -> Array[EdgePoint]pub(all) struct Tolerance {
nominal : Double
lower : Double
upper : Double
unit : String
} derive(Debug)pub(all) struct UncertaintyEstimate {
standard : Double
expanded : Double
coverage : Double
source : String
} derive(Debug)fn analyze_gap(name : String, pixel_gap : Double, scale : Double, tolerance : Tolerance) -> Measurementfn apply_tolerances(measurements : Array[Measurement], tolerances : Array[Tolerance]) -> Array[Measurement]fn benchmark_component_workload(width : Int, height : Int, rounds : Int) -> Intfn benchmark_geometry_workload(point_count : Int, rounds : Int) -> Doublefn benchmark_image_workload(width : Int, height : Int, rounds : Int) -> Doublefn best_template_match(image : GrayImage, template : GrayImage, minimum_score : Double) -> MatchResultfn calibrate_anisotropic(pixel_x : Double, pixel_y : Double, physical_x : Double, physical_y : Double) -> AffineTransformfn calibrate_from_rectangle(source : Bounds, target_width : Double, target_height : Double) -> AffineTransformfn calibration_apply_to_components(fit : CalibrationFit, components : Array[Component]) -> Array[Component]fn calibration_from_reference(pixel_distance : Double, physical_distance : Double) -> Doublefn confidence_from_uncertainty(measurement : Measurement, uncertainty : UncertaintyEstimate, tolerance : Tolerance) -> Doublefn contract_merge(first : Array[PipelineDiagnostic], second : Array[PipelineDiagnostic]) -> Array[PipelineDiagnostic]fn convolve_separable(image : GrayImage, kernel : Array[Double], policy? : BorderPolicy) -> GrayImagefn diagnostic_event(code : String, stage : String, detail : String, value : Double) -> DiagnosticEventfn diagonal_edge_fixture(width : Int, height : Int, slope : Double, intercept : Double) -> GrayImagefn edge_profile(image : GrayImage, start : Point, finish : Point, steps? : Int) -> Array[ProfileSample]fn feature_to_measurement(feature : FeatureMeasurement, nominal : Double, lower : Double, upper : Double) -> Measurementfn fixture_measurement(image : GrayImage, start : Point, finish : Point, nominal : Double) -> Measurementfn frame_diagnostics(image : GrayImage, config : CaliperConfig, tolerance : Tolerance) -> Array[DiagnosticEvent]fn gauge_risk_score(profile : ProfileSummary, tolerance : Tolerance, measurement : Double) -> Doublefn guard_band_decision(value : Double, tolerance : Tolerance, uncertainty : UncertaintyEstimate) -> MeasurementDecisionfn inspect_batch(images : Array[GrayImage], config : CaliperConfig, tolerance : Tolerance) -> BatchRunfn inspect_circle(image : GrayImage, center : Point, radius : Double, threshold : Double, scale : Double, nominal_diameter : Double) -> PipelineResultfn inspect_edge_pair(image : GrayImage, config : CaliperConfig, scale : Double, tolerance : Tolerance) -> PipelineResultfn inspect_rectangle(_image : GrayImage, bounds : Bounds, nominal_width : Double, nominal_height : Double, scale : Double) -> PipelineResultfn inspect_slot(image : GrayImage, bounds : Bounds, scale : Double, nominal : Double) -> PipelineResultfn inspection_all(image : GrayImage, calipers : Array[CaliperConfig], tolerance : Tolerance, fit : CalibrationFit?) -> PipelineResultfn inspection_report(part_id : String, image : GrayImage, measurements : Array[Measurement], diagnostics : Array[PipelineDiagnostic]) -> MeasurementReportfn inspection_retry(image : GrayImage, config : CaliperConfig, tolerance : Tolerance, attempts : Int) -> PipelineResultfn inspection_with_calibration(image : GrayImage, config : CaliperConfig, tolerance : Tolerance, fit : CalibrationFit) -> PipelineResultfn inspection_with_preprocessing(image : GrayImage, config : CaliperConfig, tolerance : Tolerance, blur_radius : Int) -> PipelineResultfn inspection_with_roi(image : GrayImage, roi : Roi, config : CaliperConfig, tolerance : Tolerance) -> PipelineResultfn inspection_with_uncertainty(result : PipelineResult, uncertainty : UncertaintyEstimate, tolerance : Tolerance) -> PipelineResultfn map_reference_grid(fit : AffineTransform, columns : Int, rows : Int, spacing_x : Double, spacing_y : Double) -> Array[Point]fn measure_caliper(image : GrayImage, config : CaliperConfig, tolerance : Tolerance) -> PipelineResultfn measure_caliper_with_scale(image : GrayImage, config : CaliperConfig, scale : Double, tolerance : Tolerance) -> PipelineResultfn measurement_confidence(measurement : Measurement, tolerance : Tolerance, quality : Double) -> Doublefn measurement_equal_with_tolerance(first : Measurement, second : Measurement, tolerance : Double) -> Boolfn measurement_with_uncertainty(measurement : Measurement, uncertainty : UncertaintyEstimate) -> Stringfn measurements_within(measurements : Array[Measurement], lower : Double, upper : Double) -> Array[Measurement]fn normalized_quality(value : Double, lower : Double, upper : Double) -> Doublefn process_frame(image : GrayImage, config : CaliperConfig, tolerance : Tolerance) -> PipelineResultfn process_frames(images : Array[GrayImage], config : CaliperConfig, tolerance : Tolerance) -> BatchRunfn process_pyramid(image : GrayImage, config : CaliperConfig, tolerance : Tolerance, levels : Int) -> PipelineResultfn profile_best_shift(first : Array[ProfileSample], second : Array[ProfileSample], maximum_shift : Int) -> Intfn profile_exponential_smooth(samples : Array[ProfileSample], alpha : Double) -> Array[ProfileSample]fn profile_fixture(length : Int, first_edge : Int, second_edge : Int, low : Double, high : Double) -> Array[ProfileSample]fn profile_from_values(values : Array[Double], start : Point, finish : Point) -> Array[ProfileSample]fn profile_outlier_repaired(samples : Array[ProfileSample], z_limit : Double) -> Array[ProfileSample]fn propagate_addition(first : UncertaintyEstimate, second : UncertaintyEstimate) -> UncertaintyEstimatefn propagate_product(value : Double, uncertainty : UncertaintyEstimate, factor : Double) -> UncertaintyEstimatefn propagate_scale_uncertainty(value : Double, scale : Double, scale_uncertainty : Double) -> UncertaintyEstimatefn quality_score_report(image : GrayImage, profile : ProfileSummary, measurements : Array[Measurement]) -> Stringfn radial_caliper_profile(image : GrayImage, center : Point, angle : Double, length : Double, samples : Int) -> Array[ProfileSample]fn rectangle_fixture(width : Int, height : Int, left : Int, top : Int, right : Int, bottom : Int, background : Double, foreground : Double) -> GrayImagefn render_full_report(part_id : String, image : GrayImage, result : PipelineResult, toolchain : String) -> Stringfn repeat_caliper(image : GrayImage, config : CaliperConfig, tolerance : Tolerance, repetitions : Int) -> StatsSummaryfn report_footer(toolchain : String) -> Stringfn rolling_decisions(values : Array[Double], tolerance : Tolerance, width : Int) -> Array[MeasurementDecision]fn run_caliper_suite(image : GrayImage, configs : Array[CaliperConfig], tolerance : Tolerance) -> PipelineResultfn safe_measure_caliper(image : GrayImage, config : CaliperConfig, tolerance : Tolerance) -> PipelineResultfn summarize_profile(samples : Array[ProfileSample], threshold : Double, mode? : EdgeMode) -> ProfileSummaryfn template_candidates(image : GrayImage, template : GrayImage, minimum_score : Double, maximum_count : Int) -> Array[MatchResult]fn to_feature_measurement(name : String, measurement : Measurement, confidence : Double) -> FeatureMeasurementfn try_calibrate_anisotropic(pixel_x : Double, pixel_y : Double, physical_x : Double, physical_y : Double) -> AffineTransform?fn try_calibration_from_reference(pixel_distance : Double, physical_distance : Double) -> Double?fn try_convolve_separable(image : GrayImage, kernel : Array[Double], policy? : BorderPolicy) -> GrayImage?fn uncertainty_is_acceptable(uncertainty : UncertaintyEstimate, tolerance : Tolerance, maximum_ratio : Double) -> Boolfn width_statistics_by_angle(image : GrayImage, center : Point, angle_count : Int, length : Double, threshold : Double) -> StatsSummaryInstall
Download zipMoonBit-native industrial visual caliper toolkit for edge-based measurement and tolerance reports.