arm_based_platforms
arm_based_platforms
This manual provides supplementary information about using HALCON on Arm® -based platforms.
Chapter 1 briefly describes the specifics for these platforms and the available development methods.
Chapter 2 briefly explains how to install HALCON on the development PC and on the Arm-based platform.
Chapter 3 explains how to develop applications in HDevelop or the programming languages C, C++, C#, Python
and HDevEngine.
An up-to-date list of supported platforms can be found on our website http://www.mvtec.com/products/
embedded-vision/all-products.
Contents
2 Getting Started 9
2.1 Installing the Necessary Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.1 Installing HALCON on the Development PC Running Under Linux . . . . . . . . . . . . 9
2.1.2 Installing HALCON on the Arm-based Platform . . . . . . . . . . . . . . . . . . . . . . 10
2.2 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.1 Installing the License on the Arm-based Platform . . . . . . . . . . . . . . . . . . . . . . 10
3 Creating Applications 11
3.1 Configuration Files and Directory Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.1 Cross-Compile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.2 Compile and Run on a Native Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Developing in HDevelop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Creating C++ Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Creating C Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5 Creating C# Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6 Creating Python Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.7 Using HDevEngine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Using HALCON on Arm-based Platforms 7
Introduction
Chapter 1
This chapter provides a brief overview on the specifics of using HALCON on Arm-based platforms. At the end of
the chapter you can find a list of other manuals that help you to work with HALCON.
1.1 Requirements
The system requirements can be found in the Installation Guide, section 1.4 on page 8.
For graphical applications, X11 support is required.
The licensing on Arm-based platforms is either based on a product license dongle or a Card IDentification (CID)
number of a SD card or other memory cards. In order to access a dongle, the hidraw device must exist, i.e., it
must be enabled in the kernel configuration. If necessary, a custom kernel needs to be compiled using the kernel
option CONFIG_HIDRAW=y. Naturally, a USB port is required to connect the dongle. In case of a card identification
number, hardware support for the memory device is required. You can query the CID numbers provided by your
system by calling the HALCON tool hhostid -i from your shell.
1.2 Limitations
The following limitations apply compared to other platforms:
• no XL version
• no MAC-based licensing, no standard evaluation licenses
• no HDevelop
• no hcomp, thus extension packages have to be cross-compiled on the development PC
An up-to-date list of supported image acquisition interfaces can be found on our website http://www.mvtec.
com/products/interfaces.
HALCON development tools like HDevelop are not available for Arm-based platforms, so you actually need two
installations of HALCON:
On the development PC:
• a development version of HALCON
On the Arm-based platform:
• a runtime installation of HALCON
In case you have a native toolchain for your Arm-based platform it is of course possible to use it directly with
HALCON. But even in this case you need to own a HALCON development license, and the HALCON development
tools are not available on your Arm-based platform.
Example programs specific to the Arm-based platform can be found in examples/arm-linux. Please note that
other example programs can only be compiled if the corresponding makefiles or CMakeLists.txt are adjusted.
In the following we will always assume you are using a cross compiler toolchain from an Intel Linux platform as
this is the most common way at the time of writing.
Chapter 2
Getting Started
Getting Started
This chapter guides you through your first steps with HALCON for Arm-based platforms, mentioning the particu-
larities concerning the steps
• installing the necessary components (section 2.1),
• licensing (section 2.2)
Please note that throughout this manual we assume that you already know how to access the Arm-based platform
from your development PC (see the corresponding documentation from the platform’s vendor for details).
On the development PC, a HALCON development installation is required. The installation procedure is described
in the Installation Guide, section 2.2.1 on page 15.
To test whether the installation and licensing was successful, we recommend to start HDevelop. The hdevelop
menu item Help . About shows which HALCON version has been started, thus, you can check whether you
successfully installed HALCON 24.11.1.0.
The following directories on the development PC will contain content specific for HALCON on Arm-based plat-
forms:
The installation for Arm-based platforms is also provided by the MVTec Software Manager. Again, see the Instal-
lation Guide, section 2.2.1.2 on page 16 for more information on the installation procedure. Note that you have the
options to obtain the packages online or offline, run the installation via Web GUI (default) or CLI, or generate your
own, customized offline installer for the purpose of archiving or unrolling the HALCON installation on multiple
platforms. Please refere also to the documentation provided with the MVTec Software Manager to get detailed
information about these options.
In order to use HALCON on the Arm-based platform, the following environment variables must be set in order for
HALCON to work:
2.2 Licensing
Standard License
If you installed HALCON for Arm-based platforms yourself and obtained the license file separately from your
distributor, you must rename it to license.dat (or similar, see the Installation Guide, section 1.6 on page 14 for
the naming conventions) and place it in the subdirectory license of the directory where you installed HALCON
on the Arm-based platform ($HALCONROOT).
Chapter 3
Creating Applications
Applications
This chapter explains how to create applications for Arm-based platforms using HALCON.
There are the following ways of developing:
• developing in HDevelop, exporting the script or procedures to C, C++ or C#, and including the code in your
application (see section 3.2 on page 14)
• using HDevEngine (see section 3.7 on page 15)
• using HALCON/.NET (see section 3.5 on page 15)
• programming in Python (see section 3.6 on page 15)
• programming in C or C++ (see section 3.4 on page 14, section 3.3 on page 14)
Note that you develop the application on the development PC, not on the Arm-based platform, using the gcc
compiler to create the executable.
3.1.1 Cross-Compile
In this section we describe the steps necessary to compile an example on a development PC in order to run on
Arm-based platforms (’cross-compilation’). We will do this with the aid of the datacode example, for which also
the exported C and C++ code is included in the example directory.
We assume HALCON is installed on your development PC (and the aarch64-linux or armv7a-linux libraries have
been installed during the installation).
First the steps needed on your development PC. They are done the easiest under a Debian or Ubuntu distribution
and in the following we will assume you are using such a system.
1. Make sure you have the cross-compilation toolchain installed. If this is not the case, you can install it via
the package streams:
For aarch64-linux:
sudo apt-get install gcc-aarch64-linux-gnu
sudo apt-get install g++-aarch64-linux-gnu
12 Creating Applications
For armv7a-linux:
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install g++-arm-linux-gnueabihf
4. Specify the HALCON target architecture (your Arm-based platform). For this, you have two options:
(a) Re-set HALCONARCH to the one of your Arm-based platform by typing
export HALCONARCH=aarch64-linux
or
export HALCONARCH=armv7a-linux
7. Specify a toolchain to CMake. For the HALCON architectures armv7a-linux and aarch64-linux, you can
find example toolchain files in $HALCONEXAMPLES/cmake/toolchains/
8. Compile the application by typing:
For aarch64-linux:
cmake .. \
-DHALCON_ARCHITECTURE=aarch64-linux \
-DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/cross-aarch64-linux-gnu.cmake
cmake --build .
For armv7a-linux:
cmake .. \
-DHALCON_ARCHITECTURE=armv7a-linux \
-DCMAKE_TOOLCHAIN_FILE=../../examples/cmake/toolchains/cross-arm-linux-gnueabihf.cmake
cmake --build .
9. Copy the compiled files onto your Arm-based platform (the files are in ./bin/aarch64-linux or
./bin/armv7a-linux/).
10. The datacode example uses images. Therefore, the image sequence file $HALCON-
ROOT/examples/images/datacode/ecc200/ecc200_cpu.seq and all images referenced by it
must be in a location readable on the Arm-based platform. The easiest way is to copy the directory
$HALCONROOT/examples/images/datacode/ecc200 to your Arm-based platform.
In this subsection we describe how you can compile the exported C and C++ code using the compiler of your
Arm-based platform. We will do this with the aid of the datacode example.
For this, you will need to install HALCON differently on your Arm-based platform:
1. Install HALCON using the MVTec Software Manager on your Arm-based platform. Select at least the
components Runtime files and Runtime files (general).
Be aware, such an installation does not contain header files, CMake scripts, and example source code. They
have to be copied from a full HALCON installation.
2. Install further required components. On your Linux PC, create an archive of the required directories:
cd $HALCONROOT
tar -cf dev-files.tar include/examples/cmake examples/arm-linux
Applications
Copy this archive to your Arm-based platform and extract the archive in your HALCON installation:
cd $HALCONROOT
tar -xf dev-files.tar
Now the Arm-based platform is set up and we can compile the code. Therefore, execute the following steps on
your Arm-based platform:
export HALCONEXAMPLES=$HALCONROOT/examples
3. Create a new build directory for your compiled example and move into it.
mkdir build
cd build
Note that for native compilation it is not necessary to provide CMake arguments for the HALCON architec-
ture and the toolchain.
To ensure that make does not attempt to run HDevelop, the date of the C file datacode.c and the C++ file
datacode_cpp.cpp must be newer than the corresponding HDevelop file datacode.hdev.
• and link the HALCON libraries for the aarch64-linux or armv7a-linux architecture
-L$(HALCONROOT)/lib/$(HALCONARCH) -lhalconcpp -lhalcon
• and link the HALCON libraries for the aarch64-linux or armv7a-linux architecture
-L$(HALCONROOT)/lib/$(HALCONARCH) -lhalconc -lhalcon
3.5 Creating C# Applications 15
How to create a simple HALCON application with .NET Core is demonstrated in Programmer’s Guide, section 9.1
on page 62.
Applications
3.6 Creating Python Applications
Detailed information about HALCON’s Python interface can be found in the Programmer’s Guide. To try out the
Python interface, make sure that the CPython implementation of the Python programming language is installed
on the system. To summarize the necessary extensions to the normal application development on your Arm-based
platform, you
• add HALCON/Python to your project:
pip install mvtec-halcon==24111
How to create a simple HALCON application with HALCON/Python is demonstrated in Programmer’s Guide,
chapter 14 on page 95.
• and link the HALCON libraries and the HDevEngine library for the aarch64-linux or armv7a-linux
architecture
-L$(HALCONROOT)/lib/$(HALCONARCH) -lhdevenginecpp -lhalconcpp -lhalcon
For more information, see the Programmer’s Guide, chapter 24 on page 179.