OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::StillSource

Opens a saved snapshot as a source of frames that can be measured.

A still written by this SDK is a measurement, not a picture of one: it carries the temperatures and the settings they were computed at. This is what turns that file back into something an operator can interrogate -- open it, drop a measuring area on it, and read what the temperature was. It is the third implementation of FrameSource, beside Imager and Player, so regions, alarms, palettes and colour scaling all behave exactly as they do on a camera.

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

One frame, delivered as often as a camera would: One frame, delivered as often as a camera would A still has exactly one frame, and that frame never changes. It is still delivered repeatedly while the source is running -- as a camera pointed at an unchanging scene would -- so that code written against FrameSource needs no special case, and so that a region added or moved after Start() is measured without anything having to be restarted. GetFrameRate() is how often; Refresh() delivers one immediately and synchronously, which is what a program that is not streaming should use.

What a still cannot do, and says so: What a still cannot do, and says so - Only temperature stills open. A raw-ADU or energy file holds uncalibrated counts with no radiometric model beside them, so there is nothing to measure. Open() refuses it by name rather than producing plausible numbers. Use rec::Snapshot::LoadRaw() for the counts themselves. - A CSV is not a still source. It carries no metadata document, so it cannot say what its numbers mean. - A region's own emissivity is not applied. See HonoursRegionEmissivity().

See also: rec::Snapshot for reading a still's metadata without opening it as a source

See also: Player for the same substitution over a recording

Inherits from optris::sdk::FrameSource.

Public static functions

Open

static auto Open(const std::string &path) -> std::unique_ptr< StillSource >

Open a PNG or TIFF snapshot as a measurable frame source.

Parameters

Name Description
path A still written by this SDK. The format is detected from the file's content, not from its extension.

Exceptions

Name Description
IoException if the file cannot be read, or carries no otc:meta document -- which is how a file from before this format, or from another program, is recognized.
FeatureNotSupportedException if the file holds raw detector counts or energy rather than temperature.

Public functions

~StillSource

~StillSource() override

GetPath

auto GetPath() const -> const std::string &

The file this source was opened from.

GetMetadata

auto GetMetadata() const -> const rec::FileMetadata &

The whole metadata document the file carries -- the pixel scale, the scene statistics, the capture telemetry, the regions and anything the writer merged in.

GetRecordedRender

auto GetRecordedRender() const -> std::optional< rec::RenderMeta >

What the colours meant when the still was taken, when it records it. Absent on a greyscale still, which was never coloured.

HonoursRegionEmissivity

auto HonoursRegionEmissivity() const -> bool

Whether a per-region emissivity reaches the numbers.

A property of the file, asked of the file that was opened. Honouring Region::emissivity means undoing the radiometric correction the pipeline already made and redoing it at a different emissivity, and both directions go through the camera's own characteristic curve. A still holds finished temperatures, so that curve is the one thing needed to invert them -- and the SDK writes it into every still it saves from a camera that has one.

True when this still carried its curve. The region is then resolved by the same object a live camera resolves it with, over a table of the same kind, so it reports what the camera that took the picture would have reported. The picture itself is never corrected -- there is no pipeline here to correct it -- so such a region reports RegionEmissivityState::kReadingOnly.

False for a still written before the curve was carried, for one saved by a source that has no curve, and for one whose curve cannot be inverted. The region then reads at the camera's own emissivity, RegionEmissivityState::kCameras says so, and a warning names the first such region. That is reported rather than ignored because the alternative is a region that reads exactly as if it had no emissivity of its own while claiming to have one -- a measurement error that looks like a working feature.

The camera's emissivity -- the one every pixel in the file was computed at -- is recorded either way and is what GetRadiation() returns.

Refresh

void Refresh()

Measure and deliver the still once, now.

Runs the region and alarm pass over the frame and fires the callbacks, on the calling thread, whether or not the source is running. This is the call for a program that wants an answer rather than a stream: add a region, Refresh(), read the statistics.

SetFrameRate

void SetFrameRate(float hz)

How often a running source re-delivers its frame, in Hz. Defaults to 10. Has no effect on Refresh().

GetFrameRate

auto GetFrameRate() const -> float

The re-delivery rate in force, in Hz.

Start

void Start() override

Begin re-delivering the still at GetFrameRate(), on a thread of the source's own, exactly as a camera pointed at an unchanging scene would.

Stop

void Stop() override

Stop re-delivering. The still itself stays open and Refresh() goes on working.

IsRunning

auto IsRunning() const -> bool override

Whether the source is re-delivering. A still that is not running is still a still, and still measurable through Refresh().

AcquireFrame

auto AcquireFrame(std::chrono::milliseconds timeout) -> ThermalFrame override

Exceptions

Name Description
CaptureException on timeout or error.

TryAcquireFrame

auto TryAcquireFrame() -> std::optional< ThermalFrame > override

Take a delivered frame, or nothing. Never waits.

A still delivers only while it is running, or once per Refresh(). This takes from what has been delivered, so it returns std::nullopt on a still that has been opened and neither started nor refreshed -- exactly as a camera that has not been started does. Call Refresh() first for a single frame, or Start() to have them delivered at GetFrameRate().

It is not "never empty". A still always has a frame on disk, but the queue is empty until something delivers into it.

SetThermalCallback

void SetThermalCallback(ThermalCallback callback) override

Called with the still's frame on every re-delivery, and once per Refresh(). Pass nullptr to stop delivery.

SetBgraCallback

void SetBgraCallback(BgraCallback callback) override

Called with the colorized still on the same occasions, drawn with the palette and colour range in force.

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.

GetDeviceInfo

auto GetDeviceInfo() const -> const DeviceInfo &override

The camera that took the still, read from the file's own metadata.

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.

GetHeight

auto GetHeight() const -> uint32_t override

Height of the still in pixels, after the orientation set here.

GetSensorWidth

auto GetSensorWidth() const -> uint32_t override

The sensor's own dimensions, unaffected by orientation.

GetSensorHeight

auto GetSensorHeight() const -> uint32_t override

Height of the still as it was stored, before any orientation.

SetOrientation

void SetOrientation(const Orientation &orientation) override

A still is stored as it was written -- already oriented, because a snapshot records the picture the operator was looking at. The orientation set here is applied on top of that, which is what lets a still be turned the same way a live picture can.

GetOrientation

auto GetOrientation() const -> Orientation override

The orientation applied on top of what the file already holds.

GetFrameCount

auto GetFrameCount() const -> uint64_t override

Frames delivered since the source started.

GetDroppedFrameCount

auto GetDroppedFrameCount() const -> uint64_t override

Re-deliveries discarded because a consumer did not keep up.

A still re-delivers its one frame on a timer, so a consumer slower than SetFrameRate() receives a subset of those re-deliveries, which the eight-deep queue discards. See FrameSource::GetDroppedFrameCount(), including why this is pure on the seam rather than defaulted to a plausible zero.

GetRadiation

auto GetRadiation() const -> RadiationConfig override

The radiation parameters the still was captured with, parsed out of its own metadata. These are what every temperature in the file was already computed from.

A still whose metadata is silent leaves this struct's defaults standing -- 1.0 / 1.0 / 20 C -- and HasRadiation() is what tells that apart from a still genuinely taken at those values.

HasRadiation

auto HasRadiation() const -> bool override

Whether this still states the three values GetRadiation() reports. See FrameSource::HasRadiation() for the full rule.

HasTemperatureRange

auto HasTemperatureRange() const -> bool override

Whether this still states the measurement range GetConfig() reports, or whether that is the record's own -20..100 C default. See FrameSource::HasTemperatureRange() for the full rule.

GetTelemetry

auto GetTelemetry() const -> Telemetry override

The telemetry the camera reported when the still was taken -- the shutter and housing temperatures and the frame counter, as recorded. Absent fields stay at their defaults rather than being invented.

GetConfig

auto GetConfig() const -> ImagerConfig override

This source's whole configuration, as one record.

A camera fills everything it holds; a recording fills what its file carries -- the serial, the radiation parameters, the temperature range, the palette and the measuring regions it was made with. Reading it is symmetric; applying one is not, and lives on the concrete types.

ApplyConfig

void ApplyConfig(const ImagerConfig &config)

Measure this still at a different global emissivity.

The same knob as on a camera, and deliberately the same arithmetic: a camera folds the global value into its energy-to-temperature table, and so does this -- the table is rebuilt from the calibration the file carries, by the camera's own TempTable, and every pixel is re-derived through it. What a region then reports is what the camera would have reported had it been set that way when the picture was taken.

The global knob and a region's own emissivity are different arithmetic, on a still as on a camera. A region's own value is applied algebraically at measure time; the global value goes through the table. Measured on a real PI 640i from emissivity 0.95, the two agree to within 3-10% of the response: 0.40 K at 0.90, but 6.9 K at 0.50, on a correction of +40.7 K. That is the camera's behaviour reproduced, not a defect of replaying from a file.

Asking for the emissivity the file was saved at restores the saved pixels exactly.

Exceptions

Name Description
FeatureNotSupportedException when the still carries no radiometry bundle -- one saved before 12.0, or from a camera with no characteristic curve -- or when its bundle does not reproduce the curve the file also carries. The temperature range is refused always: a different range is a different calibration, and the file holds only the one it was saved in.

Parameters

Name Description
config The configuration to apply. The palette is applied either way; re-colouring a still changes nothing it reports.

SaveSnapshot

void SaveSnapshot(const std::string &path, SnapshotFormat format=SnapshotFormat::kPng, const rec::SnapshotInfo &info={}, const rec::SnapshotOptions &opts={})

Write this still out as a new snapshot.

The same call a camera and a replay have. All three containers Recorder::SaveSnapshot() writes are available: PNG keeps the measurement and the picture, TIFF is the analysis export, CSV is the numbers.

Saves the pixels this source is measuring -- oriented as SetOrientation() asked, and re-derived if ApplyConfig() put a different global emissivity in force. So "open it, turn it, read it at 0.80, save it" produces a file whose temperatures are the ones that were on screen. Unlike a camera and a replay this never reports "no frame captured yet": a still has its frame from the moment it opens, whether or not Refresh() has run.

What goes in the file, and what cannot: What goes in the file, and what cannot The metadata comes from this file's own document, so a field the original did not carry is left out of the new one rather than defaulted -- a snapshot stating an emissivity nobody set cannot be told apart from one stating the emissivity an operator chose. The same list of fields that can be absent applies as for a replay; see Player::SaveSnapshot().

The characteristic curve and the radiometry bundle are carried forward verbatim when this file had them, so the new snapshot can be reopened and measured at another emissivity exactly as this one can. HonoursRegionEmissivity() is how to know in advance whether there is a curve to carry.

Two differences from a live snapshot, both deliberate: Two differences from a live snapshot, both deliberate render.overlays is false -- there is no pipeline here to composite overlays into the picture, so it has none. And attachment providers are not pulled: they are registered on a camera's Recorder and a still has no registry, so what this file carried of its own is carried forward and what your application would have attached live is not. Pass it on info.

What this is not: What this is not Not a way to save an edited snapshot. Measuring areas added or moved here are not written into the new file: the schema's RoiDefinition and the measuring model's Region have no mapping between them in either direction, so SnapshotInfo::rois is filled in by hand or not at all -- on a camera too.

Parameters

Name Description
path Output file path.
format Container to write.
info Extra metadata and attachments. Anything set here wins over what the file would have supplied.
opts Scale and compression settings.

Exceptions

Name Description
IoException if the file cannot be written.
std::invalid_argument for a scale that cannot represent the frame.

SaveSnapshot

void SaveSnapshot(const ThermalFrame &frame, const std::string &path, SnapshotFormat format=SnapshotFormat::kPng, const rec::SnapshotInfo &info={}, const rec::SnapshotOptions &opts={})

Write a frame the application already has to a still.

The overload for a thermal callback. Metadata, attachments and options behave exactly as for the frameless overload.

SaveCsvSnapshot

void SaveCsvSnapshot(const std::string &path, const rec::CsvOptions &csv, const rec::SnapshotInfo &info={})

Write the frame this still is measuring as a CSV snapshot, spelled the way csv asks.

SaveSnapshot() with SnapshotFormat::kCsv, plus the choice of delimiter, decimal separator, how an unmeasured pixel is written and whether the # header lines appear. Metadata is filled in exactly as SaveSnapshot() fills it. A default-constructed rec::CsvOptions writes the same file SaveSnapshot() writes.

Exceptions

Name Description
std::invalid_argument for a spelling rec::CsvOptions documents as refused. Nothing is written then.
IoException on the same terms as SaveSnapshot().

SaveCsvSnapshot

void SaveCsvSnapshot(const ThermalFrame &frame, const std::string &path, const rec::CsvOptions &csv, const rec::SnapshotInfo &info={})

Write a frame the application already has as a CSV snapshot, spelled the way csv asks. Otherwise exactly the frameless overload.

SetPalette

void SetPalette(Palette palette) override

Colour the still with one of the built-in palettes. Affects the BGRA delivery only; the temperatures are what the file holds.

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.

Regions

auto Regions() -> RegionEngine &override

The measuring areas over this still. Identical to a camera's: add one, Refresh(), and read what it measured.

Regions

auto Regions() const -> const RegionEngine &override

The measuring areas, for reading.

Alarms

auto Alarms() -> RuleEngine &override

The alarm rules over this still. They evaluate on every delivery, so a rule fires on a still exactly as it would live.

Alarms

auto Alarms() const -> const RuleEngine &override

The alarm rules, for reading.

SetDisplayTemperatureUnit

void SetDisplayTemperatureUnit(TemperatureUnit unit)

The unit this still shows temperatures in where the SDK turns one into text. A still draws no region overlays, so that is the description line of a JPEG snapshot written from it. Otherwise exactly Imager::SetDisplayTemperatureUnit(): display only. The unit of every number the API takes and returns is SetTemperatureUnit()'s, and until this is called the still draws in that unit.

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.