optris::sdk::FrameSource
Something that produces thermal frames and measures them.
This is the only polymorphic seam in the v12 API, and it exists for one substitution: a recording standing in for a live camera. Imager implements it, and so does Player.
It is deliberately small. An earlier shape made playback a subclass of the camera, which forced it to override 112 methods -- 48 of them no-ops or hardcoded constants -- because the base class demanded shutter triggers, focus motors and NUC cycles from a file. Anything that only one of the two can do is not here: it is on Imager (a lens, a shutter, a network port) or on Player (seeking, speed, looping).
Write against this when your code does not care where frames come from -- a viewer, a recorder, an inference pipeline. Take an Imager & or a [Player](/documentation/sdks/otc-sdk/v12.0/api/classes/optris.sdk.player) & when you need something only one of them has.
Public types
ThermalCallback
std::function< void(const ThermalFrame &)> ThermalCallback
BgraCallback
std::function< void(const BgraFrame &)> BgraCallback
ConnectionCallback
std::function< void(bool connected)> ConnectionCallback
Public functions
~FrameSource
~FrameSource()
FrameSource
FrameSource(const FrameSource &)=delete
operator=
auto operator=(const FrameSource &) -> FrameSource &=delete
Start
void Start()=0
Stop
void Stop()=0
IsRunning
auto IsRunning() const -> bool=0
AcquireFrame
auto AcquireFrame(std::chrono::milliseconds timeout) -> ThermalFrame=0
Exceptions
| Name | Description |
|---|---|
CaptureException |
on timeout or error. |
TryAcquireFrame
auto TryAcquireFrame() -> std::optional< ThermalFrame >=0
SetThermalCallback
void SetThermalCallback(ThermalCallback callback)=0
SetBgraCallback
void SetBgraCallback(BgraCallback callback)=0
SetConnectionCallback
void SetConnectionCallback(ConnectionCallback callback)=0
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 &=0
For a recording this is the camera that made it, read from the file's own metadata.
GetWidth
auto GetWidth() const -> uint32_t=0
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=0
GetSensorWidth
auto GetSensorWidth() const -> uint32_t=0
The sensor's own dimensions, unaffected by orientation.
GetSensorHeight
auto GetSensorHeight() const -> uint32_t=0
SetOrientation
void SetOrientation(const Orientation &orientation)=0
Rotate and mirror the frames this source delivers.
On the seam rather than on Imager alone because it is a property of any frame source: a camera turns its picture the right way up, and a recording -- which stores sensor-native frames plus the setting they were made with -- turns its own on replay.
GetOrientation
auto GetOrientation() const -> Orientation=0
GetFrameCount
auto GetFrameCount() const -> uint64_t=0
Frames delivered since the source started.
GetDroppedFrameCount
auto GetDroppedFrameCount() const -> uint64_t=0
Frames this source's pull queue discarded because a consumer did not keep up.
Counts exactly that and nothing else. It says nothing about frames a camera never sent, frames lost in a 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.
On the seam, and pure, because all three sources have the same queue and the same failure: each hands frames to AcquireFrame()/TryAcquireFrame() through a fixed-depth queue that discards on overflow rather than blocking, because blocking would stall the thread behind it -- an acquisition thread, a decode thread, a still's delivery timer. A consumer slower than delivery therefore receives a subset and this is the only way to find out. Measured on a recording: a 240-frame take pulled by a consumer spending 200 us a frame, less than writing a PNG costs, delivered 50 frames and dropped 190.
Pure rather than defaulted to zero, deliberately, for the reason GetFrameCount() beside it is: a source that inherited a zero would report "nothing was lost" without having counted, and a plausible zero over real loss is the thing this call exists to prevent. That is not hypothetical -- StillSource discarded silently with no counter at all.
Cumulative, and never reset by Start() or Stop(): a count that rewound could not answer "did this session lose anything". Take a difference across the span you care about. Imager::ResetStatistics() zeroes a camera's, and is the only thing that does.
Note: The callback paths do not drop. SetThermalCallback() and SetBgraCallback() are invoked for every frame, and a slow callback slows the source rather than losing frames. This counter says nothing about them.
Note: Which frame is lost is not the same on all three, and only a camera lets you choose. Imager honours Imager::SetFrameQueuePolicy() and defaults to FrameQueuePolicy::kDropOldest, so a pull returns one of the most recent frames. Player and StillSource have no policy: they keep what is queued and lose the arriving frame, which is kDropNewest behaviour. A slow consumer therefore gets an older subset out of a replay than out of a camera. Stated here rather than quietly equalised -- a replay's eviction order is shipping behaviour and changing it is not this call's business.
GetRadiation
auto GetRadiation() const -> RadiationConfig=0
The radiation parameters that apply to the frames this source delivers: emissivity, transmissivity, and the ambient the measurement is configured against.
For a camera these are the settings in force -- the same record Imager::Radiometry().Get()` returns. For a recording they are the parameters the file was made with, parsed out of its own metadata, and they are what every temperature in it was already computed from.
HasRadiation
auto HasRadiation() const -> bool
Whether this source states the three values above, or whether they are the struct's own defaults standing in for an answer.
GetRadiation() hands back plain floats, so "this recording was
made at an emissivity of 1.0" and "nothing was ever written and
the struct default stands" are the same bytes and different facts. This is what tells them apart.
True for a camera, always: a camera has parameters in force whether or not anybody has changed them, and 1.0 / 1.0 / 20 C is what it would be measuring with.
For a recording or a still it reports whether the file itself states all three -- the emissivity, the transmissivity and the ambient. False for a v11 recording, for one from another writer, and for any file whose metadata is silent about them; and then GetRadiation()'s answer describes nothing that was ever recorded. It must not be shown as the file's own, and must not be written into a snapshot taken from the replay -- a snapshot carries no radiometry at all rather than a plausible one.
All three or nothing, deliberately. The getter returns them as one struct and a caller cannot act on a partial yes, so a file stating two of the three reports false rather than inviting the third to be believed. No writer in this SDK produces such a file -- the recording controller, rec::Recorder and the snapshot writer all write the three together -- so this is the conservative answer to a case that has no producer, not a loss of information: the metadata document keeps each field as its own std::optional and a caller needing them individually reads it.
What this is not: What this is not It is a fact about the file, not about the parameters currently in force, and Player::ApplyConfig() does not move it. An application that overrides a replay's global emissivity changes what the frames are re-derived at; it does not change what the recording says it was made with, which is what a caller labelling a replay wants to know. For "the file's own figures, exactly", read them off GetRadiation() before applying anything.
Note: Not a two-call race, and the pairing is deliberate rather than inherited. On a Player and a StillSource both this and GetRadiation() answer out of state written once while the file is being opened and never written again, so there is no window between the pair for anything to move in. That is what makes the shape safe here and did not make it safe on ColorScaleFilter, where the equivalent pair was deleted: that one was mutated by the frame thread on every frame, so every two-call sequence was a window, and a thread sanitiser reported 13,048 of them in one process. A Has.../Get... pair is not the defect; an unsynchronised mutation behind it is.
GetTelemetry
auto GetTelemetry() const -> Telemetry=0
What the source reports alongside the frames: the shutter and housing temperatures, the frame counter, the temperature range.
Live from the camera, or replayed from the recording's own per-frame record -- the temperatures the camera reported when the file was written, not this machine's.
GetEffectiveAmbientTemperature
auto GetEffectiveAmbientTemperature() const -> std::optional< float >
The ambient temperature the measurement is actually using, in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit).
GetRadiation().ambient_temp_c reports what was configured. With RadiationConfig::estimate_ambient set, the camera works the ambient out from its own housing probe and that estimate -- not the configured value -- is what the energy table is built from. This reports whichever is in force, so a display can say what the measurement is based on.
A recording answers too, and has to: the configured value it reports is the ambient in force when the recording started, and with estimation on the camera reworks its estimate as the session goes -- so a long recording ends on a different ambient than it began with, and nothing could tell the two apart. This reports the ambient the frame now standing was measured against, out of the per-frame record, falling back to the file's one value for a recording written before that was stored.
nullopt before the first frame, and on a source with no ambient in force at all. Show nothing rather than a default no measurement used.
Equal to the SignalField::kAmbientTemp device signal by construction, on every kind of source: both report the value that arrived on the most recent frame's metadata.
The default is nullopt, for a source that measures nothing of its own -- a still opened from a saved snapshot answers from its document rather than from a frame.
GetConfig
auto GetConfig() const -> ImagerConfig=0
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.
HasTemperatureRange
auto HasTemperatureRange() const -> bool
Whether this source states the measurement range GetConfig() reports in temp_range_min/temp_range_max, or whether those are the record's own defaults standing in for an answer.
The same shape as HasRadiation() and for the same reason: the range comes back as two plain integers, so "this recording was
made in -20..100 C" and "the file never said and the default
stands" are the same bytes and different facts. This is what tells them apart.
True for a camera, always: a camera is measuring in some range whether or not anybody selected it.
For a recording or a still it reports whether the file itself states the range. False for a v11 recording, for one from another writer, and for any file whose documents are silent about it; and then the -20..100 C GetConfig() reports is this SDK's own default rather than anything that was recorded. Do not draw a scale bar against it and do not label a replay with it -- show nothing instead, exactly as for an unstated emissivity.
Both bounds or neither, deliberately, for the reason HasRadiation() gives at greater length: a caller cannot act on half a range, so a file stating a minimum and no maximum reports false rather than inviting the other bound to be believed. No writer in this SDK produces such a file. A caller needing the two individually reads the metadata document, where each is its own std::optional.
Why this exists where RecordedOperationModes() needed no: Why this exists where RecordedOperationModes() needed no equivalent Player::RecordedOperationModes() already refuses to fill a mode's range from the defaults, on the grounds that "a mode stating -20..100 because nothing was written would be the mode reporting on something it cannot see". That is this question, answered there by leaving the mode's bounds at zero. GetConfig() cannot do the same -- its range is two plain ints a camera fills meaningfully, and zero is a plausible bound -- so it keeps reporting the default and this reports whether the default is all there is.
Note: A fact about the file, not about what is in force, and not moved by Player::ApplyConfig(). Answered out of state written once while the file is being opened and never written again, so the pairing with GetConfig() has no window in it -- see the note on HasRadiation() for why that is the thing that matters about a Has.../Get... pair.
SetPalette
void SetPalette(Palette palette)=0
GetPalette
auto GetPalette() const -> Palette=0
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)
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()
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 >
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)=0
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 > >=0
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)=0
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=0
The mode SetAutoScaleMode last set.
SetColorScaleDynamics
void SetColorScaleDynamics(const ColorScaleDynamics &dynamics)=0
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=0
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 > >=0
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 &=0
Regions
auto Regions() const -> const RegionEngine &=0
Alarms
auto Alarms() -> RuleEngine &=0
Alarms
auto Alarms() const -> const RuleEngine &=0
Protected functions
FrameSource
FrameSource()
FrameSource
FrameSource(FrameSource &&) noexcept
operator=
auto operator=(FrameSource &&) noexcept -> FrameSource &