Properties of the HALCON interfacesđź”—
HALCON/C++ is HALCON’s interface to the programming language C++. Together with the HALCON library, it allows using the image processing power of HALCON inside C++ programs.
Procedural or object-oriented
The HALCON/C++ interface provides two different approaches to use HALCON’s functionality within your C++ program:
a procedural and an object-oriented approach.
The procedural approach corresponds to calling HALCON operators directly as in C or HDevelop, for example:
HObject original_image, smoothed_image;
ReadImage(&original_image, "monkey");
MeanImage(original_image, &smoothed_image, 11, 11);
In addition to the procedural approach, HALCON/C++ allows you to call HALCON operators in an object-oriented way, that is, via a set of classes. For example, the code from above can be “translated” into
HImage original_image("monkey");
HImage smoothed_image = original_image.MeanImage(11, 11);
This simple example already shows that the two approaches result in clearly different code:
The operator calls differ in the number and type of parameters.
Furthermore, functionality may be available in different ways.
For example, images can be read from files via a constructor of the class HImage.
In general, we recommend using the object-oriented approach.
Note, however, that HDevelop can export programs only as procedural C++ code.
Specifying the namespace
All functions and classes of HALCON/C++ use the namespace HalconCpp to prevent potential name conflicts with other
-
Specifically, by prefixing each class name or operator call with the namespace:
-
Locally, by placing the directive
In this case, you can use HALCON’s classes and functions without prefix inside this block.using namespace HalconCpp;at the beginning of a block, e.g., at the beginning of a function: -
Globally, by placing the directive directly after including
HalconCpp.h. In this case, you do not need the prefix in your whole application: - Universally, which can be done both at local and global scope:
Which method is most suitable depends on your application, more specifically, what other libraries it contains and whether there are any name collisions.
Note
The namespace is not mentioned in the operator descriptions in the reference manual to keep it readable. Similarly, in the following sections the namespace is left out.
HALCON/.NET is HALCON’s interface to .NET programming languages, for example, C# or Visual Basic .NET. It provides you with a set of .NET classes and controls.
Platform independence
HALCON/.NET is highly platform-independent: It is written in C# but can be used in any language. Like .NET in general, it can be used under Windows and Linux, on 32-bit and 64-bit systems. In addition, successful experiments with .NET Core the implementation of HALCON/.NET were performed on Arm-based platforms.
Moreover, not only can you use it on all these platforms, but you can also run an application created on one of them on the others without having to recompile it. This is possible because applications written in .NET languages are stored in a platform-independent intermediate language (IL), which is then compiled by the so-called common language runtime (CLR) into platform-specific code.
.NET Core and .NET Framework
Basically, a .NET application is developed for one or more implementations of .NET like:
- .NET Core (and later versions starting with .NET 5)
- .NET Framework
- Mono
All .NET implementations listed above are supported. The interface for all of these implementations is the same as well as their documented behavior. For users, they mostly differ in terms of tooling and platform support. Most of the relevant differences are documented in Creating Applications.
NuGet packages are provided for .NET Core, and assemblies for .NET Framework.
HALCON/.NET XL and HDevEngine/.NET XL
Packages and assemblies are provided for both HALCON and HALCON XL. The packages for .NET Core are available with XL as suffix, for example: MVTec.HalconDotNet and MVTec.HalconDotNetXL.
The assemblies for .NET Framework are available with xl as suffix, for example halcondotnet.dll and halcondotnetxl.dll.
Specifying the namespace
To be able to use the HALCON/.NET classes without having to prefix them with their namespace, we recommend that you specify this namespace at the beginning of each source file by adding the following line:
For an example, see theMatchingForm.cs.
The corresponding Visual Basic .NET code is:
For an example, see theMatchingForm.vb.
HALCON/Python is a set of native Python language bindings for HALCON. This includes interfaces for operators, HALCON Script Engine, and interoperability for third-party libraries like NumPy.
The major design goals for HALCON/Python are simplicity and rapid prototyping.
Platform independence
HALCON/Python is officially supported for CPython, the reference implementation of the Python programming language. We test the interface on x64-win64 and x64-linux. In addition, successful experiments were performed on ARM with CPython.
Other Python implementations should work as long as they are appropriate implementations of the Python standard.
What’s more, not only can you use it on all these platforms, but you can run an application created on one of them on the other ones without having to recompile it. This is possible because applications written in Python are interpreted at runtime, instead of being compiled ahead of time.
HALCON/C is HALCON’s interface to the programming language C. Together with the HALCON library, it allows using the image processing power of HALCON inside C programs.
For more information, see the documentation of the parameter classes.