OptrisOptrisDocumentation

Documentation/OTC SDK/Overviewv12.0

Calibration File Acquisition

In Fahrenheit: with the SDK switched to Fahrenheit (SetTemperatureUnit() and its counterparts, see Temperatures in Fahrenheit), every temperature on this page is read and written in Fahrenheit, and every difference in Fahrenheit degrees; the samples are unchanged.

Overview

Every Optris thermal camera requires a set of calibration files to convert raw sensor data into accurate temperature readings. These files are specific to each camera's serial number, optics, and temperature ranges.

Calibration files are acquired while a camera is being opened, not on demand. The SDK checks which files the camera needs, and fetches whatever is missing from the camera itself, from a directory you name, or from Optris, in that order.

Note: There is deliberately no "download the calibration for serial N" call. Which files a camera needs is derived from the video formats that camera reports, so the question has no answer without the camera being present. Everything a caller controls is therefore set on ImagerConfig, per camera, before Imager::Create().

Where the Files Live

Acquired files are cached so that later connections, and other applications on the same machine, reuse them:

  • Linux: ~/.config/optris/Cali/
  • Windows: APPDATA%\Imager\Cali\

Ask for it rather than hard-coding it:

#include <optrissdk.h>

std::string dir = optris::sdk::GetCalibrationDir();

This is the directory to pre-seed on a machine that will never have a network: put the files there and no camera will need to download anything.

Naming a Directory

If you keep calibration files somewhere else (deployed alongside your application, on a USB stick, or on a network share), name that directory and it is searched before the SDK reaches for the network:

optris::sdk::ImagerConfig config;
config.serial = "12345";
config.calibration_path = "/opt/my-app/calibrations";

auto imager = optris::sdk::Imager::Create(config);

Files found there are copied into the cache directory above for subsequent use.

A calibration_path that does not exist is rejected by name, before any camera is touched, so a mistyped path does not need hardware attached to diagnose:

calibration_path "/opt/my-app/calibratons" is not a directory that exists
on this machine.

Refusing the Network

On a machine that is offline, behind a firewall, or simply not permitted to make outbound connections, switch the download off:

config.allow_calibration_download = false;

The attempt is then never made, rather than made and given up on, so a machine with no route out fails in a moment instead of waiting out a connection that was never going to succeed. Only the camera itself and calibration_path are used.

When It Fails

A camera whose calibration files cannot be found still opens. Imager::Create() returns, the camera streams, and its temperatures are not measurements. Check for this after opening rather than relying on an exception:

auto imager = optris::sdk::Imager::Create(config);
if (!optris::sdk::IsCalibrated(imager->GetCalibrationStatus())) {
  std::println("{}", imager->GetCalibrationDiagnosis());
}

GetCalibrationStatus() reports CalibrationStatus::kMissing in that state, and GetCalibrationDiagnosis() names which of the things you control fell short; the two cases need different fixes, and "calibration failed" on its own tells an operator nothing:

This camera is streaming without calibration: the calibration files for
camera 12345 are not in "/opt/cal", they could not be obtained from the
camera, and downloading them is switched off
(allow_calibration_download = false).
Put the files in that directory, or allow the download. Its temperatures
are not measurements.

A caller who set neither of those still gets the sources named. That is the ordinary case on a machine nobody prepared for this.

Use IsCalibrated() rather than comparing against kMissing: a camera that is not open reports kUnknown, which is not calibrated either.

CalibrationException is thrown only when the open itself fails and calibration files were also found missing along the way; the exception then carries the same sentence, because the missing files are the more actionable half of the report. A failure to open with the calibration in order is a DeviceException.

The status distinguishes only one thing beyond found-or-not: kAcquired means the files were missing and were fetched during this open: from the camera, from calibration_path, or from Optris. The camera is fully calibrated either way, and IsCalibrated() is true for both; the distinction exists because "it worked, but it needed the network" is the answer to a different question, and it is the one a deployment engineer is asking before a machine goes offline. See Whether the Camera Is Calibrated for the four values in one table.

The status is about whether the files were found and loaded, not about whether they hold the right numbers for this particular unit. A camera with a calibration that is present but wrong reports kCalibrated, and nothing here will tell you otherwise.

Sources

The SDK probes calibration sources in this order during connection. The order reflects what each source costs: the camera's own memory needs neither network nor filesystem, your directory needs no network, and Optris is last.

Device

Supported by Xi 80, Xi 320 MT, and Xi 410.

These devices store calibration data in on-device memory. The SDK copies it to the local cache automatically. This source is skipped for devices that do not support it.

The camera hands the data over inside its video frames: asked for an address, the firmware stops sending pictures and sends the contents of that address instead, with the address in the frame's own telemetry. Those frames are taken out before any processing, so nothing is measured off them. It takes a few hundred milliseconds and no network, once the camera's stream is running.

The transfer waits for the stream's first frame before it starts counting. Over Ethernet a camera's stream can take a few seconds to start after the open asks for it. The SDK waits for that first frame for up to the camera's connection timeout (ImagerConfig::connection_timeout, ten seconds unless the camera's saved configuration or your open says otherwise), and logs at info level that it is waiting and for how long. Once frames arrive, a second without the next block ends the transfer, as before. A camera that never sends a frame ends the transfer after that wait, and the log names how long it waited. An open whose calibration files are already on the machine never reaches this step.

When it does not succeed, the log says which of three things happened rather than reporting a timeout: no block ever arrived, so the camera never entered the transfer; the transfer started and stopped part-way, naming the address it reached; or the video format the camera is running in carries no frame telemetry, in which case the address cannot be read at all and the attempt is refused immediately. GetCalibrationDiagnosis() does not claim the camera is not carrying its calibration; it says the files could not be obtained from the camera, which is the only one of the two that is knowable from the host.

Filesystem

The directory named in ImagerConfig::calibration_path. Skipped when none is named.

Internet

If calibration files are not found locally or on the device, the SDK downloads them over HTTPS. The transport is HTTPS only, because the digest below travels in-band and over plaintext HTTP anything able to change the body can change the header with it. Downloads are written atomically, so an interrupted one never leaves a partial file in the cache.

A download is verified when the server says what to verify it against, and stored unverified when it does not. The SDK checks the body's SHA-256 against a Digest: sha-256=... response header and discards a file that does not match, moving on to the next server. Two cases get no check: a 200 carrying no Digest header, which is what a captive portal or an intercepting proxy produces, and a Digest header naming some other algorithm, which this SDK does not compute. The first is logged as a warning naming the server and the file; the second is not logged at all. A site that must know every file was verified should serve the files from its own mirror (see Mirrors) rather than read the absence of a warning as a verification.

Skipped entirely when allow_calibration_download is false.

Note: Some calibrations are tied to specific video formats. The SDK only downloads calibrations for video formats supported by the current connection interface (USB or Ethernet).

Mirrors

The Internet source always starts with the built-in servers: https://calibration.optris.com/api, then the mirror https://calibration.optris-ir.cn/api for regions from which the primary is not reachable. At the start of an acquisition all servers are health-checked in parallel and the highest-priority reachable one is used; individual files fail over to the next server if a server is down or does not have them.

A site that keeps its own mirror can append it:

optris::sdk::AddCalibrationFallbackServer("https://mirror.example.com/api");

Registered servers are tried after the built-in ones, in registration order, and are removed again with optris::sdk::ClearCalibrationFallbackServers(). The built-in servers always remain active. To read the two lists back: GetCalibrationFallbackServers() returns what has been registered, in registration order, and GetBuiltinCalibrationServers() returns the ones the SDK ships with, highest priority first.

The URL must use https:// and include the full API base path; the SDK appends /healthz and /v1/calibration/... to it. A registered server must mirror the REST layout of the built-in ones, including the Digest header. https:// is required rather than merely preferred: the digest that proves a file arrived intact travels in the response header, and over plaintext it is worth nothing.

ConfigException is thrown for a URL that is empty, does not start with https://, contains whitespace, or carries a query or a fragment, and when the registration limit of eight is reached. A URL that is already built in, or already registered, is ignored with a warning rather than rejected, so registering the same mirror twice is harmless.

Note: Registering a mirror does not override allow_calibration_download. A camera opened with the download refused reaches no server at all, registered or built in.

Behavior Without Calibration

If no calibration files can be found or downloaded, the SDK still connects to the device. However:

  • Thermal frames contain invalid temperature data because the SDK cannot convert raw ADU values without calibration: every pixel reads -100.0 °C.
  • Every thermal frame is marked as not a measurement (thermal_data_reliable false) for as long as the calibration is missing, so a program that checks the flag before using a temperature skips them. SDK 12.0.22 and earlier marked them as measurements once the startup calibration had finished.
  • Raw frames (SetRawCallback) contain valid ADU data.
  • Measurement fields are not processed.
  • Operation modes are derived solely from supported video formats, with invalid values for field of view (0) and temperature range limits (-100).

Imager::GetCalibrationStatus() reports kMissing in that state and Imager::GetCalibrationDiagnosis() names the sources that were tried, whether or not the caller set any of the options on this page. See When It Fails.

How Long a Machine With No Internet Waits

The times below are what the download takes to give up, with one calibration file missing; the open continues afterwards and the camera streams uncalibrated.

The machine Time to give up
Online, files genuinely absent from the service ~1.1 s
No network configured at all (name resolution fails at once) ~7 ms
Firewalled: packets to the service are silently dropped ~25.0 s
allow_calibration_download = false no network contact at all

The firewalled figure is the one that matters, and it is a ceiling rather than a typical value: a 5 s health probe covering all servers in parallel, then a single 10 s attempt per server instead of the full retry budget. It does not grow with the number of missing files: the acquisition stops at the first file it cannot obtain, and a server that failed is struck off for the rest of it. Each application-registered mirror that is also unreachable adds about 10 s.

A site that cannot accept a 25 s delay per camera should set allow_calibration_download = false and name a calibration_path, which reaches no network at all.

Complete Example

A factory PC with no route to the internet, calibration files on a share, and a local mirror as a backstop:

#include <optrissdk.h>
#include <chrono>
#include <print>
#include <thread>

using namespace optris::sdk;

int main() {
  std::println("calibration cache: {}", GetCalibrationDir());

  ImagerConfig config;
  config.serial = "12345";
  config.calibration_path = "/mnt/share/calibrations";
  config.allow_calibration_download = false;

  try {
    auto imager = Imager::Create(config);

    // Missing files do not stop the open. Ask.
    if (!IsCalibrated(imager->GetCalibrationStatus())) {
      std::println("{}", imager->GetCalibrationDiagnosis());
      return 1;
    }

    imager->SetThermalCallback([](const ThermalFrame& f) {
      // Frames from before the startup calibration has finished
      // arrive too, and are not measurements.
      if (!f.GetMetadata().thermal_data_reliable) return;
      std::println("{}x{} max={:.1f} C", f.GetWidth(), f.GetHeight(),
                   f.GetMaxTemperature());
    });

    imager->Start();
    std::this_thread::sleep_for(std::chrono::seconds(10));
    imager->Stop();
  } catch (const ConfigException& e) {
    // A path that does not exist -- reported before any camera is touched.
    std::println("configuration problem: {}", e.what());
    return 1;
  } catch (const CalibrationException& e) {
    // The open failed, and calibration files were missing too.
    std::println("{}", e.what());
    return 1;
  }

  return 0;
}