Thermal Camera SDK 10.1.0
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
Start Developing

Contents

Which Language to Choose?

The SDK itself is implemented in C++ but offers bindings to other language like C# and Python 3. One of the first decisions you have to make is to choose the programming language with which you want to interact with the SDK. The bindings offer full access to the exposed C++ API. However, there are some minor omissions due to technical restrictions of the target languages. Their impact on the available feature set is negligible.

Visit OTC SDK

The following table lists some use cases as well as some downsides for each language and is by no means exhaustive:

Language Use Case Downsides
C++ Lowest latency and maximum performance Complexity
C# GUI application development Minor performance penalties due to bindings
Python 3 Prototyping and data science Not suitable for high performance demands (slow function calls, global interpreter lock)

The bindings are automatically generated with the help of SWIG and always consist out of the to following parts:

  • A shared library realizing a C-style function based API that is used by the target language wrapper code to access the functionality of the SDK.
  • Wrapper code in the target language that mirrors the C++ API.
Note
All the symbol names of the C++ API carry over to the other languages. Thus, you can easily use the API documentation in the Code section although it was generated from the C++ API.

Toolchains

C++

With C++ you first of all require a compatible compiler to translate your project into an executable or a library. With regards of your operating system the SDK supports the following compilers:

  • Windows: Microsoft Visual C++ Compiler (MSVC)
  • Linux: GNU Compiler Collection with C++ frontend (gcc)
Note
The chosen compiler should support the ISO C++ 17 standard.

In addition to the compiler you need to choose which build system you want to use. The SDK supports the following options out of the box:

  • Windows: CMake and Visual Studio projects
  • Linux: CMake

On Linux the native package manager apt will automatically install the GNU compiler and CMake as dependencies of the SDK package.

On Windows you can easily use either the built-in capabilities of Visual Studio or you can use CMake. Regardless of your choice you need to install the Microsoft Visual C++ compiler. Navigate to the Visual Studio website and download the installer. The following descriptions are based on the freely available Community Edition 2022:

  • Start the installer
  • Choose at least the Workload Desktop development with C++
  • Go to the tab Individual components and scroll down to the section Compiler, Buildtools and Runtimes and select the following additional components:
    • MSVC v143 Buildtools
    • Windows 11 SDK
    • C++-CMake-Tools for Windows (optional)
    • Core Functions of Test Tools - Buildtools
    • C++ AddressSanitizer
    • vcpkg-Package-Manager
    • C++ ATL Support for Buildtools v143
    • C++ Modules for v143 Buildtools
  • Deselect the Visual Studio core editor, if you wish to use another IDE/code editor.

If you want to use CMake as the build system, you have to visit to the CMake website to download their Windows installer. Run it to install CMake on your system.

C Sharp

The C# bindings of the SDK are generated based on the __.NET SDK LTS version 8.0__. Therefore, you need to install this SDK along with its corresponding runtime. On Linux you can conveniently to do this with the help of the native package manager apt. Just run the following command:

sudo apt install dotnet-sdk-8.0 dotnet8

On Windows you can refer to the Visual Studio installer to get both the .NET SDK and runtime. Navigate to the Visual Studio website and download the installer. The following descriptions are based on the freely available Community Edition 2022:

  • Start the installer
  • Choose the Workload .NET desktop development
  • Deselect the Visual Studio core editor, if you wish to use another IDE/code editor.

Python 3

In order to use the Python 3 bindings of the SDK you require the Python 3 interpreter and the NumPy library.

Linux

On Linux the bindings are compiled against the default Python 3 and NumPy versions provided by the official APT repositories. Therefore, the recommended way to install the required dependencies is the native package manager apt. Run the following command:

sudo apt install python3 python3-numpy
Note
If you use different Python 3 or NumPy versions than the system defaults, then you can run into compatibility issues. They can, for example, manifest through failed imports of the native bindings library _otcsdk_python.

Windows

On Windows the native part of the Python 3 bindings requires at least the following versions of Python 3 and NumPy:

  • Python >= 3.9
  • NumPy >= 2.0.0
Note
If you fail to adhere to these version requirements the import of the binding module will fail with an error message similar to:
ImportError: DLL load failed while importing _otcsdk_python.

Since Windows lacks a central software manager you first have to download the Python 3 installer from its website. After the installation you can use the built-in package manager pip to install NumPy:

pip.exe install numpy

To manipulate and and view false color images you may need an additional library like OpenCV. You can install it with the help of the package managers:

Linux

sudo apt install python3-opencv

Windows

pip.exe install opencv-python

Project Integration

C++

Depending on your chosen build system, CMake or Visual Studio, you have to take a different approach.

CMake

Open your CMakeLists.txt file and add the following find_package() command to instruct CMake to locate the SDK resources:

find_package(otcsdk REQUIRED)

Then add the library target otcsdk::otcsdk to the target_link_library() command for your build target (here named myTarget):

target_link_libraries(
myTarget
PRIVATE
otcsdk::otcsdk
)

In this way you build your target against the shared version of the SDK library. If you wish to link statically, use the library target otcsdk::static instead.

To compile your CMake project go to the root directory of your project, create a build directory and change into it:

mkdir build
cd build

Command CMake to generate the build files and trigger the compilation process:

cmake ..
cmake --build . --config Release
Note
You can use the --parallel option with the second command to speed up the compilation process. Make sure, however, that you have enough memory to support all the resulting compilation processes.

Visual Studio Project

The Windows SDK installer automatically sets up the system wide environment variable OTC_SDK_DIR that holds the path to your chosen installation directory. You can now use this variable to conveniently setup your Visual Studio C++ project.

After you created a C++ project in Visual Studio open the project properties and modify the following settings:

  • General page
    • Set the C++ Language Standard to ISO C++17 Standard (/std:c++17).
  • VC++ Directories page
    • Add the path $(OTC_SDK_DIR)\include to the Include Directories.
    • Add the path $(OTC_SDK_DIR)\lib to the Library Directories.
  • Input page of the Linker category
    • Add otcsdk.lib to the Additional Dependencies.

With this setup you build your project against the dynamic version of the SDK library. If you wish to link statically against the SDK, you will have to adjust the following settings:

  • Input page of the Linker category
    • Set the Additional Dependency to otcsdk_static.lib instead of otcsdk.lib.
  • Preprocessor page of the C/C++ category
    • Add OTC_SDK_STATIC to the Preprocessor Definitions.
Note
The define OTC_SDK_STATIC ensures that the macro OTC_SDK_API controlling the Windows DLL symbol export and import in the SDK headers is empty. For more details on this subject refer to the MSVC documentation.

C Sharp

Create a subfolder classes in your C# project and copy the wrapper C# classes from the SDK install directory to it. They are located in

  • <SDK Installation Directory>\bindings\csharp\classes on Windows and in
  • /usr/share/otcsdk/csharp/classes on Linux

The .NET runtime locates and loads the depended shared libraries automatically.

Python 3

To use the SDK with Python 3 you just need to import the SDK module into your code:

import optris.otcsdk as otc

Nothing more needs to be done.