OptrisOptrisDocumentation

Documentation/OTC SDK/Overviewv12.0

Using the API

The v12 C++ API: what the types are, how to construct one, and what each area is called. For an exact declaration, use API Reference.

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.

On this page

Two APIs

The SDK ships two public C++ APIs out of one shared library (libotcsdk.so / otcsdk-34.dll).

API Namespace Style Include
v12 optris::sdk Concrete classes, std::function callbacks, typed exceptions optrissdk.h for everything, or the individual headers under optris/sdk/
Legacy optris Abstract interfaces, observer pattern otcsdk/IRImager.h

One include covers the whole v12 C++ API, the rec:: recording layer and the view:: layer included:

#include <optrissdk.h>

Existing code against the legacy optris::IRImager keeps working, unchanged. New projects use optris::sdk. Everything below is the v12 API. Migration Guide: v11 to v12 maps the old entry points onto the new ones method by method, and Public Headers lists every installed header.

What differs from the legacy API:

Legacy v12
Factories and singletons Imager::Create() static factory returning std::unique_ptr<Imager>; enumeration and hotplug monitoring are free functions
IRImagerClient observer base class Registered callbacks. Subclassing still works, see Subclassing
Push only Push or pull: AcquireFrame() gets the next frame synchronously
Error codes Typed exceptions under optris::sdk::SdkException. The process interface returns failure instead of throwing
One flat list of setters Settings grouped by area behind accessors
Measurement fields and alarm channels One model: regions, with rules attached to them
Recording, playback, snapshots, simulation and visualisation as separate components All in the library

The public headers compile at C++17: the SDK's CMake targets export cxx_std_17 on their interface, while the library itself is built with C++23.

Architecture

Type Is Derives from
optris::sdk::Imager a camera FrameSource
optris::sdk::Player a recording being played back FrameSource
optris::sdk::StillSource a reopened snapshot FrameSource

FrameSource carries what all three share: starting and stopping, thermal and BGRA frames (pushed or pulled), palettes and colour scaling, regions and alarm rules. Code written against FrameSource works on any of them.

Everything camera-specific is on Imager, in sub-interfaces reached through accessors:

Accessor Covers
Regions() measuring areas and their readings
Alarms() the rules over those areas
Radiometry() emissivity, transmissivity, ambient temperature, reference correction
Detector() shutter-correction schedule, chip heating
Display() colour windows, overlays, GPU surface rendering
Canvas() where the frame sits in view space
Processing() which outputs are produced, filters, picture corrections, which backend ran
Optics() focus
Device() network settings, fail-safe, the camera's user-assigned name
GetPif() the process interface
Recorder() recordings and snapshots
Buffers() memory the SDK writes each frame into
Motion() temperature-band motion zones

The accessors on a camera repeats this list with each accessor's type and header. The handle an accessor returns refers to the imager and is valid only for as long as the imager is.

Design rules: no singletons for cameras; frames by callback or by pull; RAII, so destroying an Imager disconnects and there is no separate disconnect call; and frames, configuration records and regions are value types that copy and store.

The picture

v12_overview.dot "The v12 public API: frame sources, the sub-interfaces under Imager, the recording and view layers, and the bindings over the flat C ABI"

Every box is a type in include/optris/sdk/. Solid arrows are inheritance, dashed arrows are "reached through this accessor", dotted arrows are "built on". StillSource, the third FrameSource, is not on it.

Construction

Factory Opens
Imager::Create() the first camera found. Throws DeviceException if there is none
Imager::Create(ImagerConfig) with specific settings (serial, transport, range, calibration directory, ...)
Imager::Create(DeviceInfo) a camera returned by enumeration
Imager::Create(DeviceInfo, ImagerConfig) an enumerated camera, every other setting from the config. The DeviceInfo wins over the config's serial, transport and network address
Imager::Create(SimulatedConfig) a simulated camera, no hardware needed

All return std::unique_ptr<Imager>. A recording is not opened through Imager; see Playback.

DeviceInfo, ImagerConfig and SimulatedConfig have overloads taking an OpenProgressCallback, called one phase at a time. Not on the calling thread: a real camera publishes its phases on the SDK's event thread, the same notification queue the connection callbacks use, and only a simulated camera reports them on the thread performing the open. Synchronise any handler that touches shared state. The callback is finished with by the time Create() returns, and an open cannot be cancelled once begun. open_progress.h has the whole contract.

Every factory can raise DeviceBusyException, not only DeviceException. A camera is claimed exclusively across the machine, so an open can meet a claim another program holds, or one this application holds and has not handed back. Both are a busy refusal rather than a missing camera. reason() says which, and one of its values means nothing holds the camera at all; see Error handling. Reconnect() raises it for the same reasons.

#include "optris/sdk.h"
#include <print>

int main() {
  // First camera found.
  auto imager = optris::sdk::Imager::Create();

  const auto &info = imager->GetDeviceInfo();
  std::println("Connected: {} S/N {} ({}x{} @ {} Hz)",
               info.model, info.serial,
               imager->GetWidth(), imager->GetHeight(),
               info.frame_rate);

  // Simulated: no hardware needed. Width and height of 0 take the
  // device type's own resolution (a PI 160 by default).
  optris::sdk::SimulatedConfig sim;
  sim.framerate = 30;
  sim.pattern = optris::sdk::TestPattern::kGradient;
  auto test = optris::sdk::Imager::Create(sim);
}

GetWidth() and GetHeight() are the frame dimensions as oriented: after a 90 or 270 degree SetOrientation() they are the sensor's, swapped. GetSensorWidth() and GetSensorHeight() are unaffected by orientation.

A camera calibrates before it streams, so the first frame can take seconds. SkipStartupCalibration() ends that calibration. It does not have to be called before Start(); called while the calibration is running it ends it there, which is how a "skip" button works. It costs more than it buys: the first frame marked as a measurement arrives later, not sooner. imager.h has the measured figures.

Subclassing instead of callbacks

Imager is polymorphic and its default constructor is protected, so it can be subclassed into the observer shape the legacy IRImagerClient had. The protected constructor leaves the imager unattached: a subclass must call the protected Connect() with an ImagerConfig or a SimulatedConfig before Start(), which otherwise throws.

This whole section is C++ only, and not because nobody has written the others. The C ABI hands out an opaque optris_sdk_imager * and has no protected constructor to reach, so there is nothing for a binding to derive from: ThermalCamera, Camera and Rust's Camera are all final/sealed/concrete by construction. In those four, the shape below is composition: hold a camera, and register the callbacks in your own type's constructor. That is what examples/csharp/patterns/, examples/python/ and the Rust examples all do.

class ImagerClient : public optris::sdk::Imager {
 public:
  explicit ImagerClient(const optris::sdk::ImagerConfig& config) {
    Connect(config);
  }

  void Start() override {
    Imager::SetThermalCallback(
        [this](const optris::sdk::ThermalFrame& f) { OnFrame(f); });
    Imager::SetBgraCallback(
        [this](const optris::sdk::BgraFrame& f) { OnBgraFrame(f); });
    Imager::SetConnectionCallback(
        [this](bool c) { OnConnection(c); });
    Imager::SetVideoFormatCallback(
        [this](uint32_t w, uint32_t h, float fps) {
      OnVideoFormatChanged(w, h, fps);
    });
    Imager::Start();
  }

 protected:
  virtual void OnFrame(const optris::sdk::ThermalFrame&) {}
  virtual void OnBgraFrame(const optris::sdk::BgraFrame&) {}
  virtual void OnConnection(bool) {}
  virtual void OnVideoFormatChanged(uint32_t, uint32_t, float) {}
};

Override what you need:

class MyCamera : public ImagerClient {
 public:
  using ImagerClient::ImagerClient;

 protected:
  void OnFrame(const optris::sdk::ThermalFrame& frame) override {
    float center = frame.GetTemperature(
        frame.GetWidth() / 2, frame.GetHeight() / 2);
    std::cout << "Center: " << center << " C, "
              << "Max: " << frame.GetMaxTemperature() << " C\r"
              << std::flush;
  }

  void OnConnection(bool connected) override {
    std::cout << (connected ? "Connected" : "Disconnected")
              << "\n";
  }
};

The subclass is usable anywhere the base type is expected:

std::unique_ptr<optris::sdk::Imager> imager =
    std::make_unique<MyCamera>(optris::sdk::ImagerConfig{});
imager->Start();

std::cout << "Press Enter to quit...\n";
std::cin.get();

imager->Stop();

examples/cpp/patterns/subclass.cc is the compiled version.

Frames

Push delivery

Register std::function callbacks. Each setter replaces the previous callback; passing an empty function removes it. Callbacks run on the SDK's own threads: keep them short and hand anything slow to a thread of your own, because a blocked callback holds up the stream behind it. No callback may destroy the Imager; do that from your own thread.

Register before Start() if you want the first frame of the run. A registration carries the frames delivered after it, so the order of the two calls decides whether the first one is yours. A simulated camera and a replay both deliver a frame inside Start(), so registering afterwards loses it; a live camera is slower to produce its first frame and usually hides the difference. The same holds for the alarm, action and device-change streams.

using var stopping = new CancellationTokenSource(TimeSpan.FromSeconds(5));

// Subscribe first. FramesAsync registers the callback when you call
// it, and the stream carries what arrives after that -- so calling it
// before Start() is how the first frame of the run is yours.
IAsyncEnumerable<ThermalFrame> frames = camera.FramesAsync(stopping.Token);

camera.Start();

try
{
    await foreach (ThermalFrame frame in frames)
    {
        using (frame)
        {
            Process(frame);
        }
    }
}
catch (OperationCanceledException)
{
}
Callback setter Frame type Contents
SetThermalCallback ThermalFrame Calibrated temperatures. Stored as int16 internally; GetTemperature(x, y) returns Celsius
SetBgraCallback BgraFrame BGRA8 false-colour picture
SetRgbCallback RgbFrame The visual-camera image, on models that have one. Not a false-colour frame
SetRawCallback RawFrame uint16 sensor values before radiometry, in sensor coordinates (never rotated or mirrored)
SetEnergyCallback EnergyFrame int32 radiometric energy before the temperature lookup, in sensor coordinates

Registering a raw or energy callback turns that output on; clearing it turns it off. Nothing else has to be configured.

Event setter Fires when
SetConnectionStatusCallback The connection status changes (Connecting, Connected, Stalled, Lost, ...). Prefer this to SetConnectionCallback, which reduces it to a bool and cannot tell a stalled stream from a healthy one
SetConnectionCallback Connected or disconnected, as a bool
SetVideoFormatCallback Stream geometry or frame rate changed: a mode switch, or a quarter-turn of orientation
SetShutterCallback The internal shutter changed position. The only way to get the transitions with timestamps, and the only way to tell a shutter on its way from one that has arrived, since a camera reports Closing and Opening too. For a per-frame answer read ThermalFrame::flag_open
SetPifValueCallback A process-interface reading arrives, with its name and unit
SetErrorCallback A non-fatal problem worth surfacing. Fatal ones throw instead
SetReconnectCallback An automatic reconnection attempt succeeds or fails
Alarms().SetCallback An alarm rule changes state

Note: Three of the four bindings do not take a callback for frames, and that is deliberate. .NET hands them back as an IAsyncEnumerable; Python's handler runs on an SDK thread holding the GIL, so the pull loop below is usually the better trade; Rust's closure must be Send and is retained until the camera is dropped. The events (connection status, shutter, errors, alarms) are callbacks everywhere.

#include "optris/sdk.h"
#include <iostream>
#include <print>

int main() {
  auto imager = optris::sdk::Imager::Create();

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

  imager->SetBgraCallback(
      [](const optris::sdk::BgraFrame &f) {
    // f.GetData() is BGRA8, ready for display.
  });

  imager->SetErrorCallback(
      [](const std::string &msg) {
    std::println(stderr, "SDK error: {}", msg);
  });

  imager->Start();
  std::cin.get();
  imager->Stop();  // Callbacks have returned by the time this does.
}

Raw and energy frames

SetRawCallback() delivers the detector's own uncalibrated uint16 samples. SetEnergyCallback() delivers the pipeline's linear int32 energy, the stage after the corrections and before the temperature lookup. One call of each per thermal frame.

Both are in sensor coordinates and are never rotated or mirrored by SetOrientation(), because the calibration maps and dead-pixel indices they would be compared against are in sensor coordinates too. RawFrame::GetBitDepth() reports the width of the samples (16), not how many of those bits the detector fills. Nothing on the frame path carries the sensor's own depth.

Warning: On a simulated camera these are computed, not measured. A simulation has no detector, so the simulated imager publishes the image its drawn scene would have had, through a fixed linear model: adu = 2048 + internal and energy = 16 * internal, where internal is the thermal frame's own (celsius * 10) + 1000. The result is exact, repeatable and matches the temperature frame pixel for pixel, which is enough to write and test a consumer against. It is not radiometry and must not be used as a calibration reference.

Note: A recording carries neither. Playback stores the corrected thermal frame, so the detector samples and the energy behind them are not in the file; both callbacks report unsupported rather than delivering a substitute.

Pull delivery

#include "optris/sdk.h"
#include <chrono>
#include <print>

int main() {
  auto imager = optris::sdk::Imager::Create();
  imager->Start();

  using namespace std::chrono_literals;

  for (int i = 0; i < 100; ++i) {
    // Throws CaptureException on timeout.
    auto frame = imager->AcquireFrame(1000ms);
    // Frames from before the startup calibration has finished arrive
    // too, and are not measurements.
    if (frame.GetMetadata().thermal_data_reliable)
      std::println("Frame {}  max={:.1f} C",
                   frame.GetMetadata().sequence,
                   frame.GetMaxTemperature());
  }

  // Non-blocking variant.
  if (auto opt = imager->TryAcquireFrame()) {
    std::println("Got frame: {}x{}", opt->GetWidth(), opt->GetHeight());
  }

  imager->Stop();
}

"No frame yet" on a running camera is routine, so the non-blocking form answers false rather than raising: a poll loop should not have to be a try block. Anything genuinely wrong still raises.

if (auto waiting = imager->TryAcquireFrame()) {
  Draw(*waiting);
}

The acquisition queue is four frames deep. When a consumer falls behind, FrameQueuePolicy::kDropOldest (the default) evicts the oldest frame so a pull always gets one of the most recent; kDropNewest keeps a contiguous run and discards arrivals instead. Set it with SetFrameQueuePolicy(). GetDroppedFrameCount() counts the frames this queue discarded, and nothing else.

A shutter cycle is not a gap in the stream. Frames keep arriving while the shutter is in the way: the SDK holds the last frame taken with it open and delivers that. Those frames carry is_repeated_frame, and flag_open is false on them. A watchdog, or anything else inferring a cycle from frames stopping, reads flag_open, is_repeated_frame or SetShutterCallback() instead.

Reading temperatures out of a frame

ThermalFrame stores temperatures as int16_t in the SDK's internal format, internal = (celsius * 10) + 1000. That is where the 0.1 °C step in every reported temperature comes from. GetTemperature(x, y) converts one pixel.

For a whole frame as temperatures, ask the SDK rather than converting the samples yourself: it answers NaN for a pixel it could not measure, which the bare formula turns into a plausible-looking -3376.8 °C.

std::vector<float> celsius(frame.GetPixelCount());
frame.CopyTemperaturesTo(celsius);

The scalar helpers are for a single sample you already hold. InternalToCelsius() applies the formula to whatever it is given, including the unmeasured sentinel:

Note: These are static inline in the C header, so they export no symbol and no ctypes binding can call them: not this one, and not any other. Python therefore transcribes them, and the package pins each against the SDK's own answer rather than against a remembered formula (PythonBindingTest.InternalToCelsiusAgreesWithTheSdk). One of those transcriptions was measurably wrong once: C, .NET and Rust compute in float32 and Python's arithmetic is float64, which cost a whole 0.1 K quantum on 885 of 2,000,000 temperatures. See What Python cannot reach.

float c = optris::sdk::InternalToCelsius(raw_value);
int16_t raw = optris::sdk::CelsiusToInternal(37.5f);

Working in raw units is often better than converting. To count pixels above a threshold, convert the threshold once rather than the frame once per pixel:

int16_t threshold = optris::sdk::CelsiusToInternal(60.0f);
int hot = 0;
const int16_t *raw = frame.GetData();
for (uint32_t i = 0; i < frame.GetPixelCount(); ++i) {
  if (raw[i] >= threshold) { ++hot; }
}

CelsiusToInternal() refuses rather than wraps:

Input Result
NaN, or at or below absolute zero kInvalidPixel
Hotter than 3176.7 °C saturates at 32767
Anything else the internal format, truncated
// InternalToCelsius answers NaN for an unmeasured pixel, so the round
// trip has to give the sentinel back rather than an ordinary reading.
int16_t back = optris::sdk::CelsiusToInternal(
    optris::sdk::InternalToCelsius(optris::sdk::kInvalidPixel));

bool fits = optris::sdk::IsEncodableTemperature(3200.0f);

IsEncodableTemperature() says which of the three you got, and IsMeasurablePixel() is the usual guard on the result: in C optris_sdk_pixel_is_measured(), in C# ThermalFrame.IsMeasured(), in Python optris_sdk.pixel_is_measured(), which also takes a NumPy array, and in Rust pixel_is_measured(). The round trip is exact for a pixel that was never measured. GetTemperature() answers NaN for such a pixel by design; turning that NaN into 0 would make it an ordinary -100.0 °C reading.

The two clocks on a shutter event

A shutter transition carries two times and they are not interchangeable. Both are read at the transition, one immediately after the other, and neither is computed from the other.

Is Use it to
the monotonic stamp a stopwatch reading on the same clock a frame's timestamp uses measure: subtract two of them for the length of a cycle
the host time the machine's wall clock at the moment the shutter moved display and log

Measure with the monotonic one, because a time server can step the wall clock in either direction and a user can set it, so two host times can jump or run backwards. That is exactly the wrong failure at the worst moment, which is why timing a cycle with the wall clock is wrong even though it usually looks right.

camera.OnShutterState(change =>
    log.WriteLine($"{change.HostTime:O},{change.Previous},{change.Current}"));

A transition also reports the state before it as well as the state now, so a handler can tell a shutter on its way from one that has arrived: a camera reports Closing and Opening and not only Open and Closed, where its firmware distinguishes them. Register before Start() to also see the startup calibration's own transition.

Processing output control

Which outputs the pipeline produces is part of the processing record. Read it, change what you need, and write it back. Set() writes the whole record:

The setter writes all five flags, so this is a read-modify-write in every language: what you did not mean to change has to come from the getter.

auto processing = imager->Processing().Get();
processing.outputs.bgra_frames = false;  // Measuring only: skip colorization.
imager->Processing().Set(processing);

outputs.thermal_frames = false suppresses the entire frame dispatch: no callbacks, no external buffers, no recording, and no region, alarm or motion evaluation. To save work, turn off bgra_frames instead.

Frame statistics

Method Returns
GetFrameCount() Frames delivered
GetDroppedFrameCount() Frames the acquisition queue discarded because a pull consumer did not keep up
ResetStatistics() Zeroes both counters; safe while streaming

There is no processing-latency getter in the C++ API, because the SDK does not measure processing latency; v11's getProcessingLatency() returned a hardcoded zero on every camera. The C ABI keeps optris_sdk_imager_get_processing_latency_us() declared so existing code still links, but it always fails with OPTRIS_SDK_ERROR_NOT_SUPPORTED and writes nothing, and the .NET ThermalCamera.ProcessingLatency property always throws FeatureNotSupportedException. Measure latency in your application instead. Do not subtract GetMetadata().timestamp_us from your own clock to get one: that timestamp comes from the streaming transport, it is not a date, and which clock it is on differs between transports. Only the differences between frames are meaningful on every platform.

Processing backends

Two pipelines turn sensor data into temperatures, held to bit-exact agreement: the CPU pipeline, always available, and the GPU pipeline, compute shaders on the graphics card. Both are always built.

There is no API to pick one. The SDK chooses per camera while it opens, applying these rules in order, the first that fires deciding:

  1. A camera with a sample-point calibration always runs on the CPU pipeline, because only the CPU pipeline implements it.
  2. OTC_FORCE_CPU in the environment forces the CPU pipeline.
  3. A measured table of camera and mode combinations names a pipeline for the modes it covers.
  4. Otherwise the size rule: frames smaller than 65536 pixels (or OTC_GPU_MIN_PIXELS) go to the CPU, where a GPU dispatch costs more than the work; larger ones go to the GPU.
  5. If the GPU was chosen but no usable GPU exists (no adapter, only a software adapter, or a device that could not be created), the camera runs on the CPU pipeline.

A GPU that passes the availability probe can still fail when the camera's GPU pipeline initialises. The probe only proves an adapter and a device can be created; the pipeline's buffers, shaders and compute pipelines for this camera's frame size are built later, at connect, on an operation-mode switch, or on a frame-format change. The camera is then moved to the CPU pipeline rather than left without a picture, and the SDK logs an error naming the camera serial, where it happened and why.

C++ reports "no camera attached" as valid == false; the other four have no such flag, because the call itself fails: a status in C, an exception in .NET and Python, an Err in Rust.

const auto info = imager->Processing().Info();
if (info.valid) {
  std::println("{} pipeline: {}", optris::sdk::ToString(info.kind),
               info.explanation);
  if (info.reason == optris::sdk::PipelineReason::kGpuInitFailed) {
    // The one reason that is a fault: this machine was expected to
    // compute on its GPU and is not.
  }
}

Info() reports valid == false only when no camera is attached. A simulated camera answers with the CPU pipeline it really runs; playback answers valid == true with PipelineKind::kNone. optris::sdk::GetGpuInfo() reports which GPU adapter the SDK would use, without a camera.

Visualisation

The Imager colorises the thermal frame itself; there is no separate image builder.

17 built-in palettes, kIronBow by default; Colour Palettes names them all and GetAllPalettes() enumerates them for a UI. A 240-colour table of your own goes in with SetCustomPalette(), see Custom Palettes.

By default each frame is scaled to its own range, using the 1st and 99th percentile of the scene (AutoScaleMode::kPercentile; kAbsolute uses the coldest and hottest pixel).

imager->SetPalette(optris::sdk::Palette::kIronBow);

imager->SetColorRange(20.0f, 80.0f);  // Manual: 20-80 C.
imager->SetColorRange({}, {});        // Back to automatic.

imager->SetBgraCallback(
    [](const optris::sdk::BgraFrame &f) {
  // f.GetData() is BGRA8 pixel data,
  // f.GetWidth() * f.GetHeight() * 4 bytes.
});

GetEffectiveColorRange() reports the range actually in use. SetColorScaleDynamics() damps how quickly an automatic scale follows the scene. Colour Palettes and Colour Range are the full chapters.

void *instance = imager->Display().GetGpuInstance();  // a WGPUInstance
if (imager->Display().ConfigureSurface(surface, width, height)) {
  // Every frame now goes straight to the surface, colorized and
  // with the region overlays, at display resolution.
}

The same picture can land in a buffer of yours instead, every frame:

optris::sdk::ExternalBuffer ext;
ext.data = buffer;
ext.size = size_bytes;
ext.format = optris::sdk::ExternalPixelFormat::kThermalFloat32;
ext.on_written = [](const optris::sdk::ExternalBuffer &buf) {
  RunModel(buf.data, buf.width, buf.height);
};
imager->Buffers().Add(ext);

Measuring

Regions and alarms

A region is a measuring area: geometry, statistics and the alarms that watch it, in one model. Regions and Alarms are the full chapters.

Region coordinates are relative to the frame and divide both axes by its width, so y runs 0 … height/width: 0.75 on a 4:3 camera.

using namespace optris::sdk;

auto zone = Region::Rect(/*centre=*/{0.5f, 0.375f}, /*size=*/{0.4f, 0.3f});
zone.name = "Zone A";
zone.emissivity = 0.95f;

// A child that tracks the hottest point inside the parent, averaging
// a 3x3 window clipped to that parent.
Aperture aperture;
aperture.shape = ApertureShape::kSquare;
aperture.radius_px = 1.0f;
auto hot = Region::Spot({0.0f, 0.0f}, aperture);
hot.kind = RegionKind::kHotSpot;
hot.name = "Zone A hot";
zone.children.push_back(std::move(hot));

const auto id = imager->Regions().Add(std::move(zone));  // 0 if invalid

// After frames arrive:
if (const auto region = imager->Regions().Get(id);
    region && region->stats.valid) {
  std::println("min={:.1f}  max={:.1f}  mean={:.1f}",
               region->stats.min_c, region->stats.max_c,
               region->stats.mean_c);
}

Check stats.valid before reading a temperature. When it is false the statistics are quiet NaN rather than zero, deliberately, so a reading that was never taken cannot be plotted, averaged or compared against a limit by accident.

Other shapes: Region::Circle, Ellipse, Line, Polygon, Spline, ClosedSpline, Spot, Ring, and FromDrag for mouse-drawn areas.

Two regions compose with the members United(), Intersected() and Subtracted(). a.Subtracted(b) is "a, with b's area removed", so a ring is an outer circle with an inner one subtracted. They are members because the result takes its name, style, rules and children from the operand it is called on. The free Union(), Intersect() and Subtract() in region.h take a Composite, the bare geometry tree, not a Region: use those to build geometry rather than to combine two measuring areas.

A Line region measures the one pixel it passes through at each step along its length, including the pixels its two ends stop part-way inside. Before this was fixed a line collected every pixel within half a pixel of it: on sensors 320 pixels wide or more that made it two to three rows thick, and at some positions it measured nothing or counted a row twice. Line readings recorded before the fix on such cameras measured a band, not a line, and will differ.

Editing is in place and keeps the region's id, so alarms on it stay bound:

imager->Regions().Edit(id, [](Region &r) { r.SetCentre({0.6f, 0.4f}); });

For a live display, read all of them at once:

for (const auto &state : imager->Regions().States()) {
  if (state.stats.valid) Draw(state.region_id, state.stats.max_c, state.alarm);
}

An alarm is a rule watching a signal. The signal can be a region statistic, camera telemetry, a PIF channel, a motion zone, or a value your application publishes; the machinery is the same for all of them.

Rule hot;
hot.name = "over temp";
// The slot is filled in from the region id by the two-argument Add().
hot.input = SignalId::Region(0, SignalField::kMax);
hot.condition.compare = Compare::kAbove;
hot.condition.alarm = {.high = 60.0f, .hysteresis = 2.0f};
hot.condition.warning = Limits{.high = 55.0f};
hot.condition.on_delay = std::chrono::milliseconds(100);
hot.actions.push_back({ActionTrigger::kOnActivate, SnapshotAction{}});

const auto rule_id = imager->Alarms().Add(id, std::move(hot));

imager->Alarms().SetCallback([](const AlarmEvent &e) {
  std::println("[{}] {} -> {} at {:.1f} C",
               e.region_name, ToString(e.previous), ToString(e.current),
               e.value);
});

Note: MeasurementField, RoiAlarm and Imager::AddAlarmChannel() are removed from optris::sdk. Version 11 applications are unaffected. See Measurement Fields for the mapping.

Recording

There is no Recorder() sub-object in the four bindings: the C ABI puts the recording calls on the imager handle itself, so they hang off the camera. The pre-roll length is a Duration in Rust and .NET, seconds as a float in Python, and whole milliseconds in C, which is the ABI's own unit and where the other three narrow to.

auto &recorder = imager->Recorder();

// Pre-roll: keep the last 30 seconds in a ring buffer.
recorder.EnablePreRoll(std::chrono::seconds(30));

// Start recording. If pre-roll is on, the buffer is flushed first.
recorder.Start("/data/capture.mkv");

// ... later:
recorder.Stop();
// When Stop() returns the file is complete and can be opened.

bool recording = recorder.IsRecording();

Start(path, duration) records for a fixed time and stops by itself. SaveSnapshot(path, format) writes the latest frame as a still image; SnapshotFormat is a plain enum with one of kPng, kTiff, kCsv and kJpeg, not a set of flags to be combined. StartIntervalCapture() writes one at a fixed interval.

A recording is laid out so an ordinary media player opens it: track one is a colorized placard carrying a notice and a QR code, one picture repeated so a player keeps showing it; track two is the measurement (FFV1 GRAY16LE, AV_DISPOSITION_DEFAULT); behind them sit the per-frame telemetry text track, the otc-meta.json attachment and a cover.jpg. What a third party may rely on states which of those properties a third-party reader may rely on and which are incidental. The short rule: find the measurement by its role tag, never as "stream 0" or "the only video stream".

Playback

Player is a FrameSource but not an Imager: it has frames, palettes, regions and alarms, and no shutter, focus or network. Regions and rules on a player behave exactly as on a live camera.

There is no separate Player type in the four bindings. The C ABI opens a recording as an optris_sdk_imager (optris_sdk_imager_create_from_file), so a replay is the same handle a camera is, and the playback calls are on it. That is what lets one loop be written against live and recorded data alike; is_playback / IsPlayback is how the two are told apart, and what only hardware can do is refused by name rather than faked.

auto player = optris::sdk::Player::Open("/data/capture.mkv");  // IoException on failure

player->SetLoop(true);
player->SetSpeed(2.0f);

player->SetThermalCallback(
    [](const optris::sdk::ThermalFrame &f) {
  // A recording keeps the mark on the frames from before the camera's
  // startup calibration had finished. They are not measurements.
  if (!f.GetMetadata().thermal_data_reliable) return;
  std::println("Playback: max={:.1f} C", f.GetMaxTemperature());
});

player->Start();

// Seek.
player->SeekToFrame(0);
player->SeekToTimestamp(5'000'000);  // Microseconds.

std::println("{} / {} us", player->GetPositionUs(), player->GetDurationUs());

Pause(), Resume() and IsPaused() hold the position without stopping.

Player::Display() gives a recording the same colour windows a camera has, with two exceptions it reports rather than hides: ColorWindow::motion_only is refused, because a replay runs no motion differencing, and a picture recording (one written as colorized video) supports none of them at all. Ask Display().AreColorWindowsSupported(); it answers rather than failing, and the answer must not be cached across an upgrade. IsPicture() is answered from the stream header at Open(), so it is valid before playback starts.

GetRecordedRender() says what the colours meant when the file was written, and Player opens a recording on that palette and auto-scale mode when the file records them. GetAttachments() and ReadAttachments(path) get back files the recording carries; the static Player::ReadAttachments(path) reads them without opening the recording as a source.

Ask whether the file states a thing before believing what it reports. GetRadiation() and GetConfig() hand back plain structs, so a recording that never named an emissivity reads back as 1.0 and one that never named a range reads back as −20..100 °C: in both cases a plausible value that nobody recorded. HasRadiation() and HasTemperatureRange() separate "the file says so" from "that is the struct's default", and both are false for a v11 file and for a file from another writer. Test HasTemperatureRange() before drawing a scale bar against the range.

Opening a snapshot

A still written by this SDK carries temperatures and the settings they were computed at, so it can be measured after the fact:

using namespace optris::sdk;

auto still = StillSource::Open("capture.png");  // IoException on failure
const uint64_t id =
    still->Regions().Add(Region::Rect({0.4F, 0.4F}, {0.2F, 0.2F}));
still->Refresh();
std::println("{:.1f} C", still->Regions().Get(id)->stats.max_c);

StillSource is a FrameSource, so regions, alarms, palettes and colour scaling behave as they do on a camera. It has one frame, delivered repeatedly while it is running, so FrameSource code needs no special case; Refresh() delivers it once, synchronously, which is what a program that is not streaming should use. The format is detected from the file's content, not its extension. GetPath() and GetMetadata() return the file and the whole metadata document it carries.

A raw-ADU or energy still holds uncalibrated counts with no radiometric model beside them, so Open() rejects it by name. Use rec::Snapshot::LoadRaw() for the counts.

ApplyConfig() changes the global emissivity, the same knob as on a camera: the energy-to-temperature table is rebuilt from the calibration the file carries, by the camera's own TempTable, and every pixel is re-derived through it. Verified entry for entry against a live backend on a real PI 640i. Asking for the value the file was saved at restores the saved pixels exactly. A still with no radiometry.otc attachment refuses it by name, and the temperature range is refused always: a different range is a different calibration the file does not carry.

The global knob and a region's own emissivity are different arithmetic and can differ by several kelvin at low emissivity (0.40 K at 0.90, 6.9 K at 0.50 on a +40.7 K correction). That is the camera's behaviour, reproduced.

A region's own emissivity is applied when the file carries the camera's characteristic curve, which the SDK writes into every still it saves from a camera that has one. StillSource::HonoursRegionEmissivity() answers for the file in hand.

The file The region reads at Badged
carries the curve what the camera would have reported, resolved through the same object a live camera uses RegionEmissivityState::kReadingOnly: the numbers carry it, the picture does not, because a still has no pipeline behind it
does not the camera's emissivity, with a warning naming it kCameras

The camera's emissivity, the one every pixel in the file was computed at, is in GetRadiation() either way.

Camera control

Process interface

GetPif() returns the camera's pif::PifController. Every physical camera returns a controller, whether or not anything was detected on the connector; detection is advisory, and SetIdentity() declares a PIF that detection missed. nullptr means there is no hardware at all: a simulated camera or a recording.

A refused PIF request throws pif::PifException, like every other failure in the C++ API, and its code() says which refusal it was: an index the hardware does not have, a PIF that is not attached, a value that is not a finite number. A polling loop still does not have to catch. Reading an input before the first frame has brought one is a reading rather than a refusal (DigitalState::Unknown for a digital input, NaN for an analog one), so a loop over a working interface never throws:

The other languages report a PIF refusal the way they report everything else: a status in C, an exception in C# and Python, and an Err in Rust. A simulated camera and a recording have no PIF at all and say so: nullptr in C++, OPTRIS_SDK_ERROR_NOT_SUPPORTED in C, and an exception or Err elsewhere.

auto pif = imager->GetPif();
if (!pif) {
  std::println("No camera behind this imager.");
  return;
}

const auto &info = pif->GetHardwareInfo();
std::println("PIF: {} DI, {} DO, {} AI, {} AO",
             info.digital_input_count, info.digital_output_count,
             info.analog_input_count, info.analog_output_count);

// Set a digital output. A refused request throws.
try {
  pif->WriteDigitalOutput(0, optris::sdk::pif::DigitalState::High);
} catch (const optris::sdk::pif::PifException &e) {
  std::println(stderr, "DO0: {}", e.what());
}

// Read an analog input: NaN until the first frame has brought one.
std::println("AI0 = {}", pif->ReadAnalogInput(0));

A channel carries no meaning until Configure() gives it a purpose. Poll() reads, decodes and dispatches inputs to the handler set with OnDecodedInput(). To react to a PIF value, use an alarm rule on SignalId::Pif(...). examples/cpp/process_interface/pif_info.cc is the compiled version. Process Interface (PIF) is the full chapter.

Error handling

All SDK exceptions derive from SdkException. Error Handling has the whole hierarchy, which calls throw what, and the calls that validate with std::invalid_argument instead, so catch (const SdkException&) alone does not cover everything.

Two of them an open meets first:

Exception Carries
ConnectTimeoutException a DeviceException: the camera did not answer within the connection timeout
DeviceBusyException a DeviceException: the operation was refused and may succeed next time. Raised by an open refused on a claim, by an open whose stream would not start in its video format, and by an operation-mode switch whose format change fails. reason() says which, as a closed enum, and one of its values means nothing holds the camera, so it must not be shown as in use. detail() carries the holder and the claim file, and is empty when they cannot be named

Non-fatal errors are raised on the SDK's threads, where a caller's try/catch cannot reach them. Register an error callback for those:

Note: The four bindings do not share C++'s exception hierarchy, and two do not have one at all. C returns a status from every entry point and has optris_sdk_last_error_message() for the text, per thread, so read it into a local before calling anything else. Rust has one error type carrying a Status, so there is no order of catch clauses to get right: match on the status. .NET and Python do have hierarchies, with their own names: ThermalDeviceException and DeviceError where C++ says DeviceException.

#include "optris/sdk.h"
#include <chrono>
#include <print>

int main() {
  try {
    optris::sdk::ImagerConfig config;
    config.serial = "12345678";

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

    imager->SetErrorCallback(
        [](const std::string &msg) {
      std::println(stderr, "Non-fatal: {}", msg);
    });

    imager->Start();
    auto frame = imager->AcquireFrame(std::chrono::milliseconds{5000});
    // Frames from before the startup calibration has finished arrive
    // too, and are not measurements.
    while (!frame.GetMetadata().thermal_data_reliable)
      frame = imager->AcquireFrame(std::chrono::milliseconds{5000});
    std::println("Max: {:.1f} C", frame.GetMaxTemperature());

    imager->Stop();

  } catch (const optris::sdk::DeviceException &e) {
    std::println(stderr, "Device error: {}", e.what());
    if (!e.serial().empty())
      std::println(stderr, "  Serial: {}", e.serial());
    return 1;
  } catch (const optris::sdk::CalibrationException &e) {
    std::println(stderr, "Calibration: {}", e.what());
    return 1;
  } catch (const optris::sdk::CaptureException &e) {
    std::println(stderr, "Capture: {}", e.what());
    return 1;
  } catch (const optris::sdk::SdkException &e) {
    std::println(stderr, "SDK error: {}", e.what());
    return 1;
  }
}

Device enumeration

Warning: Enumerating is not a read. On Linux the sweep opens every attached camera to read its descriptors, so it is a group of fragments here rather than samples: the machine that gates this manual has cameras on it, and a sample is run.

#include "optris/sdk.h"
#include <print>

int main() {
  // Cameras on the local buses. Network cameras are not included
  // unless asked for.
  auto devices = optris::sdk::EnumerateDevices();

  // With options: include network and simulated.
  optris::sdk::EnumerationOptions opts;
  opts.include_network = true;
  opts.include_simulated = true;
  auto all = optris::sdk::EnumerateDevices(opts);

  for (const auto &dev : all) {
    std::println("{}  S/N {}  {} ({}x{} @ {} Hz)",
                 dev.model, dev.serial,
                 optris::sdk::ConnectionTypeToString(dev.connection),
                 dev.width, dev.height, dev.frame_rate);
  }

  // Create an imager from an enumerated device.
  if (!all.empty()) {
    auto imager = optris::sdk::Imager::Create(all[0]);
  }
}

Network discovery is a broadcast and does not cross a router. ProbeNetworkDevice() asks one address directly without opening the camera.

In C#, write Optris.Sdk.EnumerationOptions in full, or add using EnumerationOptions = Optris.Sdk.EnumerationOptions; at the top of the file. A project made from the default .NET templates has implicit usings switched on, which imports System.IO and with it System.IO.EnumerationOptions, so new EnumerationOptions { ... } after using Optris.Sdk; does not compile (error CS0104, an ambiguous reference). Code inside a namespace of its own under Optris.Sdk is not affected.

EnumerateDevices() blocks, and with include_network set it blocks for network_discovery_timeout, 3 seconds by default. To keep a sweep off a user-interface thread, run it on a thread of your own. There is no callback-based form and no need for one: the result is a std::vector<DeviceInfo> returned by value, so a std::jthread that enumerates and posts the vector is the whole solution. Device enumeration has it written out.

For arrivals and departures rather than one sweep:

optris::sdk::StartHotplugMonitor(
    [](const optris::sdk::DeviceInfo &dev, bool added) {
  std::println("{} {}  S/N {}", added ? "+" : "-", dev.model, dev.serial);
});

StartHotplugMonitor() is USB only and stays that way: it takes no options, so it has nowhere to put the poll interval that watching a network needs. StartDeviceMonitor() takes options, owns its thread, and adds two things to the same arrivals and removals:

  • watch_claims: kClaimed and kReleased, for every claim including this process's own. Read DeviceInfo::claimed_by_this_process to tell them apart.
  • watch_network: cameras on the network, which the monitor does not report at all without it. A camera appears up to one network_poll_interval after it is powered and leaves two intervals after it stops answering, and the broadcast reaches the local network segment only. Use ProbeNetworkDevice() for a camera behind a router. See Device enumeration.

Camera settings

The range is two whole degrees across the ABI, so the four bindings carry a pair rather than C++'s record; extended and high_precision are their own calls there.

auto range = imager->GetTemperatureRange();  // min_c, max_c, extended, high_precision
for (const auto &[lo, hi] : imager->GetDeviceInfo().available_ranges) {
  std::println("{}..{} C", lo, hi);
}
// A range change is a mode change and reloads the calibration.
// Throws ConfigException for a range this camera does not offer.
imager->SetTemperatureRange({.min_c = 150, .max_c = 900});

TemperatureRange::extended (off by default) and high_precision (on by default, as in v11) both rebuild the energy-to-temperature table. Both are camera-wide requests; what the active mode can act on is OperationMode::extendable, high_precision_available and the extended_temp_min/extended_temp_max pair. High precision does not change the 0.1 °C step size the SDK reports, see Operation Modes.

const auto &modes = imager->GetDeviceInfo().operation_modes;
for (const auto &m : modes) {
  // The unit comes from the mode, not from an assumption: the same
  // number is degrees on one optic and millimetres on another.
  const char *unit =
      m.optics_unit == optris::sdk::OpticsUnit::kMillimetres ? "mm" : "deg";
  std::println("{} {}  {}..{} C  {}x{} @ {} Hz",
               m.optics_fov, unit, m.temp_min, m.temp_max,
               m.width, m.height, m.framerate);
}
imager->SetOperationMode(modes[0]);
auto active = imager->GetOperationMode();

The radiation parameters are a whole-record setter too, so read, change and write back:

auto radiation = imager->Radiometry().Get();
radiation.emissivity = 0.95f;
radiation.transmissivity = 1.0f;
radiation.ambient_temp_c = 22.0f;  // Also the reflected temperature.
imager->Radiometry().Set(radiation);

There is one ambient value, used also as the reflected temperature. There are no separate reflected-temperature, distance or humidity settings. With estimate_ambient = true the camera estimates ambient from its housing probe and GetEffectiveAmbientTemperature() reports the value in use, while Get() keeps reporting the configured number in either mode. A value written while the camera is estimating is kept, and comes back into force when estimation is turned off. Radiometry().Sources() says whether emissivity and ambient come from the SDK or from a PIF input.

Radiometry().TemperatureAtEmissivity() re-evaluates a reading you already have at another emissivity without disturbing the camera. Ask GetEmissivityConversionSupport() first: a nullopt from it is a refusal, not a conversion that made no difference. Thermal Measurement Basics covers what these three parameters mean and what gets them wrong.

// Read first: this is a whole-record setter, so a default-constructed
// record writes defaults over every setting you did not think about,
// the shutter forecast included.
auto nuc = imager->Detector().GetAuto();
nuc.enabled = true;
nuc.min_interval_secs = 30.0f;
nuc.max_interval_secs = 300.0f;
// How far any internal probe may drift before a correction is due,
// checked once min_interval_secs has elapsed. Default 0.1.
nuc.temp_drift_threshold_c = 0.5f;
imager->Detector().SetAuto(nuc);

// Manual trigger. This is the correction: on this hardware a
// non-uniformity correction is a shutter cycle and there is no other.
imager->Detector().TriggerShutter();

The 30 and 300 above are this example's choice, not the defaults: a camera runs a 12-second minimum with no ceiling. Until something calls SetAuto(), a freshly opened camera runs on the engine's own schedule. GetTelemetry() reports nuc_status and flag_open. Read optris::sdk::AutoNucConfig in full before changing any of it: drift_filter_secs and drift_band_steps carry the measured account of why a settled camera still corrects every twelve seconds, what to set instead, and the one case where setting it makes things worse.

Detector().SetChipHeating() stabilises the detector at a fixed temperature. Heating is a property of the optic, not the camera: on an optic that must not be heated (the G7, for instance) kAuto and kFixed throw FeatureNotSupportedException and kFloating is the only mode, while the same camera on another optic heats.

Distortion and size-of-source correction are both on by default, matching v11:

These are three separate settings in the ABI rather than one record, so the four bindings set them one at a time.

auto p = imager->Processing().Get();
p.rdc = optris::sdk::RdcMode::kNormal;  // kOff, kNormal (default), kWide
p.sos_correction = true;                // default
p.sos_strength = 0.3f;                  // default 0: see below
imager->Processing().Set(p);

// What is actually happening, as opposed to what was asked for.
const auto c = imager->Processing().Correction();
std::println("RDC: {}  SoS: {}", optris::sdk::Explain(c.rdc),
             optris::sdk::Explain(c.sos));

sos_correction alone changes nothing: sos_strength defaults to 0, which is an exact identity, because the shipped correction table carries the shape of the halo and no magnitude. The strength has to be measured for a camera and its optics. Correction() reports SosStatus::kZeroStrength in that state, and kNoTable / RdcStatus::kNoCoefficients where the calibration carries nothing to apply. Neither is an error. Frame Processing Settings covers both corrections and the noise filters.

A motorized lens is focused as a share of its travel: 0.0 is the near end and 1.0 the far end, on every lens, and the SDK maps it onto the motor's own steps. That is the form to offer a person. The steps (GetFocusPosition(), SetFocusPosition(), GetFocusRange()) differ from model to model and are for saving and restoring one exact setting.

auto &optics = imager->Optics();
if (optris::sdk::IsFocusable(optics.GetCapability())) {
  optics.SetFocus(0.5F);                 // the middle of the travel
  float share = optics.GetFocus();       // 0.0 near .. 1.0 far
}

GetDeviceInfo() is the cached identity record; GetTelemetry() is a live reading built per call.

There is no GetTelemetry() in the C ABI, and so none in the four bindings: the housing and detector readings are fields of a frame, which is where they come from. They carry the same chip_temp_known flag for the same reason, and reading them off a frame makes the one thing that matters explicit: a telemetry reading belongs to a moment, not to a camera.

const auto &info = imager->GetDeviceInfo();
std::println("Serial: {}", info.serial);
std::println("Model:  {}", info.model);

const auto t = imager->GetTelemetry();
std::println("Box temp: {:.1f} C", t.box_temp_c);
// The detector is the one probe that can be absent rather than cold.
// `chip_temp_c` is 0.0 and `chip_temp_known` false on a camera whose
// detector count does not decode, and 0 C is a temperature a detector
// can genuinely be at.
if (t.chip_temp_known) {
  std::println("Chip temp: {:.1f} C", t.chip_temp_c);
} else {
  std::println("Chip temp: no reading from this camera");
}

A camera whose calibration files could not be found still opens and streams, and its temperatures are wrong. GetCalibrationStatus() is how to tell, and GetCalibrationDiagnosis() says which source fell short. Calibration File Acquisition is the chapter.

Register memory you own and the SDK writes each frame straight into it. This removes the copy on the caller's side; internally the frame is still built and then written out.

This is the one place Rust has an unsafe, and it is unsafe for the reason the pointer makes obvious: the SDK writes into memory you own, from its own thread, and it must stay valid and unmoved until the buffer is removed or the camera is dropped. The C ABI's rule is the same and nothing enforces it there.

std::vector<float> buf(imager->GetWidth() * imager->GetHeight());

optris::sdk::ExternalBuffer ext;
ext.data = buf.data();
ext.size = buf.size() * sizeof(float);
ext.format = optris::sdk::ExternalPixelFormat::kThermalFloat32;

ext.on_written = [&](const optris::sdk::ExternalBuffer &) {
  // buf[] now contains float Celsius values.
};

// Throws ConfigException if the buffer is too small for the frame.
imager->Buffers().Add(ext);

The formats are kThermalInt16, kThermalFloat32, kBgra, kRgb and kEnergyInt32. On unified-memory platforms (NVIDIA Jetson) a cudaMallocManaged pointer works directly.

Configuration persistence

An optris_sdk_config is opaque and the ABI has no setters on one, so the four bindings cannot modify a copied record the way C++ does: a record carries the values it was copied with, and the way to change a setting is the setting's own call. The export and the import are the same in all five.

// Read current config.
auto cfg = imager->GetConfig();
std::println("Emissivity: {}", cfg.radiation.emissivity);

// Modify and apply.
cfg.radiation.emissivity = 0.92f;
imager->ApplyConfig(cfg);

// Export to a JSON file. Writes this file and nothing else.
imager->SaveConfig("/data/my_camera.json");

// Import. Replaces regions, rules, motion zones, colour windows and
// canvas placement with the file's.
const auto report = imager->LoadConfig("/data/my_camera.json");
std::println("{}", report.diagnosis);

SaveConfig() writes atomically: an interrupted export leaves the previous file intact. LoadConfig() checks what it can before touching the camera, so a file that cannot work here is refused with nothing changed; pass ConfigLoadOptions{.require_matching_serial = true} to refuse a file from a different camera. SaveDeviceConfigArchive() is the separate write of the SDK's own per-camera archive on this machine, which is reloaded the next time that camera is opened. It is not written to the camera.

GetConfig() and ApplyConfig() are the same pair with no file involved. The reporting overload of ApplyConfig() goes through the same staged applier as LoadConfig() (everything refusable is refused before the first setting moves) and returns the same ConfigLoadReport.

This is the shape to save and restore settings in, and doing it setting by setting cannot be complete: a setting added in a later SDK version is silently absent from the caller's own save and restore, and nothing says so. A record grows with the SDK. Reachable from C, C#, Python and Rust as well.

camera.SaveConfiguration("line-3.json");

// ... later, or in another process ...
ConfigurationLoadReport report = camera.LoadConfiguration("line-3.json");
Console.WriteLine(report.Diagnosis);

The no-file pair is how a program tries something and puts it back:

auto saved = imager->GetConfig();

auto radiation = imager->Radiometry().Get();
radiation.emissivity = 0.5f;
imager->Radiometry().Set(radiation);
// ... try something ...

const auto report = imager->ApplyConfig(saved, {});

And a record taken from one camera can be applied to another, with the serial check waived on purpose:

auto saved = source->GetConfig();
std::println("Restoring the settings taken from {}", saved.serial);

optris::sdk::ConfigLoadOptions options;
options.require_matching_serial = false;
target->ApplyConfig(saved, options);

Other languages

The same SDK is reachable from other languages through a flat C ABI, optris/sdk_c.h, built into the same library.

Language Package Get it from What it is
C optris/sdk_c.h the platform package Hand-written C99 ABI over the v12 API
.NET Optris.Sdk (ThermalCamera) nuget.org: dotnet add package Optris.Sdk Hand-written package over the C ABI, targeting .NET 10; carries the native SDK
Python optris_sdk PyPI: pip install optris-sdk Hand-written pure-Python package over the C ABI (ctypes), NumPy optional; the wheel carries the native SDK
Rust optris-sdk over optris-sdk-sys crates.io: both crates in [dependencies] Safe crate over raw FFI declarations for the C ABI; needs the platform package installed

Getting each one has the copy-paste line for each.

The older SWIG-generated C# and Python bindings (otcsdk) wrap the legacy API, not this one.

The C ABI's API version is OPTRIS_SDK_C_ABI_VERSION, currently 34. There is one API version for every language, see Versions.

Structs that may grow begin with a struct_size field, and every one a caller declares has an _init that stamps the size and applies the documented defaults. Call it before changing any field: a struct built by hand gets zeros where the SDK's defaults belong, and a zeroed struct_size is refused.

The rule is "does a call ever write into your buffer", not "who produces the value". Several structs the SDK fills in itself have an _init, because the same struct is also read into storage the caller declared:

Call _init first Before
optris_sdk_alarm_event_init() optris_sdk_imager_read_alarm_log()
optris_sdk_shutter_correction_event_init() optris_sdk_imager_get_last_shutter_correction()
optris_sdk_nuc_cycle_report_init() optris_sdk_imager_get_last_nuc_cycle()
optris_sdk_action_error_init() the callback that delivers one
optris_sdk_action_completed_init() the callback that delivers one
optris_sdk_action_drop_counts_init() optris_sdk_imager_get_action_drop_counts()
Has no _init Why
optris_sdk_image, optris_sdk_motion_event, optris_sdk_attachment_request received borrowed, never declared
the nested capability blocks the enclosing _init stamps their sizes
optris_sdk_rgb24, optris_sdk_vec2, optris_sdk_color_window_entry fixed layout; no struct_size either

Examples are under examples/cpp/, examples/c/, examples/csharp/, examples/python/ and examples/rust/, arranged by API area. examples/legacy/, examples/python3/ and examples/csharp/legacy/ hold examples for the older optris::IRImager interface, kept for existing code.