optris::sdk::Imager
Main interface for Optris thermal cameras. Polymorphic class with pimpl. Default implementations delegate to the internal implementation. Subclass and override to customize behavior.
auto imager = optris::sdk::Imager::Create(); imager->SetThermalCallback([](const optris::sdk::ThermalFrame &f) { std::println("Max: {:.1f} C", f.GetMaxTemperature()); }); imager->Start();
Inherits from optris::sdk::FrameSource.
Public types
RgbCallback
std::function< void(const RgbFrame &)> RgbCallback
The visual-camera image, on models that have one.
RawCallback
std::function< void(const RawFrame &)> RawCallback
Sensor values before radiometry -- for diagnostics and for recording a stream that can be reprocessed later.
One call per thermal frame, on the same thread and before the picture is colorized. Registering turns the tap on and clearing turns it off, so nothing else has to be configured.
Note: Sensor coordinates. Unlike the thermal frame beside it, this is never rotated or mirrored: the calibration maps and the dead-pixel indices it would be compared against are all in sensor coordinates, so turning it with the picture would make it useless for the one thing it is for. On a camera at its default orientation there is no difference.
Note: 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, so a 14 there would be a guess.
EnergyCallback
std::function< void(const EnergyFrame &)> EnergyCallback
Radiometric energy, the stage before energy becomes temperature.
After the NUC, gain, BXF and emissivity corrections and before the lookup that makes temperatures. This is the quantity to integrate over an area -- averaging temperatures over a region is not the same thing and is not a radiance.
One call per thermal frame, in sensor coordinates, on the same terms as RawCallback above.
VideoFormatCallback
std::function< void(uint32_t w, uint32_t h, float fps)> VideoFormatCallback
The stream geometry changed: a mode switch does this, and so does a quarter turn of orientation, which swaps width and height.
PifValueCallback
std::function< void(const std::string &name, float value, const std::string &unit)> PifValueCallback
A process-interface reading, with its name and unit.
ErrorCallback
std::function< void(const std::string &message)> ErrorCallback
A non-fatal problem worth surfacing. Fatal ones throw instead.
ConnectionStatusCallback
std::function< void(const ConnectionStatusChange &)> ConnectionStatusCallback
The connection status changed.
Invoked on the SDK's event dispatch thread, not the streaming thread. Fires on transitions only, so it is safe to drive UI state directly from it.
ShutterCallback
std::function< void(const ShutterEvent &)> ShutterCallback
The internal shutter changed position.
This is the way to get the transitions themselves, with timestamps, and the only way to tell a shutter on its way from one that has arrived -- a camera reports Closing and Opening too, and no single bool can carry four values.
It is not the only way to see a closure. The SDK holds the last frame taken with the shutter open and delivers it through the closed window rather than withholding it, so ThermalFrame::flag_open is false on those frames on every source and a per-frame answer is available.
Invoked on the SDK's flag cycle thread, which is not the streaming thread: a slow handler here delays the next transition report, never the camera.
ShutterCorrectionCallback
std::function< void(const ShutterCorrectionEvent &)> ShutterCorrectionCallback
A closure the process interface made has ended, and here is what came of it.
Only fires while a PIF input is in Shutter Control; an SDK-driven cycle does not report through this. Once per closure, at the reopen.
Invoked on the SDK's frame thread, from inside the frame that reported the reopen, so a slow handler here costs frames.
NucCycleCallback
std::function< void(const NucCycleReport &)> NucCycleCallback
One shutter cycle the SDK itself commanded has reached its decision, and here is everything it measured.
The counterpart of ShutterCorrectionCallback for the SDK's own periodic non-uniformity correction, which does not report through that one. Once per cycle that reached a decision; a cycle taken over by a process interface or cut short by a mode switch, a reconnect or shutdown reports nothing, and NucCycleReport::sequence is how a consumer tells that from a delivery it missed.
Until this existed every number in that record went only to the log, so no application could tell a cycle that averaged dark frames from one that averaged the scene. The field to read first is NucCycleReport::has_delivery_share: the quantity that separates a slow camera from a host losing frames cannot be measured on every camera, and 0 is not the answer "unmeasurable" -- the flag is.
Invoked on the SDK's flag cycle thread, before the reopen is waited out, so a handler that blocks holds the picture back.
Public static functions
Create
static auto Create() -> std::unique_ptr< Imager >
Create an Imager by auto-detecting the first available camera.
Exceptions
| Name | Description |
|---|---|
DeviceException |
if no camera found. |
CalibrationException |
if the open failed and calibration was found missing along the way. Missing calibration on its own is not a failure: the camera opens and streams, and GetCalibrationStatus() rather than a catch block is what reports it. This line said "if calibration unavailable", which is the case that does not throw. |
Create
static auto Create(const ImagerConfig &config) -> std::unique_ptr< Imager >
Create an Imager with specific configuration.
Exceptions
| Name | Description |
|---|---|
DeviceException, CalibrationException, ConfigException. |
Create
static auto Create(const DeviceInfo &device) -> std::unique_ptr< Imager >
Create an Imager for a specific device.
Exceptions
| Name | Description |
|---|---|
DeviceException, CalibrationException. |
Create
static auto Create(const DeviceInfo &device, const ImagerConfig &base) -> std::unique_ptr< Imager >
Open a specific device, taking every other setting from base.
The entry from enumeration says which camera and where it is, and wins over base.serial, base.transport and base.network -- enumeration has already resolved those and re-deriving them is what made a network camera unopenable. Everything else in base is used as given, which is how an application says "this camera,
and take the calibration from here" or "this camera, with these
measurement settings" without having to fill in the address itself.
There is no fallback to the other transport. A kUsb entry is opened on USB and a kNetwork entry at the address enumeration found it at; neither falls back to the other, so a camera that has gone away fails on the connection it was found on rather than first broadcasting for it elsewhere. Open from an ImagerConfig with Transport::kAuto if a search is what you want.
Exceptions
| Name | Description |
|---|---|
DeviceException, CalibrationException, ConfigException. |
Create
static auto Create(const SimulatedConfig &config) -> std::unique_ptr< Imager >
Create a simulated Imager for testing without hardware.
Create
static auto Create(const DeviceInfo &device, OpenProgressCallback progress) -> std::unique_ptr< Imager >
Create an Imager for a specific device, reporting progress.
Parameters
| Name | Description |
|---|---|
device |
the camera to open. |
progress |
called as the open moves through its phases, one phase at a time. May be empty. Must not throw; an exception that escapes it is swallowed. |
The callback is finished with by the time this returns: it is never invoked afterwards, and anything captured for the duration of this call can be released as soon as it returns.
It is not called on this thread for a real camera. The connect path publishes its phases on the SDK's event thread; only a simulated camera reports them on the caller's. See OpenProgressCallback for the whole contract.
Note: There is no cancellation parameter because there is nothing honest to put behind one. The legacy connect path this calls holds its API mutex from entry to exit and checks no flag along the way, so an open cannot be interrupted once it has begun. See docs/pages/20_csharp_api.md for what the managed wrapper does instead, and docs/pages/11d_device_communication.md for the window in which reopening that camera fails.
Exceptions
| Name | Description |
|---|---|
DeviceException, CalibrationException. |
Create
static auto Create(const ImagerConfig &config, OpenProgressCallback progress) -> std::unique_ptr< Imager >
Create an Imager from a configuration, reporting progress.
See also: Create(const DeviceInfo &, OpenProgressCallback)
Create
static auto Create(const DeviceInfo &device, const ImagerConfig &base, OpenProgressCallback progress) -> std::unique_ptr< Imager >
Open a specific device with base's settings, reporting progress.
The combination of Create(const DeviceInfo &, const ImagerConfig &) and Create(const DeviceInfo &, OpenProgressCallback), and the one an offline site needs: base.calibration_path and base.allow_calibration_download say where the calibration may come from, and progress reports the phases while it is obtained. Those are the same open -- pointing the SDK at a directory is exactly the case where the open is slow enough that the phases are worth showing.
device wins over base.serial, base.transport and base.network exactly as it does for Create(const DeviceInfo &, const ImagerConfig &).
Note: Still no cancellation parameter, for the reason given on Create(const DeviceInfo &, OpenProgressCallback): the connect path cannot be interrupted once it has begun.
Exceptions
| Name | Description |
|---|---|
DeviceException, CalibrationException, ConfigException. |
A CalibrationException names which source fell short -- the directory, the download, or both. |
Create
static auto Create(const SimulatedConfig &config, OpenProgressCallback progress) -> std::unique_ptr< Imager >
Create a simulated Imager, reporting progress.
A simulated camera has no calibration to acquire and nothing to look for, so this reports OpenPhase::kLocating followed by OpenPhase::kEstablished and nothing in between.
See also: Create(const DeviceInfo &, OpenProgressCallback)
Public functions
~Imager
~Imager() override
Imager
Imager(Imager &&) noexcept
operator=
auto operator=(Imager &&) noexcept -> Imager &
Imager
Imager(const Imager &)=delete
operator=
auto operator=(const Imager &) -> Imager &=delete
GetPif
auto GetPif() -> std::shared_ptr< pif::PifController >
The camera's process interface, or nullptr if there is no camera behind this imager.
Every physical camera answers with a controller, whether or not anything was detected on the connector. Detection is advisory -- see pif::PifDetection -- so a camera that reports nothing may still have a PIF wired to it, and pif::PifController::SetIdentity() is the documented remedy for exactly that. It has to be reachable on the cameras that need it, which are the ones detection fails on. Such a controller reads kind kNone, detection kUnknown, zero channels and IsConnected() == false until something is declared.
nullptr means there is no hardware to declare anything about: a simulated camera or a recording.
AttachSimulatedPif
void AttachSimulatedPif(pif::PifDeviceKind kind, const pif::PifHardwareInfo &layout)
Plug an in-memory process interface into this simulated camera.
A simulated camera has no PIF socket, so GetPif() answered nullptr on it and every PIF path -- channel tables, decoded inputs, output read-back, the fail-safe watchdog -- could only be tested through an SDK-internal seam that an application cannot reach. This is that seam, made public on the one camera where a fake is the honest answer.
After this call GetPif() returns a real pif::PifController over a memory-backed port. Everything above the port is the shipping code: the same transforms, the same reconciliation, the same signal publication into the alarm engine. Only the wire is fake.
The inputs are yours to drive -- SetSimulatedPifInput() -- and the outputs are the SDK's to drive; reading an output back through pif::PifController::ReadDigitalOutput() or ReadAll() is how a test asserts what the SDK did.
Calling it a second time replaces the interface, as swapping the box on the connector would: the controller, its channel table and its fail-safe configuration are all new.
Parameters
| Name | Description |
|---|---|
kind |
What the interface should present itself as. Every kind is accepted here, and GetSupportedDeviceKinds() lists them all, so pif::PifController::SetIdentity() can be exercised. |
layout |
How many channels of each sort it has, and whether it has a fail-safe line. Everything else in the record -- autonomy, output ranges, relay hold -- is reported back unchanged, so a test can state exactly the capability it wants the code under test to see. |
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera. |
AttachSimulatedPif
void AttachSimulatedPif(pif::PifDeviceKind kind=pif::PifDeviceKind::kStandard)
The same, with a two-in two-out layout and a fail-safe line -- the shape of a standard PIF, and enough for most tests.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera. |
DetachSimulatedPif
void DetachSimulatedPif()
Unplug it again. GetPif() answers nullptr afterwards.
Harmless if nothing is attached, because "there is no PIF on this camera" is the state it is asked to reach.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera. |
HasSimulatedPif
auto HasSimulatedPif() const -> bool
Whether a simulated process interface is plugged in right now.
False on a real camera rather than throwing: it is the question a caller asks before deciding whether the PIF it is holding is a fake, and an exception is a poor answer to that.
SetSimulatedPifDigitalInput
void SetSimulatedPifDigitalInput(uint8_t index, bool high)
Drive one digital input pin of the simulated interface.
This is the outside world talking: the value is what the next pif::PifController::Poll() or ReadAll() will read off pin index. There is no matching setter for an output, deliberately -- an output is what the SDK drove, and a test that could write one could assert on its own input.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera or nothing is attached. |
ConfigException |
if index is past the attached layout. |
SetSimulatedPifAnalogInput
void SetSimulatedPifAnalogInput(uint8_t index, float volts)
Drive one analog input pin of the simulated interface, in volts.
Volts, not raw counts: this is the reading a multimeter on that pin would show, before any channel decode. What pif::PifController::ReadAnalogInput() then answers depends on the channel configured over it.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera or nothing is attached. |
ConfigException |
if index is past the attached layout. |
StepSimulatedPifWatchdog
void StepSimulatedPifWatchdog()
Advance the fail-safe watchdog of the simulated interface by one check, as a passing health check on a real camera would.
The fail-safe line is deliberately not driven by pif::PifController::Poll() -- see the comment there -- so on a real camera it moves only when the frame watchdog says the pipeline is alive. A simulated camera has no such watchdog, and tying the line to synthetic frames would make the alternation a matter of timing. This is the explicit step instead: call it, and the line moves if and only if the configured period has elapsed, exactly as the real check does.
Observe the result through pif::IoSnapshot::fail_safe_level, or through the digital output the fail-safe was configured onto.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera or nothing is attached. |
SetSimulatedPifDetectedKind
void SetSimulatedPifDetectedKind(pif::PifDeviceKind kind, const pif::PifHardwareInfo &layout)
Put an external temperature probe reading on the simulated interface, in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit), as a frame carrying one would.
A probe reading does not arrive on a channel -- it is decoded out of the frame's PIF telemetry -- so there is no pin to drive and this is the only way to produce one without hardware. It reads back from pif::PifController::GetExternalProbeTemperature() and is published as SignalField::kProbeTemp, so an alarm rule on the probe fires here exactly as it would on a camera with one fitted.
Connect a process interface to the simulated camera's socket, to be found by the next re-detection.
This changes nothing by itself, exactly as plugging a cable in changes nothing until the camera is asked. The identity, the capabilities and the channel layout all move on the next pif::PifController::RedetectIdentity() and not before, so the sequence an application actually performs -- notice the socket is empty, plug something in, press "detect again" -- is the sequence a test performs.
This is what AttachSimulatedPif() cannot model. Attaching again replaces the controller and makes every handle stale, which is a box swapped on the connector; a PIF found on the socket that was always there is the same controller, so a handle an application is holding stays valid and its own RedetectIdentity() is the call under test.
Pass pif::PifDeviceKind::kNone to model a PIF that has been removed or powered down; the next re-detection then reports pif::PifDetection::kUnknown, as an empty socket does.
layout is what the interface being connected can do, and is adopted as the capabilities when it is found. A declaration still does not move the capabilities: that would make a test's stated layout a suggestion. This call moves them because it models the hardware changing rather than the application asserting.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera or nothing is attached. |
SetSimulatedPifDetectedKind
void SetSimulatedPifDetectedKind(pif::PifDeviceKind kind)
The same, with the default layout AttachSimulatedPif() uses -- two of each channel and a fail-safe line, or nothing at all for pif::PifDeviceKind::kNone.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera or nothing is attached. |
SetSimulatedPifExternalProbe
void SetSimulatedPifExternalProbe(float celsius)
Put an external temperature probe reading on the simulated interface, in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit), as a frame carrying one would.
Only on an interface attached as pif::PifDeviceKind::kTemperatureProbe, as on a real camera: on any other kind the reading is ignored and pif::PifController::GetExternalProbeTemperature() answers nothing.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera or nothing is attached. |
ClearSimulatedPifExternalProbe
void ClearSimulatedPifExternalProbe()
Take the simulated probe reading away, as a frame carrying none would -- a probe unplugged, or one that has stopped answering.
The missing half of SetSimulatedPifExternalProbe(). Without it the simulated interface could give a reading but never remove one, so the case that actually matters could not be reached without hardware, and the SDK held the last reading for ever.
Afterwards pif::PifController::GetExternalProbeTemperature() answers nothing, SignalField::kProbeTemp is invalid, a rule on the probe goes AlarmState::kOrphaned and a Compare::kInvalid watchdog on it fires -- which is what kProbeTemp has always documented and what a real camera does from this release on.
Calling it with no reading set is not an error.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera or nothing is attached. |
AcquireFrame
auto AcquireFrame() -> ThermalFrame
Acquire the next thermal frame (blocking).
Exceptions
| Name | Description |
|---|---|
CaptureException |
on error. |
TryAcquireFrame
auto TryAcquireFrame() -> std::optional< ThermalFrame > override
Try to acquire a frame without blocking.
AcquireFrame
auto AcquireFrame(std::chrono::milliseconds timeout) -> ThermalFrame override
Acquire a frame with timeout.
Exceptions
| Name | Description |
|---|---|
CaptureException |
on timeout or error. |
SetFrameQueuePolicy
void SetFrameQueuePolicy(FrameQueuePolicy policy)
Choose which frame the four-deep acquisition queue loses when it overflows. FrameQueuePolicy::kDropOldest by default, so a pull always sees one of the most recent frames.
Safe to call while streaming; it takes effect on the next frame. It does not disturb what is already queued, so a consumer that switches to FrameQueuePolicy::kDropNewest mid-stream keeps the frames it has.
The queue is emptied by a SetOperationMode(), SetTemperatureRange() or SetClippedWindow() that changes something, because what it holds then belongs to the settings just left. Those frames are not counted by GetDroppedFrameCount().
GetFrameQueuePolicy
auto GetFrameQueuePolicy() const -> FrameQueuePolicy
The policy in force.
See also: SetFrameQueuePolicy
GetDroppedFrameCount
auto GetDroppedFrameCount() const -> uint64_t override
How many frames the acquisition queue has discarded because a pull consumer did not keep up.
Counts exactly that and nothing else. It says nothing about frames the camera never sent, frames lost in the transport, or frames a consumer dropped from a buffer of its own further up -- the .NET package counts the last of those separately. Zero while nothing pulls slowly, whatever else the system is doing.
Non-zero and climbing is a consumer-side problem: either pull faster, or accept the loss and know its size. It is not reset by Start(), so a reading is over the life of the imager unless ResetStatistics() says otherwise.
On the FrameSource seam, where a recording and a still answer the same question about their own queues.
ResetStatistics
void ResetStatistics()
Zero the delivered-frame and dropped-frame counters, so a measurement can be taken over an interval rather than over the life of the imager.
Safe while streaming. A frame arriving during the call lands on one side of it or the other and is never counted twice.
SetThermalCallback
void SetThermalCallback(ThermalCallback callback) override
Register a callback. Each replaces any previous one, and passing an empty function removes it. Callbacks are invoked on the SDK's own threads, so anything slow belongs on a thread of your own -- a callback that blocks holds up the stream behind it.
No callback may destroy this Imager. A callback runs from inside the SDK, on a call stack that is holding state the teardown needs; destroying from there cannot complete. Hand the decision to a thread of your own and destroy it there.
What a callback may call on this Imager: What a callback may call on this Imager Every getter, and every setter but four. Read the width, the height, the serial, the radiometry, the device info, the temperature range, the regions and their measurements; add, move and remove regions and rules; set the palette, the colour range and the orientation. None of that blocks and none of it can deadlock. This was not always true -- in v11 a getter called from a frame callback could hang the camera for good -- so treat older advice to avoid the API inside a callback as obsolete.
The four exceptions are the calls that have to stop or drain the stream, which means waiting for the very callback that is asking: SetOperationMode(), Device().SetNetworkConfig(), Stop() and Reconnect(). They are refused, not hung: each throws or logs and names the callback it was called from, so the mistake is reported rather than paid for. Do them on a thread of your own.
The only cost left is time. The stream waits while a callback runs, so a slow one drops frames -- and a callback that blocks on something an API call is doing (a lens moving, a network write) blocks the stream for exactly that long.
SetBgraCallback
void SetBgraCallback(BgraCallback callback) override
SetRgbCallback
void SetRgbCallback(RgbCallback callback)
SetRawCallback
void SetRawCallback(RawCallback callback)
SetEnergyCallback
void SetEnergyCallback(EnergyCallback callback)
SetConnectionCallback
void SetConnectionCallback(ConnectionCallback callback) override
For a camera: connected or not. For a recording: true while the file is open, so a viewer's status logic does not have to branch.
SetConnectionStatusCallback
void SetConnectionStatusCallback(ConnectionStatusCallback callback)
Report every change of connection status.
Prefer this to SetConnectionCallback(). That one reduces the whole story to a bool, which cannot distinguish a camera that was closed from one that is gone from one that is open but no longer sending anything -- and the last of those is the case that matters, because it is the one where an application keeps showing a picture that has stopped being true.
Fires on transitions only. A link that is dead and stays dead reports Stalled once.
Warning: Do not destroy this Imager from inside the handler, and do not call this function from inside it either. Both need state the notification is holding, so neither can complete while it runs. The SDK refuses them and logs what happened rather than hanging, but a refused call is a call that did nothing.
Which thread this runs on depends on what changed, and it is not always the event dispatch thread. A transition coming out of the device layer is queued and delivered on the dispatch thread. The Connecting and Failed a reconnect publishes are synchronous: on the SDK's reconnect watcher thread for an automatic attempt, and on your own calling thread for a manual Reconnect(). So the handler can run underneath a call you made yourself.
Warning: And it can run on two of those threads at the same time, so the handler must be thread-safe. A queued transition and a reconnect's synchronous publish are two independent deliveries, and nothing serializes them: measured, with two threads observed inside one handler together. Keep the handler to recording what changed, and do not assume a previous call has returned before the next begins.
Recovering from ConnectionStatus::Stalled or ConnectionStatus::Lost by hand means destroying this Imager and creating another, and the handler is the obvious place to do it. Do it on a thread of your own instead -- record the transition here and let your own loop act on it.
Or do not recover by hand at all: EnableAutoReconnect() does this for you, with a backoff, a presence gate and a progress handler of its own. An application that both follows the example below and enables automatic recovery disposes the camera while the SDK's own attempt is in flight, which is the one combination to avoid -- pick one owner for the recovery. The example is for applications that want to own it:
#include <atomic> ImagerConfig config; std::atomic<bool> recover{false}; imager->SetConnectionStatusCallback( [&](const ConnectionStatusChange &change) { if (change.current == ConnectionStatus::Lost || change.current == ConnectionStatus::Stalled) { recover = true; // and nothing else from here } }); // ... on your own thread: if (recover.exchange(false)) { imager.reset(); // safe here imager = Imager::Create(config); }
Clearing the handler is a fence: when this returns after being passed an empty function, no handler is still running, so anything it captured is safe to destroy.
SetVideoFormatCallback
void SetVideoFormatCallback(VideoFormatCallback callback)
SetPifValueCallback
void SetPifValueCallback(PifValueCallback callback)
SetErrorCallback
void SetErrorCallback(ErrorCallback callback)
SetShutterCallback
void SetShutterCallback(ShutterCallback callback)
Register before Start() to see the startup calibration; a registration made afterwards still sees every later cycle.
SetShutterCorrectionCallback
void SetShutterCorrectionCallback(ShutterCorrectionCallback callback)
Be told what came of each closure the process interface makes.
Registering late loses nothing permanently: Detector::GetLastShutterCorrection() answers for the closure before this handler existed.
SetNucCycleCallback
void SetNucCycleCallback(NucCycleCallback callback)
Be told what each of the SDK's own shutter cycles measured.
Registering late loses nothing permanently: Detector::GetLastNucCycle() answers for the cycle before this handler existed.
SetTemperatureRange
void SetTemperatureRange(const TemperatureRange &range)
The band this camera is measuring in.
A range change is a mode change on the device and includes a calibration reload, so it is applied only when the record asks for something different from what is active.
The same is true of extended and high_precision: each rebuilds the energy-to-temperature table, so each is applied only when it differs from what is in force. Whichever of the three moves, this can take seconds on a running camera: rebuilding the processing chain waits for the picture being processed and for a shutter calibration in progress, because the rebuild frees what both of those are using. A record that changes nothing returns at once, which is what makes the documented read-modify-write idiom cheap.
For the same reason, a record that changes something may not be set from inside a frame callback: the wait is for the pass that callback is part of. It throws and says so rather than waiting for itself. A record that changes nothing is fine from anywhere.
And whichever of the three moves, the camera restarts its startup calibration and the frames until it finishes are not measurements. This is the same state a connect publishes, not a new one: FrameMetadata::thermal_data_reliable is false from the write, alarm rules do not act on those frames and region readings are not published, and all of it resumes on its own when the readings are right. Measured on an Xi 410 21104350: a −20..100 → 0..250 °C change marked 556 of the 557 frames after the write, over 29.9 s; an extended change 13.0 s -- the shorter figure being the abbreviated settling times a change gets when it did not move the detector's working point. Wait for the first frame that reports the flag set; that flag is the whole of the signal, and there is deliberately nothing else to read and no timer to run. If you need a measurement immediately, open the camera in the range you want rather than changing into it -- see ImagerConfig::operation_mode.
No frame from before the change is handed out after it. When this returns having changed something, the frames still waiting in the AcquireFrame() queue were taken with the settings just left, the newest of them still marked reliable, and they are discarded. The thermal callback is not called for one either, so the first frame after the call that reports the flag set is one of the new settings. Recorder::SaveSnapshot() throws IoException until a frame of the new settings that reports the flag set has arrived, rather than write the last frame of the old ones or a frame of the recalibration, the first of which can have been read out before the call; the interval capture and alarm stills write nothing until then. A record that changes nothing discards nothing.
Exceptions
| Name | Description |
|---|---|
ConfigException |
if the range is not one this camera offers. GetDeviceInfo().available_ranges lists the ones it does. |
GetTemperatureRange
auto GetTemperatureRange() const -> TemperatureRange
The range currently active.
GetHighPrecisionState
auto GetHighPrecisionState() const -> HighPrecisionState
Whether the high-precision table's finer step is reaching the temperatures this SDK reports, and when it is not, why not.
Read this rather than inferring an answer from GetTemperatureRange().high_precision, which reports the **request** and reads back trueon every camera, including those whose calibration offers no finer table and those where the pipeline rounds it away. Combining it withGetOperationMode().high_precision_available gets closer and still cannot see the rounding, which is the part a caller has no other way to learn.
Answers on a camera that is not open -- as HighPrecisionState::kUnknown -- rather than throwing, so a status panel can show it without a connection.
See also: HighPrecisionState for what each value means, and TemperatureRange::high_precision for the measured step figures.
SetOperationMode
void SetOperationMode(const OperationMode &mode)
The optic, range, resolution and frame rate the camera is running with, as one value. GetDeviceInfo().operation_modes lists every mode it offers.
On a running camera this restarts the startup calibration, and the frames until it finishes are not measurements. Same state a connect publishes, same flag: FrameMetadata::thermal_data_reliable is false from the write and true again when the readings are right -- measured on an Xi 410 21104350 as 556 of the 557 frames after a −20..100 → 0..250 °C switch, over 29.9 s. Wait for the first frame that reports the flag set; that flag is the whole of the signal. The readings afterwards land where opening the camera in that mode lands them (about 0.7 K, re-measured at 0.16 to 0.51 K), so there is no reopen to do -- an earlier SDK carried a mark here saying otherwise and it has been removed.
To avoid the wait altogether, open in the mode you want: ImagerConfig::operation_mode.
No frame of the old mode is handed out after this returns. The frames still waiting in the AcquireFrame() queue are discarded, and the thermal callback is not called for one, so the first frame after the call that reports the flag set is the new mode's. Recorder::SaveSnapshot() throws IoException until a frame of the new mode that reports the flag set has arrived, rather than write the old mode's last frame or a frame of the recalibration, and the interval capture and alarm stills write nothing until then. Setting the mode already active discards nothing.
Exceptions
| Name | Description |
|---|---|
ConfigException |
if the mode is not one this camera has. |
GetOperationMode
auto GetOperationMode() const -> OperationMode
The mode currently active.
GetClippedWindow
auto GetClippedWindow() const -> ClippedWindow
Where a clipped video format's window sits on the detector.
The fastest formats are not the whole detector. A PI 640's 640x120 @ 125 Hz reads 120 of its 480 rows, and that strip is a window that can be moved: there is no reason the interesting part of the scene should be in the middle of the detector.
Ask this first. It never throws, on any camera, open or not, so it is what an application tests before offering the control. clipped is false and everything else zero on a mode that reads the whole detector -- which is most of them.
SetClippedWindow
void SetClippedWindow(int x, int y)
Move that window's top-left corner, in detector pixels.
Positions outside the window's travel clamp to it rather than being refused, so a slider dragged to its end does the obvious thing. The travel is ClippedWindow::max_x and ClippedWindow::max_y, which are usually 0 and something: a fast format drops rows rather than columns, so the window normally moves vertically only.
This costs what an operation-mode switch costs. The window is not only a command to the camera: the calibration is cropped to it, the distortion correction's optical centre is measured from it, and the dead-pixel list is in detector coordinates. Moving it rebuilds the processing chain so that all four agree. Do not drive it from a slider's every intermediate value.
If the rebuild fails, the previous position is restored and the failure is reported; the camera is never left reading one strip while the pipeline is calibrated for another. When it moves, the frames from the old position are not handed out afterwards, as for SetOperationMode().
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if the active operation mode is not a clipped format, or no camera is open. GetClippedWindow() answers both without throwing. |
DeviceException |
if the camera or the pipeline refused. |
Start
void Start() override
Start frame acquisition and processing.
Exceptions
| Name | Description |
|---|---|
DeviceException |
on failure. |
Stop
void Stop() override
Stop acquisition. Callbacks have returned by the time this does, so a buffer they were writing into is safe to release afterwards.
IsRunning
auto IsRunning() const -> bool override
True between a successful Start() and a Stop().
IsConnected
auto IsConnected() const -> bool
Whether a device is open.
Note what this does not mean: it does not mean frames are arriving. A camera whose stream has stopped -- because the host suspended, or the link went quiet -- is still open, and this still answers true. Ask GetConnectionStatus() whether the picture can be trusted.
GetConnectionStatus
auto GetConnectionStatus() const -> ConnectionStatus
What the link is actually doing, latched.
Readable at any time, including before Start() and after a drop. Reports Stalled while the device is open but no frame has arrived within the connection timeout.
GetConnectionTimeout
auto GetConnectionTimeout() const -> std::chrono::milliseconds
How long without a frame before GetConnectionStatus() says Stalled.
Worth reading rather than assuming. The default is not the SDK's: it comes from this camera's saved configuration on this machine, so the same program watching the same camera model reports a stall after a different wait on a different PC. An application that wants to tell its user how long the picture has been stale has to ask.
Readable before the camera is open, when it reports what a fresh configuration would use.
SetConnectionTimeout
void SetConnectionTimeout(std::chrono::milliseconds timeout)
Shorten or lengthen that wait for this camera.
Nothing is written to disk. The saved configuration is the machine's; this is the application's, and it lasts as long as this imager does.
This is the only lever over a stream that opens and then never delivers a frame: with the stock ten seconds, a program that re-opens a camera on a stall waits ten seconds to find out it has to.
Exceptions
| Name | Description |
|---|---|
std::invalid_argument |
if the duration is zero or negative -- that is not a short wait, it is a stream that is stalled before it starts. |
Reconnect
void Reconnect()
Re-open this camera, in place, now.
A reconnect is a re-open, not a retry. A host suspend or a replug invalidates the device handle rather than making it stale: on Windows the Media Foundation read fails with 0xc00d3ea2 and the asynchronous read chain is never re-armed, so nothing can resume it. This therefore tears the whole session down -- streaming stopped, source reader destroyed, control channel closed, host claim released -- and opens a fresh one in its place.
The Imager object, its callbacks, its regions, its alarm rules and its settings all survive: it is the camera underneath that is replaced, not this object. See reconnect_settings below for exactly what is re-applied.
Synchronous, and one attempt. It returns when the camera is open and a frame has arrived, or it throws. Waiting for the frame is not belt and braces: a Media Foundation reader can be recreated successfully against a session the frame server has not finished tearing down, and it then accepts every read and completes none. An open that reports success and delivers nothing is the failure this call exists to end, so it is not allowed to be the answer.
If the camera was streaming when the link died it is streaming again when this returns. If it was not, it is open and stopped.
What survives. Everything the application set through this Imager: the palette (built-in or custom), the colour range and auto-scale policy, the colour-scale dynamics, temperature range and operation mode, radiation parameters, regions, alarm rules, colour windows, orientation, the connection timeout, the process interface configuration and every registered callback. What does not survive is anything belonging to the old session rather than to the configuration: the frame counter continues, the startup calibration runs again, and a recording in progress is stopped and finalized before the teardown. The file on disk is complete and playable, rec::RecordingPhase::kStopped reaches the handler registered with Recorder::OnRecording(), and nothing is written into it afterwards. Start a second recording on ReconnectPhase::kRecovered if that is what you want: a file that silently hides a two-minute outage is worse than one that stops.
A time-lapse keeps running and writes nothing while the camera is away. The retained last frame is dropped with the link, so Recorder::SaveSnapshot() throws rather than writing the last live frame under a filename carrying the current time.
The process interface carries over as far as the camera that comes back allows. The channel table from pif::PifController::Configure() and the state of pif::PifController::SetFailSafe() are re-applied to the re-opened camera, so a fail-safe that was armed is armed again and its line keeps alternating. A camera that comes back reporting a different interface -- or none, because it was unplugged during the outage -- cannot be given the old table. The SDK logs at error level exactly what it could not restore, and says explicitly whether the fail-safe is armed; pif::PifController::GetConfiguration() and pif::PifController::GetFailSafe() then report what the camera actually has. This is not free-standing state like the regions: the v12 table lives only in the controller, and the controller is destroyed with the session, so it is carried across explicitly.
Warning: Not from inside an SDK callback. The frame thread and the event dispatch thread are both torn down by this call and cannot wait for themselves. Called from either, it throws rather than deadlocking. Record the decision in your handler and act on a thread of your own -- or use EnableAutoReconnect(), which already has one.
Exceptions
| Name | Description |
|---|---|
DeviceException |
if the camera could not be re-opened, or if it opened and delivered no frame. The imager is left closed and GetConnectionStatus() reports Failed; calling again is valid, and is what EnableAutoReconnect() does. |
DeviceException |
if there is no camera to re-open, or if called from an SDK callback thread. |
EnableAutoReconnect
void EnableAutoReconnect(const ReconnectConfig &config)
Have the SDK re-open this camera by itself whenever it drops.
This is the answer to "who reconnects": the SDK does. A background thread watches the connection status this imager already publishes, and on a transition to ConnectionStatus::Lost, ConnectionStatus::Stalled, ConnectionStatus::Disconnected or -- after a session that worked -- ConnectionStatus::Failed, it performs Reconnect() on the backoff schedule in config. Frame callbacks stop when the camera stops and resume when it comes back, with the same settings; the application sees a gap in the frames and the status transitions that explain it, and writes no recovery loop of its own.
A Failed raised by the very first open is not recovered: the application asked for that open and is holding the error, and retrying it on a backoff schedule behind its back is not recovery.
A camera that is being asked for frames and has never delivered one is not recovered. The question this answers is "did this session ever work", and an open on its own does not answer it: the engine publishes Connected at the end of the open, before any frame, so a camera whose open succeeded and whose stream never started looks identical to one that ran for an hour.
The case it is for is a network camera whose first frame is held back by a firewall prompt. Before this rule such a camera stalled, was recovered, stalled again, and spent the whole attempt budget on a re-open that cannot help it -- the frames are not blocked by anything a re-open changes.
Two things it deliberately does not withhold:
- A camera you opened and never started. There is no frame to wait for on one of those, and it is recovered as before.
- A camera that delivered frames and has since gone quiet or been stopped. One frame is enough, for the whole life of the camera: the rule asks whether it ever delivered, not whether it is delivering now.
So Start() on a camera that never produces a frame leaves you with the status transitions and no recovery, which is the honest answer -- ConnectionStatus::Stalled stands, and the remedy is the application's, not a re-open's. Once a single frame has arrived the camera is eligible for the rest of its life.
An attempt is withheld when the SDK can see that making it is pointless. A USB camera that a device sweep does not list, and one the sweep lists but another process holds, are both waited for -- ReconnectPhase::kWaitingForDevice, on the same backoff schedule -- and the wait spends no attempt. Refuse an individual attempt with SetReconnectAttemptCallback().
A camera left unplugged is looked for indefinitely rather than exhausting its budget against an empty bus, including when it is the only Optris USB camera on the host and when every camera went at once, as it does when a hub loses power. That used to need another camera to stay enumerated: the USB layer reports a bus with nothing on it and a backend that could not look in the same way, so an empty sweep was read as "present" and every attempt was made. The sweep now establishes separately whether it was able to read the bus, and an empty result from a bus it could read is absence.
Note: On Windows this works the same way and since the same release, read off the device interface enumeration rather than libusb: a lone unplugged USB camera is waited for there too and spends no attempt. Where the bus cannot be read at all -- on either platform -- nothing is concluded from an empty sweep and the attempt is made, exactly as before, because never re-opening a camera that is present would be the worse mistake.
A camera reached over the network is looked for on the network instead: at the address it was at, then by its serial in a discovery sweep. Found nowhere, it is waited for in the same way; found at another address (a new DHCP lease), it is re-opened there. One that has never answered discovery from this host is attempted as before, because a broadcast does not cross a router and its silence proves nothing.
A reconnect is a re-open, so a recording in progress is stopped and finalized first. It is stopped at the first attempt, not at the drop, so while the wait above is holding attempts back the file stays open and IsRecording() stays true.
The sequence for one drop and one failed attempt is Lost or Stalled, then Connecting, then Disconnected, then Connecting, and finally Connected or Failed. Failed is the last word of a failed attempt, never Disconnected: the teardown's own notification is delivered before it, so a subscriber keyed on Failed cannot miss the outcome and one keyed on Disconnected cannot mistake it for a user close.
The transitions are worth watching even so: Disconnected then Connecting then Connected is a recovery that worked, and the UI that shows "reconnecting" rather than a frozen frame is what makes the gap honest to an operator. SetReconnectCallback() reports the attempts themselves.
Calling this again replaces the configuration. The watcher is stopped by DisableAutoReconnect(), by destroying the Imager, and by the SDK itself once it gives up.
Exceptions
| Name | Description |
|---|---|
ConfigException |
if config is not a backoff: a backoff_multiplier below 1 shortens the wait on every failure, and a non-positive initial_delay is a retry loop with no wait in it. Both hammer a camera that is not there. |
DeviceException |
if called from inside a reconnect handler. |
DisableAutoReconnect
void DisableAutoReconnect()
Stop reconnecting this camera automatically.
Does not throw, and is harmless when nothing is enabled, so tidy-up code need not check. No further attempt is made, and this returns after the watcher has stopped, so anything its callbacks captured is safe to destroy afterwards.
An attempt already in flight is abandoned, not waited out. Waiting one out costs a teardown, a whole re-open and up to eight more seconds of waiting for a first frame -- tens of seconds, on the path an application takes while it is shutting down. An attempt is given up between the teardown and the re-open, and while waiting for that first frame, and the camera is left closed: the connection status comes to rest at ConnectionStatus::Disconnected, and no ReconnectPhase::kAttemptFailed is published, because nothing failed -- you asked the SDK to stop.
A failed attempt rests at ConnectionStatus::Failed instead, and the difference is deliberate: an application may branch on the two, and switching recovery off does not read, in a log, like a recovery that did not work.
What is still waited for is the re-open itself, if it had already begun: that call cannot be interrupted, so the worst case is one connection timeout (ten seconds by default) rather than one timeout plus the frame grace.
IsAutoReconnectEnabled
auto IsAutoReconnectEnabled() const -> bool
Whether automatic reconnection is in force for this camera.
The state, not the request. This reads false once the SDK has given up: after ReconnectPhase::kGaveUp the watcher thread has returned and nothing is watching the camera, and a flag still saying "in force" described a request nobody was acting on. Switch it back on with another EnableAutoReconnect().
GetReconnectConfig
auto GetReconnectConfig() const -> ReconnectConfig
The configuration EnableAutoReconnect() was given, or the defaults when it has not been called.
SetReconnectCallback
void SetReconnectCallback(ReconnectEventCallback callback)
Report every step of an automatic reconnect.
The attempts, their failures and the outcome -- which the connection status alone cannot distinguish from a camera that is simply gone. Replaces any previous handler; an empty function removes it, and clearing is a fence in the same way SetConnectionStatusCallback() is.
Invoked on the SDK's reconnect thread. It must not destroy this Imager and must not call Reconnect(), EnableAutoReconnect() or DisableAutoReconnect(); those are refused with a log line rather than hanging.
Whatever the handler captures must outlive the watcher, and the watcher outlives the last event you saw. A recovery is a schedule: after any phase but ReconnectPhase::kGaveUp and ReconnectPhase::kRecovered another attempt is coming and this thread is still running. So do not destroy what the handler captured because a phase you were waiting for has arrived -- destroy it only after DisableAutoReconnect(), this call with an empty function, or ~Imager() has returned. Each of the three waits. Destroy it earlier and the handler writes into memory that is gone; on Linux that is usually silent, on Windows the heap manager terminates the process with STATUS_HEAP_CORRUPTION.
SetReconnectAttemptCallback
void SetReconnectAttemptCallback(ReconnectAttemptCallback callback)
Refuse an individual reconnect attempt.
Called just before each attempt, after the wait and after the presence gate. Return true to let it proceed and false to stop recovering altogether: the watcher publishes ReconnectPhase::kGaveUp and exits, and a later EnableAutoReconnect() is what starts it again.
There is deliberately no third answer. false ends the recovery; it does not skip one attempt and keep watching, and a handler that refuses an attempt because the camera is briefly unreachable has stopped the recovery rather than postponed it. Return true in that case. The deferral is already in the SDK and sits lower than a callback can: the presence gate withholds an attempt for an absent or foreign-held camera without spending one, publishes ReconnectPhase::kWaitingForDevice, and re-asks on every wait. Keep this hook for what only the application knows and leave the bus to the gate.
This is the hook for an application that knows something the SDK cannot -- that the device is deliberately powered down for maintenance, that the operator has closed the camera's tile, that a network camera has been re-addressed. Without it the only way to stop a recovery was DisableAutoReconnect() from another thread, racing the attempt it was trying to stop.
Set independently of EnableAutoReconnect(), before or after it, and survives it: enabling again does not clear the hook. An empty function removes it, and no veto means every attempt proceeds.
Invoked on the SDK's reconnect thread, with the same rules as SetReconnectCallback(): it must not destroy this Imager and must not call Reconnect(), EnableAutoReconnect() or DisableAutoReconnect().
The same capture-lifetime rule too, with one fence fewer. Removing this hook with an empty function is not a fence, unlike removing the SetReconnectCallback() handler: the veto is copied out from under its lock and called with the lock released -- which is what keeps installing one from inside a handler from hanging -- so a call already in flight when you remove it runs to completion afterwards. Use DisableAutoReconnect(), or destroy the Imager, before destroying anything this hook reads.
GetCalibrationStatus
auto GetCalibrationStatus() const -> CalibrationStatus
Whether this camera's temperatures can be believed.
A camera whose calibration files could not be found opens anyway, streams anyway, and reports temperatures anyway -- and they are wrong. GetConnectionStatus() will not tell you: the link is fine, and the link is all it reports. This is the other axis.
Latched during the open and readable for as long as the imager lives, including after the stream has stopped -- unlike the warning it replaces, which was one log line at open time.
Reports kUnknown for a simulated camera, which has no calibration to find.
Note: A recording and a still are not an Imager and so never reach this function at all -- there is no C++ object of this kind to ask. They answer kUnknown through the C ABI and the bindings, where one handle type covers all three sources: optris_sdk_imager_get_calibration_status(), .NET ThermalCamera.CalibrationStatus.
GetCalibrationDiagnosis
auto GetCalibrationDiagnosis() const -> std::string
Why the calibration is missing, in words, when it is.
Names which source let this machine down -- the directory the caller pointed at, the camera itself, or a download that was switched off -- because on a factory PC behind a firewall that distinction is the whole of the problem. Empty when GetCalibrationStatus() reports anything but kMissing.
SkipStartupCalibration
auto SkipStartupCalibration() -> bool
Skip the calibration a camera runs when it starts.
What it buys. The frames during that calibration are not measurements and say so -- every one carries FrameMetadata::thermal_data_reliable false -- so this gets a picture on screen sooner. That is the whole of the gain: a reasonable trade for a viewfinder, a bad one for a measurement.
What it costs, which is more than it buys. The startup calibration commands three shutter cycles of its own, and the detector-settling criterion needs two references it can compare before it will say the detector has stopped moving. Skipping gives those up, so the first frame marked as a measurement arrives later, not sooner. Measured on an Xi 410 21104350, warm: first reliable frame at 20.9 s without skipping and 231.7 s with it -- and, before the SDK commanded a reference of its own, never within 303 s in two runs where nothing else was done.
The SDK asks for that reference itself once the configured minimum flag interval has elapsed (IRImagerConfig::minInterval, 12 s by default), so the wait is bounded. It is still longer than not skipping. If you need a measurement, do not skip; Detector().TriggerShutter()` is the fastest way back if you already have -- a cycle triggered by hand at 16 s ended the wait at 18.2 s on that camera.
It does not have to be called before Start(). Called while the calibration is running it ends it there, which is how an application offering a "skip" button uses it. It returns false once the calibration has finished, because there is then nothing to skip.
GetFrameCount
auto GetFrameCount() const -> uint64_t override
Frames delivered since the source started.
SetPalette
void SetPalette(Palette palette) override
Set internal processing parameters directly. These reach whichever pipeline backend is active -- CPU and GPU alike. Digital detail enhancement, base and detail gain. Setting either one switches enhancement on.
Enhancement is a visualization operation: it changes the RGBA output and nothing else. Temperatures reported through ThermalFrame, measurement regions, recordings, snapshots and the registered external buffers are unaffected by these gains, on every backend. Before v12 they were not -- see the CHANGELOG. Spatial filter selection. Unlike the DDE gains above, the noise filters run inside the radiometric path and do change reported temperatures -- that is what denoising a measurement means.
Mode 7 selects detail enhancement and is the exception: it is equivalent to the DDE gains above and is display-only.
GetPalette
auto GetPalette() const -> Palette override
The built-in palette selected.
Unaffected by SetCustomPalette(): a custom palette overrides the selection rather than replacing it, so this keeps reporting the built-in that ClearCustomPalette() would go back to. Ask GetCustomPalette() which one is actually on screen.
SetCustomPalette
void SetCustomPalette(const CustomPalette &palette) override
Colorize with colours the application supplies.
Overrides the built-in selection until ClearCustomPalette() or SetPalette() puts it back. The table is copied, so the caller's CustomPalette does not have to outlive the call, and nothing is registered anywhere -- the palette belongs to this source alone.
Throws ConfigException if the palette is not valid; see ValidateCustomPalette() to test instead of catching.
The default reports that the source cannot colorize.
ClearCustomPalette
void ClearCustomPalette() override
Go back to the built-in palette GetPalette() reports.
Does nothing when no custom palette is in force.
GetCustomPalette
auto GetCustomPalette() const -> std::optional< CustomPalette > override
The custom palette in force, or nullopt when a built-in one is.
Returns what was set, so an application can read the colours back to draw a legend the same way GetPaletteColors() serves the built-in ones.
SetColorRange
void SetColorRange(std::optional< float > min_c, std::optional< float > max_c) override
Fix the colour scale. Unset means scale each frame to its own range.
Both ends are in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit). The SDK keeps the range in Celsius, so one set before a unit switch keeps its meaning and reads back in the new unit.
GetColorRange
auto GetColorRange() const -> std::pair< std::optional< float >, std::optional< float > > override
The fixed colour range in force, end by end.
The counterpart SetColorRange() did not have, and the only call that can say whether the scale is fixed at all. It is the same shape as the setter on purpose: a pair of optionals, so that a source holding one end and not the other reports exactly that rather than a range it does not have.
This is not the same question as GetAutoScaleMode(): This is not the same question as GetAutoScaleMode() A fixed range is not a mode. The mode is what applies while no fixed range is in force, and setting a range does not clear it -- clearing the range has to leave a mode to go back to. So a source drawn on a fixed range still reports whatever mode was last chosen, and on a replay that is kPercentile, the default, because the file names no mode when a fixed range was in force.
That is what makes GetAutoScaleMode() alone unanswerable: it was the only thing a caller could read, so it was taken for the answer, and a replay of a recording made on 25..35 C reported "percentile". Both ends being present here is what "the scale is
fixed" means.
Nor the same as GetEffectiveColorRange(): Nor the same as GetEffectiveColorRange() That one is what the last frame was actually drawn with, so it is empty until a frame has been drawn and it moves from frame to frame under an auto mode. This one is the setting, available before anything is drawn -- which is when an application decides what to label the scale.
Returns: The two ends in the SDK's temperature unit, each present only if set.
SetAutoScaleMode
void SetAutoScaleMode(AutoScaleMode mode) override
How that per-frame range is chosen while no fixed range is set: the scene's 1st/99th percentile (the default), its coldest and hottest pixel, or a band of one or three standard deviations around its mean. It changes the picture only; every temperature the source reports is the same either way.
GetAutoScaleMode
auto GetAutoScaleMode() const -> AutoScaleMode override
The mode SetAutoScaleMode last set.
SetColorScaleDynamics
void SetColorScaleDynamics(const ColorScaleDynamics &dynamics) override
How fast the auto-scaled colour range is allowed to move.
Applies in every auto mode. The scale is recomputed from each frame, and letting it follow that raw estimate makes the picture breathe -- a hot object leaving re-colours the scene behind it in a single frame, and on a narrow scene the scale is the sensor noise, so a still wall shimmers. This is the damping that stops that, expressed in time so a 27 Hz camera and an 80 Hz one behave the same.
Has no effect while a fixed range is in force: a range the caller set is not an estimate to be smoothed.
The mechanism reproduces the v11 ImageBuilder's filter.
GetColorScaleDynamics
auto GetColorScaleDynamics() const -> ColorScaleDynamics override
The dynamics in force, after clamping. Echoes what was set -- what it did to the last frame is GetEffectiveColorRange().
GetEffectiveColorRange
auto GetEffectiveColorRange() const -> std::optional< std::pair< float, float > > override
The colour scale the most recent frame was actually drawn with, in the SDK's temperature unit, or nullopt if none has been yet.
What a temperature slider shows while auto-scaling. It cannot be derived from outside the SDK: under the sigma modes it is temporally filtered, so it is neither what any single frame's pixels imply nor what the caller last asked for.
Empty before the first frame and after a change of scaling mode, both of which are states where no frame has been drawn with any range and a number would be an invention.
GetRenderState
auto GetRenderState() const -> std::optional<::optris::sdk::rec::RenderMeta >
Everything that decides what the colours currently mean, as one consistent answer.
The palette (or "custom" and the application's name for it), the two ends of the colour scale in the SDK's temperature unit, and the auto-scale mode that chose them -- or an empty mode when a fixed range is in force and the caller chose them.
Assembling this by hand means GetPalette(), GetPaletteName(), GetCustomPalette(), GetEffectiveColorRange(), GetAutoScaleMode() and then knowing that the mode only names the chooser when no fixed range is set. That is five calls and one rule, taken without a lock between them, and every caller that needs a legend or a file header has to get all six right. This is that answer, derived once.
overlays and thermal_data_reliable are left absent: both are properties of a particular picture rather than of the settings, so whoever has the picture fills them in.
Returns: Empty until a colour scale exists -- before the first frame has been drawn there is no range to report and nothing here could be said truthfully. GetConfiguredRenderState() is what to ask in that moment.
GetConfiguredRenderState
auto GetConfiguredRenderState() const -> ::optris::sdk::rec::RenderMeta
The same answer restricted to what is configured, and therefore always available.
The palette, and either the fixed colour range the caller set or the name of the auto-scale mode that will choose one. Never the range under an auto mode: that range does not exist until a frame has been drawn, and this reports it absent rather than inventing it.
What it is for: What it is for A recording can begin before anything has been drawn -- an alarm trigger, or a Start() on the line after Open(). GetRenderState() is empty there, and a file whose render block is simply missing makes every reader handle an absent key and tells it nothing, when the palette was known all along and, under a fixed scale, so was the range. A recording's file-level block is now always written, from this when there is nothing drawn yet.
overlays and thermal_data_reliable are absent for the same reason as in GetRenderState(): they describe a picture, and there is none here.
Regions
auto Regions() -> RegionEngine &override
The measuring areas on the image.
Reached the way GetPif() reaches the process interface. The returned handle refers to this imager and is valid as long as it is.
auto area = Region::Rect({0.5F, 0.375F}, {0.2F, 0.2F}); area.name = "Furnace"; const auto id = imager->Regions().Add(std::move(area)); const Vec2 p{0.6F, 0.4F}; imager->Regions().Edit(id, [&](Region &r) { r.SetCentre(p); });
Regions
auto Regions() const -> const RegionEngine &override
Alarms
auto Alarms() -> RuleEngine &override
The rules that watch signals, and the alarms they raise.
Rule hot; // The region's signal slot is filled in from the region id by // the two-argument Add() below, so this 0 is discarded. It is // not a region id -- see RegionEngine::SignalSlot() for the // one-argument Add(), where the slot has to be right. hot.input = SignalId::Region(0, SignalField::kMax); hot.condition.compare = Compare::kAbove; hot.condition.alarm.high = 80.0F; imager->Alarms().Add(region_id, std::move(hot));
Alarms
auto Alarms() const -> const RuleEngine &override
Optics
auto Optics() -> sdk::Optics &
The lens: whether it can be focused, and where.
Optics
auto Optics() const -> const sdk::Optics &
Display
auto Display() -> sdk::Display &
How the picture is drawn: colour bands, region overlays, and the GPU surface it can render straight onto.
Display
auto Display() const -> const sdk::Display &
SetDisplayTemperatureUnit
void SetDisplayTemperatureUnit(TemperatureUnit unit)
The unit this imager shows temperatures in, wherever the SDK itself turns a temperature into text for a person to read.
That is the reading in a region's label drawn into the picture (RegionStyle::show_label), on the delivered frame, on the GPU surface and in a snapshot's picture, and the "The scene measured
... to ..." line a JPEG snapshot opens with. Each is converted and rounded by Temperatures::Format(), so a label and an application's own Temperatures::Format() of the same reading agree to the last digit.
Display only. It chooses the unit of this imager's own text and nothing else. The unit of every number the API takes and returns is SetTemperatureUnit()'s, for the whole SDK. Everything written for a program to read stays in Celsius: the radiometric PNG and TIFF, the metadata document in every snapshot, and log lines. A CSV snapshot keeps its own rec::CsvOptions::temperature_unit.
Until it is called, this imager draws in the SDK's unit (SetTemperatureUnit(), Celsius by default), so a program that sets only that gets Fahrenheit labels too. Once called, it is this imager's choice whatever the SDK's unit. With both left at Celsius every picture and file is byte for byte what it was before this setting existed. Takes effect on the next frame drawn and the next snapshot written. Safe from any thread.
Each imager has its own setting. A canvas (Canvas()) is drawn by the imager it is set on, so its labels follow that imager's unit.
imager->SetDisplayTemperatureUnit(TemperatureUnit::kFahrenheit); // A region at 21.3 C, labelled "INLET 21.3C" until now, is // labelled "INLET 70.3F".
Exceptions
| Name | Description |
|---|---|
InvalidArgumentException |
for a value that is neither kCelsius nor kFahrenheit. Nothing changes then. |
GetDisplayTemperatureUnit
auto GetDisplayTemperatureUnit() const -> TemperatureUnit
The unit set with SetDisplayTemperatureUnit(); the SDK's unit (GetTemperatureUnit()) until it is called.
Buffers
auto Buffers() -> sdk::Buffers &
Memory you own that the SDK writes each frame into, for zero-copy hand-off.
Buffers
auto Buffers() const -> const sdk::Buffers &
Motion
auto Motion() -> sdk::Motion &
Temperature-band motion detectors, and what they observe.
Motion
auto Motion() const -> const sdk::Motion &
Recorder
auto Recorder() -> sdk::Recorder &
Recordings, still images, and the files that travel with them.
Recorder
auto Recorder() const -> const sdk::Recorder &
Radiometry
auto Radiometry() -> sdk::Radiometry &
How radiation becomes a temperature: emissivity, the air in between, and where those values come from.
Radiometry
auto Radiometry() const -> const sdk::Radiometry &
GetRadiation
auto GetRadiation() const -> RadiationConfig override
The radiation parameters in force, as Radiometry().Get()` reports them.
On the FrameSource seam because a recording answers the same question about the frames it delivers, and generic code asks the source rather than the camera. Setting stays on Radiometry(): only a live camera can be told to measure differently.
Detector
auto Detector() -> sdk::Detector &
Keeping the detector honest: how it is held at temperature, and when the shutter closes to re-reference it.
Detector
auto Detector() const -> const sdk::Detector &
Processing
auto Processing() -> sdk::Processing &
What happens to a frame between the sensor and you.
Processing
auto Processing() const -> const sdk::Processing &
Canvas
auto Canvas() -> sdk::CanvasControl &
Where this camera's frame sits in view space.
Canvas
auto Canvas() const -> const sdk::CanvasControl &
Device
auto Device() -> sdk::DeviceControl &
The camera as a device on a plant: network settings and the fail-safe.
Device
auto Device() const -> const sdk::DeviceControl &
GetConfig
auto GetConfig() const -> ImagerConfig override
This camera's whole configuration, as one record.
Everything SaveConfig() writes, without the file: the measurement parameters, the temperature range, the palette and any custom colour table, the output directory, the motion zones, the colour windows, the canvas placement, the measuring regions and the alarm rules. Hand it back to ApplyConfig() to restore it.
This is the shape to save and restore configuration in. Setting-by-setting save and restore cannot be complete -- a setting added in a later version is silently absent from it, and nothing tells the caller -- whereas a record grows with the SDK and a caller that round-trips one never has to be revisited.
ApplyConfig
void ApplyConfig(const ImagerConfig &config)
Apply a whole configuration record.
This replaces the measuring regions, the alarm rules, the motion zones, the colour windows and the canvas placement, the same way LoadConfig() does. Region ids are reassigned on the way in.
All-or-nothing from the caller's point of view: it either returns, having applied everything, or throws, having said nothing about where it got to. Prefer the overload below, which reports.
ApplyConfig
auto ApplyConfig(const ImagerConfig &config, const ConfigLoadOptions &options) -> ConfigLoadReport
Apply a whole configuration record, and say what it did.
The in-memory half of LoadConfig(), through the same three phases and the same staged applier: what cannot work on this camera is decided while nothing has moved, and only then is anything applied. So the common failure -- a record carrying a temperature range this model has not got -- comes back as ConfigLoadOutcome::kAppliedWithOmissions with the range named, rather than as a camera left holding another model's emissivity.
ConfigLoadReport::present is ConfigSection::kAll: a record always carries every section, because an empty regions means "no
regions" and not "this section is absent". That is the one way it differs from a file, where a section can genuinely be missing.
Parameters
| Name | Description |
|---|---|
options |
ConfigLoadOptions::require_matching_serial is honoured against ImagerConfig::serial, which GetConfig() fills in. A record with an empty serial is never refused by it. |
Returns: what it did.
See also: ConfigLoadReport
Exceptions
| Name | Description |
|---|---|
ConfigLoadException |
if the record was refused for this camera, or if applying it stopped part-way. Read its report() before deciding whether to re-read your settings. |
SaveConfig
void SaveConfig(const std::string &path)
Export this camera's configuration to path, as JSON.
Writes path and nothing else. Until v12 this also rewrote the SDK's own per-camera archive on this machine -- a second file, in a directory the caller never named, which the SDK then reloads the next time that camera is opened. So an export changed how the camera would behave on the next run. It no longer does; SaveDeviceConfigArchive() is that write, by its own name, for the callers that want it.
The file covers the measurement parameters, the temperature range, the palette (including a custom colour table, as colours rather than a name), the output directory, the motion zones, the colour windows, the canvas placement, the measuring regions and the alarm rules. It records this camera's serial, which LoadConfig() can be asked to check.
Written whole or not at all: the JSON goes to a sibling .partial file which is flushed, closed and then renamed over path. An interrupted export therefore cannot leave a truncated file where a good one used to be.
Parameters
| Name | Description |
|---|---|
path |
where to write. Must not be empty, and its directory must exist -- this creates the file, not the directory. |
Exceptions
| Name | Description |
|---|---|
IoException |
if path is empty, if the file cannot be written, or if the rename into place fails. The previous contents of path are intact in every one of those cases. |
SaveDeviceConfigArchive
void SaveDeviceConfigArchive()
Write the SDK's own per-camera archive for this camera.
Nothing to do with SaveConfig(): this is the host-side XML the SDK keeps per serial number under the user's application data, and reloads the next time that camera is opened. Calling it is how a program says "remember these settings for this camera", which is the only thing the write inside SaveConfig() was ever doing.
It is not a write to the camera's memory or EEPROM, whatever the v11 documentation said. Move the camera to another machine and none of this goes with it.
Does nothing on a simulated camera and on playback, neither of which has an archive.
Exceptions
| Name | Description |
|---|---|
IoException |
if the archive could not be written, or DeviceException if the camera is not connected. |
LoadConfig
auto LoadConfig(const std::string &path) -> ConfigLoadReport
Import a configuration file and apply it to this camera.
Returns: what it did: which sections the file carried, which are now in effect, and a sentence for a person. See ConfigLoadReport. A caller that ignores the return value gets the behaviour it always had.
This replaces the measuring regions, the alarm rules, the motion zones, the colour windows and the canvas placement. Anything added since the file was written is discarded, and region ids are reassigned on the way in.
Everything that can be checked before the camera is touched is checked before the camera is touched -- a temperature range this model does not offer is the usual one -- so a file that cannot work here is refused with nothing changed rather than applied half-way. A failure the SDK could not foresee still stops part-way, and ConfigLoadException::report() then names exactly what took effect.
Exceptions
| Name | Description |
|---|---|
IoException |
if the file cannot be read or is not JSON. Nothing was changed. |
ConfigLoadException |
if the file was refused for this camera, or if applying it stopped part-way. Read its report() before deciding whether to re-read your settings. |
LoadConfig
auto LoadConfig(const std::string &path, const ConfigLoadOptions &options) -> ConfigLoadReport
Import a configuration file, with a say in what is refused.
The overload to use when the file is a backup of this camera rather than a template for a line of them: set ConfigLoadOptions::require_matching_serial and a file from a different camera is refused outright, with both serials named, instead of being applied until some setting the other model has and this one has not.
See also: LoadConfig(const std::string &)
SetOrientation
void SetOrientation(const Orientation &orientation) override
Rotate and mirror the image. Applied to the thermal data at the end of the pipeline, before anything measures it, so there is only ever one coordinate system: regions are authored in the oriented frame and need no mapping.
Rotation is applied FIRST, then the mirror. The two do not commute -- 90 degrees then a horizontal mirror is not a horizontal mirror then 90 degrees -- so the order is part of the contract, not an implementation detail.
Settable while streaming. A mounting angle is discovered by looking at the picture, so requiring a restart would be hostile.
A quarter turn moves pixels without changing them, so every measured temperature is bit-identical to the unrotated frame.
Warning: On a 90 or 270 degree turn this SWAPS the reported dimensions: a 640x480 camera reports 480x640, and every buffer sized from GetWidth()/GetHeight() -- textures, recording headers, snapshot writers -- has to follow. Check for the swap rather than assuming the frame size is fixed for the session.
Exceptions
| Name | Description |
|---|---|
ConfigException |
if the rotation is not 0, 90, 180 or 270, or if Resampling::kWeighted is asked for. |
imager->SetOrientation({.rotation_deg = 90.0F, .mirror = Mirror::kHorizontal});
GetOrientation
auto GetOrientation() const -> Orientation override
IsSimulated
auto IsSimulated() const -> bool
Whether this is a simulated camera rather than a real one.
The question GetSimulatedOptions() and UpdateSimulatedScene() answer by throwing, offered separately so a user interface can decide whether to show a scene panel without provoking an exception to find out.
GetSimulatedOptions
auto GetSimulatedOptions() const -> SimulatedConfig
What this simulated camera is currently drawing.
Every field resolved to what the camera is actually doing, so read-modify-write works: take this, change a scene field, pass it to UpdateSimulatedScene().
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera. |
UpdateSimulatedScene
void UpdateSimulatedScene(const SimulatedConfig &options)
Point a running simulated camera at a different scene.
Takes effect on the next frame, with no reconnect: regions, alarm rules, recording and every open handle survive it. That is the point -- switching a virtual camera from a gradient to a hot spot used to mean closing it, opening another and replaying everything that had been configured on the first.
Only the scene may move. SimulatedConfig marks which fields are fixed for the life of the camera and says why for each; a fixed field that differs from the running value is refused by name rather than ignored, so a control wired to the wrong call says so instead of appearing to work.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if this is a real camera. |
ConfigException |
if a fixed field differs from the running value, naming the field, if the requested pattern is TestPattern::kFromFile on a camera created without a frame file, or if SimulatedConfig::frame_cycle_steps is neither zero nor in kFrameCycleMinSteps..kFrameCycleMaxSteps. A refused update changes nothing. |
SetSimulatedHotSpot
auto SetSimulatedHotSpot(Vec2 position) -> bool
Pin the simulated hot spot at position, overriding its automatic motion.
A convenience over UpdateSimulatedScene() for the one scene control that gets moved continuously (by a mouse drag, or by a test walking it across a limit), where a read-modify-write of the whole config per step would be clumsy. Returns false rather than throwing on a camera with no hot spot to place: a real one, or a simulated one drawing a gradient.
Coordinates are frame-normalized isotropic, the same space regions use (see region.h), so a position taken from a region's centre places the spot inside that region without conversion. Safe to call while streaming; takes effect on the next frame.
ClearSimulatedHotSpot
auto ClearSimulatedHotSpot() -> bool
Let the hot spot move on its own again.
GetSimulatedHotSpot
auto GetSimulatedHotSpot() const -> std::optional< Vec2 >
Where the hot spot is now, pinned or moving, in the same coordinates. Empty on a camera that has no hot spot, so a caller can use this to decide whether to offer the control at all.
GetDeviceInfo
auto GetDeviceInfo() const -> const DeviceInfo &override
Who this camera is and what it can do: serial, model, type, resolution, frame rate, revisions, capabilities.
These do not change while a camera is connected, so this returns a reference to a cached record rather than rebuilding one per call. It is refreshed on connect and whenever the operation mode changes, which is the only thing that alters the resolution.
This replaces nine individual getters. GetWidth() and GetHeight() survive alongside it because frame geometry is read on essentially every frame by every caller, and GetDeviceInfo().width` reads worse in the one place that is written most often.
GetWidth
auto GetWidth() const -> uint32_t override
Frame dimensions AS ORIENTED. On a 90 or 270 degree rotation these are the sensor's swapped: a 640x480 camera reports 480x640. Size buffers, textures and file headers from these.
GetHeight
auto GetHeight() const -> uint32_t override
GetSensorWidth
auto GetSensorWidth() const -> uint32_t override
The sensor's own dimensions, unaffected by orientation.
Needed by anything that stores or reasons about the frame BEFORE orientation -- the recorder writes sensor-native frames, so its stream header is sized from these. Applications displaying or measuring want GetWidth()/GetHeight() instead.
GetSensorHeight
auto GetSensorHeight() const -> uint32_t override
GetTelemetry
auto GetTelemetry() const -> Telemetry override
What the camera is doing right now: shutter and housing temperatures, shutter state, NUC progress, focus position.
Unlike GetDeviceInfo() this is a live reading and is built per call.
Not every field of Telemetry can be filled today -- the frame counters, calibration state, bad-pixel counts and external-sync fields have no source in the current engine and are left at their defaults. See Telemetry in optris/sdk/telemetry.h.
GetEffectiveAmbientTemperature
auto GetEffectiveAmbientTemperature() const -> std::optional< float > override
The ambient temperature the measurement is actually using, in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit).
RadiationConfig::ambient_temp_c reports what was configured, in both modes. While RadiationConfig::estimate_ambient is set the camera works the ambient out from its own housing probe instead, and that estimate -- not the configured value -- is what the energy table is built from. This returns whichever one is in force, so a display can say what the measurement is based on.
Equal to the SignalField::kAmbientTemp device signal by construction: both report the value that arrived on the most recent frame's metadata. Use the signal to have an alarm rule watch it, and this when you just want to read it.
nullopt before the first frame, and while estimation is off with no ambient ever configured. Show nothing rather than a default no measurement used.
Note: With estimation on the value steps rather than drifts: the pipeline refolds its energy table only when the estimate moves by 0.1 K or more, and this reports the value in force, not a fresh calculation from the current housing temperature.
Protected attributes
impl_
std::unique_ptr< Impl > impl_
Protected static functions
TearDown
static void TearDown(std::unique_ptr< Impl > impl) noexcept
The teardown ~Imager() performs, as a function, so that it can be run somewhere other than on the destroying thread when the destroying thread is one it must not run on. See ~Imager().
Protected functions
WithProcessingAdapter
bool WithProcessingAdapter(const std::function< void(optris::ProcessingAdapter &)> &fn)
Calls fn with the processing chain under the legacy imager, and returns whether it did. False for an imager that has none (playback, and anything not backed by IRImagerNative), and false while an automatic reconnect has the camera closed. Protected so a Player can say so.
This used to hand back the pointer. An automatic reconnect destroys that object on the SDK's watcher thread, so a caller that held it -- for one statement or for a frame -- was calling into freed memory. The call now runs inside a fence the teardown cannot pass, which is only possible if the call stays here.
Warning: fn must touch the adapter and nothing else. The thread tearing the adapter down holds the imager's API mutex while it waits for this fence, so an fn that reaches back into the imager deadlocks. Copy out what you need and use it afterwards.
Imager
Imager()
Builds the sub-interfaces and the bridge, and nothing else. The imager is not attached to a camera until Connect() is called, and Start() on an unattached imager throws.
Connect
void Connect(const ImagerConfig &config)
Attach this imager to a camera, the way Create() does.
This is what makes deriving from Imager work. The class is polymorphic with a protected constructor so it can be subclassed -- see the example at the top of this file -- but the constructor alone leaves the backend unattached, so a subclass has to call this before Start().
Exceptions
| Name | Description |
|---|---|
DeviceException, CalibrationException, ConfigException. |
Connect
void Connect(const SimulatedConfig &config)
Attach this imager to the built-in synthetic camera. Needs no hardware, so it is what a subclass can be tested against.
RequireConnected
void RequireConnected(const char *operation) const
Throw a DeviceException naming operation if no backend is attached, rather than dereferencing a null one.
ProcessRegionsAndAlarms
void ProcessRegionsAndAlarms(const ThermalFrame &frame)
Measure every region against frame, publish its signals and device telemetry, and evaluate the rules.
Called from the frame dispatch. Player runs the same pass over its own bridge, which is what makes a replayed frame measure and alarm exactly as a live one.
RefreshDeviceInfo
void RefreshDeviceInfo()
Re-reads the cached DeviceInfo from the device. Called after connecting and after any operation-mode change.
StartReconnectWatcher
void StartReconnectWatcher()
Start the thread that watches for a drop and re-opens the camera. One per imager, owned by the imager, and stopped by DisableAutoReconnect() and by the destructor before anything else.
PublishReconnectEvent
void PublishReconnectEvent(const ReconnectEvent &event)
Deliver one ReconnectEvent to the application's handler.
IsOnReconnectWatcherThread
auto IsOnReconnectWatcherThread() const -> bool
Whether the calling thread is this camera's reconnect watcher.
The question behind every refusal in the reconnect API: that thread is the one a stop, a restart or a teardown would have to join, and a thread cannot join itself. It covers the reconnect handler, the attempt veto, and -- which the publisher flag did not -- a connection status handler that an attempt published.
EnableAutoReconnectWithCallbacks
void EnableAutoReconnectWithCallbacks(const ReconnectConfig &config, ReconnectAttemptCallback on_attempt, ReconnectSuccessCallback on_success, ReconnectFailureCallback on_failure)
The process-wide EnableAutoReconnect() reaches the per-imager one through here, because the three legacy callbacks it carries are not part of the per-camera API.
Friends
ImagerRegistry
struct ImagerRegistry
Registry of the open imagers in this process, for the free functions in device_enumerator.h. Weak, so being registered never keeps a camera open.
Recorder
class Recorder
ImagerAccess
struct ImagerAccess