Our Product

AdaMachineVision

AdaMachineVision (AMV) is a machine vision library written in Ada 2022. It provides tools such as blob analysis, calipers and pattern location, and the SPARK kernels that hold the logic are proved free of run-time errors. It can also be used from C.

What AdaMachineVision is

It is a library that provides images, coordinate spaces, shapes and regions, and vision tools such as blob analysis, calipers and pattern search.

The kernels are written in SPARK and proved free of run-time errors. The library can also be used from C and does not depend on other libraries.

Features

A common way to run tools, and coordinate space trees

Every tool is run with Run, and Run_Status tells you how the run went. Blob, Caliper, Find Line, Find Circle, CNL Search and PMAlign take their run parameters in Run_Params and return their results in Results. Images carry a coordinate space tree, so you can work with positions in a coordinate space added under the root.

Kernels proved free of run-time errors

All logic lives in SPARK kernels (AMV.Kernels.*). For every kernel, gnatprove proves that no run-time error occurs. As of November 12, 2026, there are 34,514 checks, all of them proved. There is no pragma Assume and there are no justified checks. The assumptions behind the proofs and the parts that are not proved are described under “Scope and limits of the proofs” below.

Usable from C as well

The functions the kernels export take C-compatible types, check every input and report failures as a status instead of raising an exception. They are exported with the C calling convention, so they can be used as the C API (include/amv.h) as they are. The Ada API is a thin layer that only calls these functions and turns a failed status into an exception.

A C program calls adainit() before calling the first library function and adafinal() after the last one, and is linked together with the Ada runtime. Both functions are generated by the Ada binder. The C example and tests in the repository are set up to be built together with the Ada sources by gprbuild.

No dependency on other libraries

All you need to build it is GNAT and gprbuild. Reading and writing image files (PNM, BMP) is also implemented inside the library.

What it provides

The following is implemented and tested in version 0.1.0.

Core2-D transforms, coordinate space trees, 8-bit and 16-bit grayscale images, planar color images, image files (PNM, BMP), shapes and regions, floating-point image math, line and circle fitting, the tool framework
BlobBlob analysis: fixed, relative and dynamic thresholds and soft thresholds; connectivity and the parent-child relationships of blobs; a range of measures; filters and sorting
CaliperCaliper, Find Line, Find Circle
Dimensioning22 measuring tools; line, circle and ellipse fitting; 8 shape creation tools
Image ProcessingHistogram, PixelMap, SobelEdge, Sharpness, operations on one image (IPOneImage), affine transform, copying a region (CopyRegion), operations on two images (IPTwoImage), image format conversion (ImageConvert), polar unwrapping (PolarUnwrap)
CNL SearchSearch by normalized correlation, with train and search masks and partial matches
PMAlignLocating patterns under rotation and scale, with train and search masks
CalibFixFixtures, N-point fits, N-point calibration, checkerboard calibration (including a mode with perspective and radial distortion)
ToolGroup / ToolBlockA framework for running tools together

PMAlign’s search is AMV’s own method based on published literature.

Barcode reading and OCR are out of scope for version 0.1.0.

Code example

This example creates an image, adds a fixture coordinate space under the root, and converts a pixel position into a position in that coordinate space. It is examples/quick_look.adb from the repository, minus its opening comment.

with Ada.Text_IO;

with AMV;
with AMV.Image_File;
with AMV.Images;
with AMV.Misc;
with AMV.Transforms;

procedure Quick_Look is
   Image : AMV.Images.Ks_Image_8_Grey :=
     AMV.Images.Create (Width => 64, Height => 48, Value => 0);
   X, Y  : AMV.Real;
begin
   Image.Set_Pixel (X => 10, Y => 20, Value => 255);

   --  A fixture space under the root: its origin is at (5, 3) in the
   --  root and its axes are turned by 30 degrees. Parent_From_New maps
   --  fixture coordinates into the root (the parent).
   Image.Coordinate_Space_Tree.Add_Space
     (Parent_Space_Name => "@",
      New_Space_Name    => "Fixture",
      Parent_From_New   =>
        AMV.Transforms.Create_Rigid
          (Rotation      => AMV.Misc.Deg_To_Rad (30.0),
           Translation_X => 5.0,
           Translation_Y => 3.0));
   Image.Set_Selected_Space_Name ("@\Fixture");

   --  Where is the centre of pixel (10, 20) in the selected space?
   Image.Get_Transform (".", "#").Map_Point (10.0, 20.0, X, Y);
   Ada.Text_IO.Put_Line
     ("pixel (10, 20) is at" & X'Image & "," & Y'Image & " in "
      & Image.Selected_Space_Name);

   AMV.Image_File.Write_Image ("quick_look.pgm", Image);
   Ada.Text_IO.Put_Line ("wrote quick_look.pgm");
end Quick_Look;

The center of pixel (10, 20) is at about (12.83, 12.22) in fixture coordinates. The examples directory of the repository also contains a blob analysis example that counts the holes in each washer and passes or fails it, and an example that locates a part with PMAlign and then measures dimensions with calipers. The blob analysis example is also included in a version that uses the C API.

Scope and limits of the proofs

docs/PROOF.md describes what is proved and where the limits are. The main points are as follows.

  • The kernels are proved free of run-time errors. For the properties listed in that document, functional correctness is proved as well.
  • The proofs assume that floating-point values are finite. NaNs and infinities are rejected by the input checks of the kernels, which return a failure status. That they are rejected is checked by tests, not by proofs.
  • The thin Ada API, the reference counting for shared pixels, and small helpers for allocating memory and for copying to and from C memory, among others, are not proved.
  • For floating-point results, it is proved that they stay within their stated ranges and that they do not overflow. Their accuracy is checked by tests.
  • The accuracy of detection and measurement is not covered by the proofs either. It is checked by tests on synthetic images and tests on publicly available real images. In version 0.1.0, make test runs 26,487 checks in Ada and 914 in C.
  • The caller is trusted to pass valid pointers and handles from C, and to make sure that the pointers receiving results do not overlap the other arguments.

Getting the source and building it

The source is in the GitHub repository. You need the following to build it.

  • GNAT 16.1 and gprbuild 26 (the Ada build and tests also pass with GNAT 14)
  • gnatprove 16.1, if you want to rerun the proofs

The repository’s CI runs the build, the tests and the proofs on Ubuntu 24.04. Building on Windows is not checked in CI.

make build produces the static library (build/lib/libamv.a). make test runs the Ada tests and the C API tests, and make prove runs the proofs of the kernels.

Versions

The first version recorded in CHANGELOG.md is 0.1.0 (November 12, 2026). The main branch of the repository contains the changes made after it (Unreleased in the CHANGELOG). The ABI version of the C API is 2 in 0.1.0 and 3 on main.

Because the version is still below 1.0.0, a minor version update may break compatibility. When the compatibility of the C API changes, the ABI version (ks_abi_version) is raised and the change is recorded in the CHANGELOG.

License

AMV is dual-licensed. Which license applies depends on what you use it for.

Noncommercial useFree of charge. The PolyForm Noncommercial License 1.0.0 applies. Noncommercial use includes personal study, hobby projects and research without an anticipated commercial application, and use by educational institutions, public research organizations, charitable organizations and government institutions.
Commercial useA paid commercial license is required. Examples are selling a product or service that contains AMV, and a company running it on its own production or inspection line. Please contact us about the cost.

If you are not sure which one applies, you can also ask us through the contact page. The detailed terms are in LICENSING.md and LICENSE.md in the repository.

The source is public, but because the free license excludes commercial use, AMV is not open source in the sense of the Open Source Definition. Under the free license, the software comes as is, without any warranty, as far as the law allows.

The copyright notice is “Copyright (c) 2026 Go Komura”. The copyright holder, Go Komura, is the representative of KomuraSoft, and KomuraSoft handles inquiries about commercial licenses.

Help with adoption

Besides commercial licensing, you can consult us in cases such as the following.

  • You want to find out whether your own inspection or measurement processing can be built with AMV
  • You want to call inspection or measurement processing that uses AMV from a C# or C++ application
  • You want to build an application that covers camera image acquisition, integration with equipment and saving the results

Application development is offered as our Machine Vision & Image Processing Windows Software Development service.

Frequently Asked Questions

Is AdaMachineVision free to use?
For noncommercial use, it is free of charge under the PolyForm Noncommercial License 1.0.0. That includes, among others, personal study, hobby projects and research without an anticipated commercial application, and use by educational institutions and public research organizations. Any other use, such as building it into a product or service or running it on a company's production or inspection line, needs a paid commercial license.
Can it be used from C or C#?
It can be used from C. The functions of the kernels that hold the logic are exported with the C calling convention, and include/amv.h is that C API. Failures are returned as a status, not raised as exceptions. A C program calls adainit() first and adafinal() last, and is linked together with the Ada runtime. The library is built as a static library, and no C# wrapper is included. To use it from C#, you need to package the C API as a shared library and call it through P/Invoke.
What exactly is proved?
For the kernels written in SPARK, gnatprove proves that no run-time error occurs (out-of-bounds access, overflow, division by zero and so on). For the properties listed in docs/PROOF.md in the repository, functional correctness is proved as well. The proofs assume that floating-point values are finite; NaNs and infinities are rejected by a check. The accuracy of floating-point computation and the accuracy of detection and measurement are not covered by the proofs and are checked by tests.
Can it read barcodes or do OCR?
Not in version 0.1.0. Barcode reading and OCR are out of scope.

Consult Us Here

If this page is close to the situation you are dealing with, please consult us and include the current context and what kind of support you need.

Back to Home