optris::sdk::Player
Plays a recording back as a source of frames.
A Player is not a camera and does not pretend to be one. It has no shutter to trigger, no focus motor, no NUC cycle and no network port, so it does not carry those methods -- which is the whole difference from what came before. The previous shape made playback a subclass of Imager and it had to override 112 methods to say "not applicable", 48 of them with an empty body or a hardcoded constant.
What it shares with a camera is FrameSource: it starts, stops, produces frames, and measures them. A replayed frame goes through exactly the same region and alarm pass a live one does, so measuring areas, rules, hysteresis and actions all behave identically on a recording.
using namespace optris::sdk; auto player = Player::Open("run.mkv"); player->Regions().Add(Region::Circle({0.5F, 0.375F}, 0.1F)); player->SetThermalCallback([](const ThermalFrame &f) { std::println("max {:.1f} C", f.GetMaxTemperature()); }); player->SetSpeed(2.0F); player->Start();
Inherits from optris::sdk::FrameSource.
Public static functions
Open
static auto Open(const std::string &path) -> std::unique_ptr< Player >
Open an MKV recording.
Exceptions
| Name | Description |
|---|---|
IoException |
if the file cannot be opened. |
OpenSeries
static auto OpenSeries(const std::string &path) -> std::unique_ptr< Player >
Open a multipart recording, from any one of its parts, and replay every part as one recording. Added in 12.0.10.
A recording started with a segment limit is written as run_part000.mkv, run_part001.mkv and so on. Open() replays the one file it is given; this replays the whole recording from its first frame, whichever part it is given. GetDurationUs() and GetPositionUs() are the whole recording's, a seek or a frame number reaches into any part, and regions and alarm rules carry on across each part boundary exactly as they do from one frame to the next. A whole recording opens exactly as Open() opens it.
auto player = Player::OpenSeries("run_part001.mkv"); std::println("{} parts, {} s", player->GetSeriesPartCount(), player->GetDurationUs() / 1'000'000); player->Start();
Exceptions
| Name | Description |
|---|---|
IoException |
if the file cannot be opened, or if a part of the recording is missing. The message names the missing part and the file it should be; open the parts that are there with Open(). |
ReadAttachments
static auto ReadAttachments(const std::string &path) -> std::vector< rec::Attachment >
Read the files carried inside a recording without opening it for playback.
The no-camera, no-transport read: parses the container header and stops, so it costs the same on an hour-long take as on a one-second one. Works on any Matroska file this SDK writes -- a plain recording, one segment of a segmented one, and the multi-camera session file of rec::SessionRecorder, whose own otc-session.json comes back as one of the attachments.
The still-image counterpart is rec::Snapshot::ReadAttachments().
Parameters
| Name | Description |
|---|---|
path |
Path to the .mkv file. |
Exceptions
| Name | Description |
|---|---|
IoException |
if the file cannot be opened, or is not a container this SDK can read. |
Public functions
~Player
~Player() override
GetSeriesPart
auto GetSeriesPart() const -> uint32_t
Which part of a multipart recording is playing, counting from 0: the number in the file's _partNNN suffix. 0 for a single file. Added in 12.0.10.
GetSeriesPartCount
auto GetSeriesPartCount() const -> uint32_t
How many parts this replay holds. 1 for a single file. Added in 12.0.10.
Start
void Start() override
Stop
void Stop() override
IsRunning
auto IsRunning() const -> bool override
AcquireFrame
auto AcquireFrame(std::chrono::milliseconds timeout) -> ThermalFrame override
Exceptions
| Name | Description |
|---|---|
CaptureException |
on timeout or error. |
TryAcquireFrame
auto TryAcquireFrame() -> std::optional< ThermalFrame > override
SetThermalCallback
void SetThermalCallback(ThermalCallback callback) override
SetBgraCallback
void SetBgraCallback(BgraCallback callback) override
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 made the recording, 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
GetSensorWidth
auto GetSensorWidth() const -> uint32_t override
The sensor's own dimensions, unaffected by orientation.
GetSensorHeight
auto GetSensorHeight() const -> uint32_t override
SetOrientation
void SetOrientation(const Orientation &orientation) override
Recordings hold sensor-native frames plus the orientation that was set when they were made; playback applies it. Changing it here re-orients the replay, which a recording of the oriented picture could not have offered.
GetOrientation
auto GetOrientation() const -> Orientation override
GetFrameCount
auto GetFrameCount() const -> uint64_t override
Frames delivered since the source started.
Regions
auto Regions() -> RegionEngine &override
Regions
auto Regions() const -> const RegionEngine &override
Alarms
auto Alarms() -> RuleEngine &override
Alarms
auto Alarms() const -> const RuleEngine &override
SeekToFrame
void SeekToFrame(uint64_t frame_index)
Jump to a frame by zero-based index.
SeekToTimestamp
void SeekToTimestamp(uint64_t timestamp_us)
Jump to the frame nearest a timestamp, in microseconds.
Pause
void Pause()
Stop advancing, holding the current frame and position.
Not Stop(), which ends the run and rewinds: a paused player is still open, still at the frame it was on, and still seekable, so Resume() carries on from there.
This exists because the obvious workaround does not work and cannot be made to. SetSpeed(0) reads as "pause" and the pacing divides the frame interval by the speed, so a speed of zero is a division by zero: the result is infinite, converting it to an integer is undefined, and in practice the sleep comes out negative and the file plays as fast as the disk allows. The v12 demo's transport did exactly that, and the symptom was a space bar that made the recording sprint instead of stopping.
Resume
void Resume()
Carry on from where Pause() stopped. No-op unless running.
IsPaused
auto IsPaused() const -> bool
Refresh
auto Refresh() -> FrameRefreshResult
Re-process the frame now held and deliver it again.
The call for a paused replay whose settings have changed. Pause() halts the decode thread, and a paused player therefore produces nothing: every frame a consumer ever sees is one the decode thread pushed, so changing the emissivity, the orientation or the palette while paused used to leave the picture on screen exactly as it was until the recording was resumed. There was no call on this class that re-delivered it, and seeking to the frame already showing was not one either.
Named as StillSource::Refresh() is, and for the same reason: both are "measure and deliver what you are holding, once, now", and a program reviewing a still and a recording side by side should not have to learn two names for it.
What it re-runs
The whole delivery path, from the frame as the decoder handed it over. The orientation is applied, the global radiation is re-derived if one other than the file's own is in force, the region and alarm pass measures the result, the recorded region record is applied over it, and both callbacks fire. The frame also joins the pull queue, so AcquireFrame() and TryAcquireFrame() see it exactly as they see a decoded one. A caller cannot tell a refreshed frame from a live one, which is the point: nothing downstream needs a second code path.
What it deliberately does not do
- It does not advance the position.
GetFrameCount()andGetPositionUs()are unchanged: the same frame was delivered again, and counting it twice would make a progress bar jump backwards on the next real frame. - It does not re-evaluate the alarm rules. A refresh is the same instant measured again, not a new observation of the scene, and
Condition::on_delayis a duration: evaluating here would let a caller trip a delayed alarm by tapping refresh while the recording stands still. Region statistics are re-measured and republished, so the next real frame evaluates against the new numbers. - It does not move the colour scale. Under an auto-scale mode the range is temporally damped, so re-applying the filter would draw a slightly different picture on every call. A refresh re-uses the range already in force --
GetEffectiveColorRange()-- so repeated calls are idempotent and the picture only changes for a setting the caller changed.
What a recording can and cannot be told after the fact
A .mkv holds finished temperatures by design, so not every setting can reach them. What reaches what is fixed, and none of it is silent:
| Setting | Reaches | How a caller knows |
|---|---|---|
| Global emissivity, transmissivity, ambient | the delivered pixels | CanChangeRadiation(); ApplyConfig() throws when it cannot |
| A region's own emissivity | that region's numbers only, never the picture | HonoursRegionEmissivity(); RegionEmissivityState::kReadingOnly |
| Orientation | the delivered pixels | always, on any radiometric recording |
| Palette, colour range, auto-scale, isotherms, overlays | the picture | always |
| Regions, measuring areas | the numbers | always |
| Temperature range | nothing | ApplyConfig() throws: a different range is a different calibration |
| Size-of-source correction, noise filters, detail enhancement, distortion | nothing | there is no setter for them on this class. They live on Imager::Processing(), and a replay runs no pipeline backend to apply them in |
The last row is the honest shape of it rather than an omission. A refresh cannot quietly honour some of what it was asked for, because the things it cannot honour cannot be asked for here at all; and the one setting a file may refuse -- the global radiation on a recording that carries no radiometry bundle -- is refused by ApplyConfig() when it is set, not swallowed here.
Returns: FrameRefreshResult::kDelivered when a frame went out. See FrameRefreshResult for the three ways nothing happens; none of them throws.
Note: Runs on the calling thread, and the callbacks run on it too -- unlike a decoded frame, which arrives on the decode thread. Do not call it from inside SetThermalCallback() or SetBgraCallback(): the delivery path is serialised, so a handler that refreshes would wait on the pass it is itself inside.
auto player = Player::Open("run.mkv"); player->Start(); player->Pause(); auto config = player->GetConfig(); config.radiation.emissivity = 0.80F; if (player->CanChangeRadiation()) { player->ApplyConfig(config); player->Refresh(); // the picture changes now, not on Resume() }
CanChangeRadiation
auto CanChangeRadiation() const -> bool
Whether this recording's global radiation can be changed and have it reach the delivered pixels.
Ask this instead of calling ApplyConfig() and catching: a user interface wants to grey the emissivity slider out, and an exception is a poor way to discover that. The answer is fixed when the file is opened and never changes.
True when the recording carries a radiometry bundle that reproduces the characteristic curve the file also carries -- both of which come out of the same file, so the check can see what it reports on. The energy each stored temperature came from is then recovered through the carried curve and read back out of a table rebuilt at the new value, which is the table the camera itself would have built. It costs the stored tenth of a kelvin and nothing else: measured, 0.20 K at emissivity 0.90 and 0.30 K at 0.50.
False for a recording written before the bundle was carried, for one from a camera with no characteristic curve, and for one whose bundle does not reproduce its own curve -- which is what a recording whose ambient moved between the table fold and the metadata looks like. ApplyConfig() then throws FeatureNotSupportedException rather than answering from a calibration that does not match the frames.
Says nothing about a region's own emissivity, which goes through the curve alone and needs no bundle: HonoursRegionEmissivity() is that question.
HonoursRegionEmissivity
auto HonoursRegionEmissivity() const -> bool
Whether a per-region emissivity reaches that region's numbers on this recording.
The counterpart of StillSource::HonoursRegionEmissivity(), and the same fact about the same thing: honouring a region's own emissivity means undoing the radiometric correction at the camera's value and redoing it at the region's, and both directions go through the camera's characteristic curve. A recording holds finished temperatures, so that curve is the one thing needed to invert them, and the SDK writes it into every recording made from a camera that has one.
The picture is never corrected either way. A replay runs no pipeline backend, so there is nothing to apply a per-region emissivity map in; such a region reports RegionEmissivityState::kReadingOnly to say exactly that, and a Refresh() after changing it moves the region's statistics and not one pixel. A caller drawing a number beside a measuring area should read the state rather than assume the image agrees with it.
False for a recording written before the curve was carried and for one from a camera that has none. A region then reads at the camera's own emissivity and RegionEmissivityState::kCameras says so, rather than reading as though it had no emissivity of its own while claiming to have one.
IsPicture
auto IsPicture() const -> bool
Whether this recording is a picture rather than radiometry.
A take written as colorized video carries the image only: the palette was applied before it was written and the temperatures are gone. The frames still arrive -- through the BGRA callback -- but nothing measures, so regions report nothing and an alarm cannot fire. Ask before showing a number next to one.
SetSpeed
void SetSpeed(float speed)
Playback speed multiplier: 1.0 is real time, 0.5 is half.
Must be greater than zero. Zero and negative values are rejected with std::invalid_argument rather than accepted and divided by -- see Pause() for what a caller reaching for zero actually wants.
GetSpeed
auto GetSpeed() const -> float
RealFrameRate
auto RealFrameRate() const -> MeasuredFrameRate
How many real frames the replay delivered, over how long.
The same measurement Imager::Processing().RealFrameRate() makes on a camera, with the same window and the same three rates; see MeasuredFrameRate. Only frames delivered by playing are counted: a frame delivered by a seek while paused or stopped, and one re-delivered by Refresh(), are not new measurements. A frame the recording marks FrameMetadata::is_repeated_frame is a repeat here as it was live.
measured_hz and delivered_hz describe wall time and fall to zero across a pause. Start() begins a new measurement.
GetLiveFrameRate
auto GetLiveFrameRate() const -> LiveFrameRate
Real frames per second over the time the replay was playing and the scene was being measured: the frame rate to show a user.
The count RealFrameRate() makes, on a clock that Pause() stops and that leaves out the closures the recording carries (its repeated frames), so a paused replay holds the rate it had and reads the file's rate again straight after Resume(). See LiveFrameRate.
SetLoop
void SetLoop(bool loop)
Restart from the first frame after the last one.
IsLooping
auto IsLooping() const -> bool
GetDurationUs
auto GetDurationUs() const -> uint64_t
How long the recording is, in microseconds.
GetStartTimeUs
auto GetStartTimeUs() const -> uint64_t
When the recording started: the container's creation_time, in microseconds since the Unix epoch (UTC).
For a recording made from a camera this is when the recording began, on the host clock of the machine that made it, to the second. For one converted from an earlier recording (a PIX Connect .ravi through rec::ImportRavi()) it is when the original was recorded, not when it was converted (Recorder::SetStartTime()). For a multipart recording it is when the first part began.
Zero when the file does not say: a file written by something other than this SDK, or with the tag stripped.
Add GetPositionUs() to it for the wall-clock time of the frame on screen.
GetStartTimeZone
auto GetStartTimeZone() const -> rec::RecordingTimeZone
The time zone the recording was made in, beside the UTC start GetStartTimeUs() gives: the recording computer's for a recording of a camera, the one given (or, marked assumed, the one taken) at conversion for one converted from a PIX Connect .ravi. For a multipart recording, the first part's.
known is false for a recording that does not say: one made by an SDK release before this existed, or by another program.
GetLastSeekWalkedFrames
auto GetLastSeekWalkedFrames() const -> uint64_t
How many frames the last seek decoded without delivering them.
A recording this SDK writes is not all-intra, so a seek can only start the decoder at the keyframe at or before its target and the frames between are decoded and discarded; that is what makes a seek frame-accurate, and what stops GetPositionUs() from stepping backward after one. This is what that cost. Zero after a seek that landed on a keyframe, and zero before the first seek.
Counted, not estimated. The alternative is to divide by the declared frame rate and assume the encoder's GOP, and both of those are wrong on a file whose camera did not deliver at the rate the header claims. Use optris::sdk::rec::FrameIndex to learn what a file's keyframe interval is before seeking (it reads packet headers and decodes nothing) and this to learn what a seek actually paid.
The walk is unpaced: it never sleeps, so a seek costs decode time rather than the playback time of the frames it steps over. Measured on a 64x48 take, the walk is three orders of magnitude cheaper than playing the same span; a scrub pays decode, not wall clock.
GetLastSeekReplayedRecords
auto GetLastSeekReplayedRecords() const -> uint64_t
How many region records the last seek replayed without decoding anything.
A seek's second cost, bounded by a different distance from the one above, and the reason there are two numbers rather than one.
The picture reaches back to the video keyframe, because nothing after a keyframe decodes without the frames between. The region state reaches back to wherever it was last known, which can be much further: a region's definition is written on the frame it first appeared on, so walking forward from a keyframe never contains a definition that lies in an earlier keyframe interval, and the region did not appear at all. The records are replayed off the metadata track to close that, with the video stream handed to the demuxer to skip: no decoding, so the cost is the record track's and not the file's.
A seek forward replays only the records between where the state was last known and the target, so a scrub forward is cheap and costs the same per frame crossed however long the file is. A seek backward starts from the beginning of the file: the record is a delta and nothing un-applies one, so the only honest way back is forward from a known state. That makes a backward seek's cost proportional to where it lands, and it is the figure to plan a scrub against on a long recording.
Counted, never estimated: same reason as above.
GetPositionUs
auto GetPositionUs() const -> uint64_t
How far into the recording we are, in microseconds from its first frame.
An offset into the file, which is what SeekToTimestamp() takes: 0 <= GetPositionUs()<=GetDurationUs()` at all times, for every seek target this API accepts. It is not the frame's capture stamp -- ThermalFrame::GetMetadata().timestamp_us is that, and it counts from an epoch of the transport's own, which is what this used to report.
Zero before playback starts, and zero again after Stop(), which rewinds the file.
IsAtEnd
auto IsAtEnd() const -> bool
Whether a non-looping replay has read the file to its end.
The end of a replay, asked rather than inferred. Polling GetPositionUs() against GetDurationUs() was the only way to see it and it cannot be exact: the position is the last frame's start, the duration counts that frame's own length as well, so the two stand one frame period apart on a correct file and never meet. Every consumer therefore had to invent a tolerance, and the real gap can be up to a second -- at which point a 250 ms tolerance means a replay under three minutes never reads as finished at all.
False before playback starts, and false again after Start() or any seek: both of those are somewhere to play from. A replay under SetLoop(true) never sets it, because it never ends.
Stop() leaves it set, which is not an oversight. Stop() on this class halts the decode thread and leaves the file where it is; it does not rewind. A replay that has played out and then been stopped has still played out, and nothing more will arrive until it is seeked or started again -- at which point this goes false. Note that Start() does not rewind either: seek to zero first to replay the recording.
For a caller that pulls: For a caller that pulls This says the file has been read out, not that the pull queue is empty. AcquireFrame() and TryAcquireFrame() may still have frames to hand over after this turns true; drain them rather than stopping on it. A caller driven by the frame callback has already had every frame by then.
GetDroppedFrameCount
auto GetDroppedFrameCount() const -> uint64_t override
How many decoded frames were discarded before reaching AcquireFrame() or TryAcquireFrame().
The pull queue is four frames deep and the decode thread discards on overflow rather than blocking; blocking would stall playback for every other consumer, including the callbacks and the display. So a caller that pulls slower than playback delivers receives a subset of the recording, and until this counter existed there was no way to discover that: the frames that arrived were correct and complete-looking, and the ones that did not simply were not there.
Measured on a 240-frame take with a consumer spending 200 µs a frame (less than writing a PNG costs), 50 frames arrived and 190 were dropped. Anything exporting a frame series should read this and refuse to claim success when it is non-zero, or avoid the problem entirely by not pulling from a running playback: seek to each frame and take it, rather than playing and catching what comes past.
Cumulative from Open(), like the recorder's rec::SessionSourceStats::frames_dropped_backlog which this mirrors. It never decreases, and Stop() does not reset it: a count that rewound with the file could not answer "did this
session lose anything". Take a difference across the span you care about.
The callback path does not drop. SetThermalCallback() and SetBgraCallback() are invoked for every decoded frame, from the decode thread, and a slow callback slows playback rather than losing frames. This counter says nothing about them.
Spelled GetDroppedFrames() in earlier v12 builds. Renamed to the name a camera has always used for the identical question, because the two were one concept under two names and only the camera's was reachable from C, .NET, Python and Rust. See FrameSource::GetDroppedFrameCount().
GetTelemetry
auto GetTelemetry() const -> Telemetry override
The telemetry captured with the current frame: the temperatures the camera reported when the recording was made, not this machine's.
GetRadiation
auto GetRadiation() const -> RadiationConfig override
The radiation parameters in force on this replay.
The file's own until something changes them, which is what every temperature in it was computed from. They can be changed on a recording that carries a radiometry bundle, and this then reports what was asked for rather than what the file holds -- the two are no longer the same question.
Read from the recording's otc-meta.json where it states them, and from its config.json attachment otherwise; a file carrying both is believed on the first, which is the same preference the per-frame ambient follows. A file that states neither leaves this struct's defaults standing -- 1.0 / 1.0 / 20 C, plausible numbers nobody recorded -- and HasRadiation() is the only thing that tells the two apart.
See ApplyConfig() for what may be changed, and CanChangeRadiation() for whether this file allows it.
HasRadiation
auto HasRadiation() const -> bool override
Whether this recording states the three values GetRadiation() reports, or whether they are defaults standing in for an answer.
False for a v11 recording, for one from another writer, and for any file whose metadata is silent -- and then nothing in GetRadiation()'s answer was ever recorded. See FrameSource::HasRadiation() for the full rule, including why a file stating two of the three answers no and why ApplyConfig() does not move it.
HasTemperatureRange
auto HasTemperatureRange() const -> bool override
Whether this recording states the measurement range GetConfig() reports, or whether that is the record's own -20..100 C default standing in for an answer.
False for a v11 recording, for one from another writer, and for any file whose documents are silent about the range -- and then the range reported is this SDK's default and describes nothing that was recorded. Do not draw a replay's scale bar against it. See FrameSource::HasTemperatureRange() for the full rule.
GetEffectiveAmbientTemperature
auto GetEffectiveAmbientTemperature() const -> std::optional< float > override
The ambient the frame now standing was measured against, in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit). The file itself stays Celsius.
The honest counterpart to GetRadiation().ambient_temp_c on a replay. That is the configured ambient, which for a recording is the value in force when the recording started -- and with RadiationConfig::estimate_ambient set the camera reworks its own estimate as the session goes, so a long recording ends on a different ambient than it began with and nothing could say so.
Read from the per-frame record, so it moves with the estimate as it moved. A recording written before the per-frame ambient was stored answers with the file's one value instead, which is the right answer for it: nothing in such a file contradicts it.
nullopt before the first frame, and on a recording that names no ambient at all. Equal to the SignalField::kAmbientTemp device signal, as it is on a camera.
Note: Changing the radiation on a recording that carries a radiometry bundle makes this report the ambient the re-derivation used, which is what was asked for rather than what the file holds -- the same split GetRadiation() describes.
GetRecordedRender
auto GetRecordedRender() const -> std::optional<::optris::sdk::rec::RenderMeta >
What the colours meant at the current frame.
The palette the operator had selected, the two ends of the colour scale in the SDK's temperature unit, and the auto-scale mode that chose them. Under the percentile and sigma modes the range is temporally filtered, so it is neither what the frame's own pixels imply nor what the application last asked for: the file is the only place it can be read from.
This answers for the frame most recently delivered, not for the file as a whole. The recording carries a block per frame wherever the file-level one would be wrong -- which under an auto-scale mode is essentially every frame, because the range genuinely moves -- and this prefers it, falling back to the file's own. A caller therefore never has to know which of the two it got.
Returns: Empty for a recording that does not say: every file written before the recorder recorded this, and any file from another writer. Empty is "the file does not say", never "the defaults" -- a caller that needs to show something can then say so rather than presenting this player's own palette as though it were the one the recording was made with.
GetRecordedFlagPolicy
auto GetRecordedFlagPolicy() const -> std::optional<::optris::sdk::rec::FlagPolicyMeta >
Whether the shutter was held back while this recording was made, and what that cost.
The call to make before trusting a recording's numbers. A shutter cycle is the non-uniformity correction; holding it back buys an unbroken stream and pays in drift, and a recording stores finished temperatures -- so the drift is in these pixels permanently and nothing on replay removes it. A suppressed recording looks exactly like a good one: no gap in the stream, and temperatures that are simply wrong by an amount nobody is told. This is where the file says the amount.
Like GetRecordedRender(), it prefers the current frame's own block and falls back to the file's, so a caller never has to know which it got -- but the two halves say different things here and both are worth reading:
- from the file:
while_recordingandoverride_drift_c, what was configured for the whole recording; - from the frame:
heldanddrift_c, what was happening at the frame most recently delivered. Present only on the frames where a correction was actually refused, so a seek into a healthy stretch of a suppressed recording reports the policy withoutheld.
peak_drift_c and held_frames are never set here. They are a summary of a run, and a replay is not the run -- ask Detector::GetShutterDeferral() on the camera that made it, or take the largest drift_c over the frames.
Returns: Empty for a recording made at the default policy, which is every recording written before the setting existed. Empty is "nothing was suppressed", which for those files is the truth.
GetRecordedGap
auto GetRecordedGap() const -> std::optional<::optris::sdk::rec::RecordingGap >
Whether the frame most recently delivered is on the far side of a hole in this recording.
That a value comes back is the fact: the frames either side of this one are not contiguous, because the camera stopped delivering in between. Two things put such a hole into a file, and both are a camera that stopped delivering: a recording held open across a reconnect (rec::RecordingOptions::hold_open_across_reconnect), and an armed pre-roll that spanned an outage -- the ring is deliberately not cleared when a camera drops, because those frames are real and are the history the application asked to keep.
Per frame, like GetRecordedRender(), but with no file-level half to fall back to: a recording's otc-meta.json is written before its first frame and cannot describe anything that happens afterwards, which is the same reason rec::SeriesMeta has no end time. So a replay has to be at the frame to see it.
Returns: Empty when this frame carries no marker, which is the complete answer rather than an absence: the join here is sound. Every frame of a recording that ran without an outage, and every frame of every recording written before this metadata existed, is in that position.
GetRecordedLossy
auto GetRecordedLossy() const -> std::optional<::optris::sdk::rec::LossyMeta >
What was done to this recording's samples that a lossless recording would not have done.
Why a replay has to be able to answer this: Why a replay has to be able to answer this Because a lossy recording and a lossless one are the same format, the same tracks and the same pixel type, and the difference is invisible in the numbers: a temperature that reads 23.4 C may have been measured as 23.4 C or as 23.37 C. Nothing in the data recovers that, and a measurement whose uncertainty is unknowable is not evidence. max_error_k is the one number to put beside a reading taken from such a file.
Read from the lossy block of otc-meta.json, which the recorder derives from the encoders it actually ran rather than from anything a caller declared.
Returns: Empty for a lossless recording, which is the default and every recording written before the block existed. Empty means lossless; it is not "unknown".
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.
GetAttachments
auto GetAttachments() const -> std::vector< rec::Attachment >
Every file carried inside this recording.
An application that attached its own files while recording -- see Imager::SetAttachmentProvider() -- reads them back here, beside the SDK's own otc-meta.json, device.json and config.json. Telling the two apart is a comparison on rec::Attachment::name.
In container order, which puts otc-meta.json first for every file this SDK wrote. Names are not required to be unique, which is why this is a list rather than a map.
rec::Attachment::compress is false on everything this returns: an MKV attachment stream is stored verbatim, so nothing was deflated on the way in and nothing is inflated on the way out.
Copies every payload out of the open container on each call. Ask once and keep the answer rather than calling it per file.
SaveSnapshot
void SaveSnapshot(const std::string &path, SnapshotFormat format=SnapshotFormat::kPng, const rec::SnapshotInfo &info={}, const rec::SnapshotOptions &opts={})
Write the frame this replay is showing to a still image.
The same call a camera has, on the frame the player has most recently delivered -- the moment an operator found while scrubbing. All three containers Recorder::SaveSnapshot() writes are available here, on the same terms: PNG keeps the measurement and the picture, TIFF is the analysis export, CSV is the numbers.
What goes in the file, and what cannot: What goes in the file, and what cannot The metadata comes from the recording's own document, so the snapshot says what the recording says. A field the recording does not carry is left out rather than defaulted, and that is the whole design here: a file stating an emissivity nobody set cannot be told apart from one stating the emissivity an operator chose, and the second is a measurement.
So a replay snapshot can lack any of these, and a reader must treat each as "not recorded" rather than as zero:
| Can be absent | When |
|---|---|
| emissivity, transmissivity | The recording carried no config.json and no radiometry block -- a v11 file, or one from another writer. |
| ambient temperature | As above, and also whenever the recording itself had none worth writing: a camera estimating ambient with no reading yet, or configured the v11 way. Never the -100 placeholder. |
| measurement range | The recording carried no range block. |
| model, serial, hardware and firmware revision | The recording did not name them. A v11 device.json carries model and serial only. |
| field of view | Carried only since the optic was recorded. |
| the characteristic curve and the radiometry bundle | The recording carried neither -- anything written before 12.0, or from a camera that has no curve. Without them the snapshot can be reopened and read, but not re-measured at another emissivity. |
Two differences from a live snapshot, both deliberate: Two differences from a live snapshot, both deliberate render.overlays is false: region and blob overlays are composited into a picture by the GPU backend alone and a replay has none, so the picture genuinely has no overlays in it. And attachment providers are not pulled -- they are registered on a camera's Recorder and a player has no registry. What the file carries of its own is carried forward; what your application would have attached live is not. Pass it on info.
The picture is drawn in the colours this player is set to now, not the ones the recording was made with, for the same reason a camera writes the picture on screen rather than a second rendering. GetRecordedRender() is how to see the other.
Parameters
| Name | Description |
|---|---|
path |
Output file path. |
format |
Container to write. |
info |
Extra metadata and attachments. Anything set here wins over what the recording would have supplied. |
opts |
Scale and compression settings. |
Exceptions
| Name | Description |
|---|---|
IoException |
when no frame has been delivered yet -- start the player or seek, so there is a frame to save -- or when 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, where the frame is to hand and the player may already have moved on. 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 the replay is showing 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.
ApplyConfig
void ApplyConfig(const ImagerConfig &config)
Put back a configuration this recording can still honour.
The palette is a drawing choice and is applied either way: re-colouring a replay changes nothing about what it reports.
The global radiation is applied too, and reaches the pixels, on any recording that carries a radiometry bundle. The energy each stored temperature came from is recovered through the characteristic curve the file carries and read back out of a table rebuilt at the requested emissivity -- the table the camera itself would have built -- so the global knob on a replay is the same knob as on a camera and gives the same answer. Asking for the file's own parameters back clears the mapping and returns the recorded pixels unchanged, to the byte.
Changing it takes effect on the next frame delivered. On a paused replay that is no frame at all until Resume(), so call Refresh() to see it now.
What it still refuses, and says why:
- The temperature range. A different range is a different calibration -- its own
.prn, its own table parameters -- and the file carries only the one it was recorded in. There is nothing to rebuild from. - The global radiation on a file with no radiometry bundle, or one whose bundle does not reproduce the characteristic curve the file also carries.
CanChangeRadiation()answers this without raising anything.
ApplyConfig(GetConfig()) is always accepted, so round-tripping a recording's own record works.
Exceptions
| Name | Description |
|---|---|
FeatureNotSupportedException |
if the record's temperature range differs from the file's, or if its radiation parameters differ and this recording cannot rebuild its table at them. |
SetPalette
void SetPalette(Palette palette) override
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 to each frame's own range, which is what a recording needs by default -- it carries no scene statistics. In the SDK's temperature unit, as FrameSource::SetColorRange() says.
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.
Display
auto Display() -> sdk::Display &
Colour windows -- isotherms -- over the replayed picture, and the region overlays drawn into it.
The same Display a camera hands out, over this player's own rendering state. A band gets the same ids, the same kMaxColorWindows limit and the same ascending-id compositing order, because it is the same code operating on the same map: a layout authored against a live camera draws the same picture when it is reviewed on a recording.
Until v12 the colour-window calls refused a recording outright, while SetPalette() a few lines above accepted one -- so palettes worked on a replay and isotherms did not, and the difference was which class owned the call rather than anything about the file.
Two members of Display mean less here than on a camera, and say so themselves rather than failing quietly. Motion-gated bands are refused: motion zones are Imager::Motion()'s. The direct GPU rendering answers nullptr and false: a recording has no GPU backend, exactly like a camera that could not start one.
auto player = Player::Open("run.mkv"); if (player->Display().AreColorWindowsSupported()) { player->Display().SetColorWindow( 1, {.min_c = 60.0F, .max_c = 90.0F, .opacity = 0.8F}); }
Display
auto Display() const -> const sdk::Display &
SetDisplayTemperatureUnit
void SetDisplayTemperatureUnit(TemperatureUnit unit)
The unit this replay shows temperatures in where the SDK turns one into text: region labels drawn into the picture and the description line of a JPEG snapshot. Exactly Imager::SetDisplayTemperatureUnit(), with the same promise: display only. The unit of every number the API takes and returns is SetTemperatureUnit()'s, and until this is called the replay 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.