OptrisOptrisDocumentation

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

optris::sdk::rec::Snapshot

Reads and writes single-frame files. All methods are static and stateless; nothing here touches a camera.

Public static functions

SavePng

static void SavePng(const optris::sdk::ThermalFrame &frame, const std::string &path, const SnapshotInfo &info={}, const SnapshotOptions &opts={})

Save a thermal frame as a radiometric 16-bit PNG.

Greyscale, colour type 0, no interlace, lossless. The file carries a human-readable Description, the full metadata as JSON in an iTXt otc:meta chunk, and one otCa chunk per attachment, all before the first IDAT, so a streaming reader has them before any pixels arrive.

Parameters

Name Description
frame Thermal frame from the SDK.
path Output file path.
info Capture metadata and attachments to embed.
opts Scale and compression settings.

Exceptions

Name Description
InvalidArgumentException for an empty frame or a scale that cannot represent it.
IoException on write failure. No partial file is left behind on failure.

SavePng

static void SavePng(const optris::sdk::RawFrame &frame, const std::string &path, const SnapshotInfo &info={}, const SnapshotOptions &opts={})

Save uncalibrated detector counts as a 16-bit PNG.

ADU is written through bit for bit: no scale, no offset, no unit. The metadata records adu_bit_depth so a reader knows the valid range is 0..16383 rather than 0..65535 on a 14-bit sensor.

A raw-ADU PNG carrying its dark frame and calibration blob as attachments is fully re-processable offline, which is the point of this overload.

Exceptions

Name Description
InvalidArgumentException for an empty frame.
IoException on write failure.

SaveTiff

static void SaveTiff(const optris::sdk::ThermalFrame &frame, const std::string &path, const SnapshotInfo &info={}, const SnapshotOptions &opts={})

Save a thermal frame as a classic float32 TIFF.

float32 Kelvin by default, matching the PNG's unit; set SnapshotOptions::tiff_int16 for the uint16 variant on the same grid as the PNG. Always classic TIFF, version 42, never BigTIFF. A write that would exceed the 4 GB classic ceiling raises InvalidArgumentException rather than being silently upgraded.

Exceptions

Name Description
InvalidArgumentException for an empty frame, or past the classic ceiling.
IoException on write failure.

SaveTiff

static void SaveTiff(const optris::sdk::RawFrame &frame, const std::string &path, const SnapshotInfo &info={}, const SnapshotOptions &opts={})

Save uncalibrated detector counts as a uint16 TIFF.

Exceptions

Name Description
InvalidArgumentException for an empty frame.
IoException on write failure.

SaveTiff

static void SaveTiff(const optris::sdk::EnergyFrame &frame, const std::string &path, const SnapshotInfo &info={}, const SnapshotOptions &opts={})

Save linear radiometric energy as an int32 TIFF.

Post-NUC and pre-PRN, for feeding an external temperature model.

Exceptions

Name Description
InvalidArgumentException for an empty frame.
IoException on write failure.

SaveJpeg

static void SaveJpeg(const optris::sdk::ThermalFrame &frame, const std::string &path, const SnapshotInfo &info={}, const SnapshotOptions &opts={})

Save the colour picture as a JPEG.

A JPEG snapshot is not a measurement and cannot be read back as one. JPEG is eight bits a channel and lossy; there is no way to put temperatures into one and get them out again. LoadThermal() refuses a JPEG rather than returning approximate temperatures, and that is the point of the format being separate from the other three: PNG and TIFF carry the radiometry, CSV carries the numbers, JPEG carries what it looked like.

Use it for a report, a work order, an email: anywhere the file is going to be looked at rather than analysed. Use SavePng() for anything that has to stay measurable; a colour PNG shows the same picture to the same viewers and keeps the 16-bit data in an attachment.

SnapshotInfo::rendering must be set, because it is the only thing in a SnapshotInfo that a JPEG can hold. Without it there is no picture, and a greyscale ramp invented from the frame would be this SDK choosing a palette on the caller's behalf and then not saying so. Recorder::SaveSnapshot() fills it from the live view.

The metadata document is written into a JPEG comment segment prefixed otc:meta, so the file still says which camera took it, at what emissivity, with what colour scale, and what the scene's extremes were. Attachments are refused rather than dropped: a format that cannot carry them must say so, not accept them and lose them.

Parameters

Name Description
frame The frame the picture was rendered from. Its size must match the rendering, and its metadata goes into the file.
path Output file path.
info Capture metadata. rendering is required; attachments must be empty.
opts SnapshotOptions::jpeg_quality selects the quality.

Exceptions

Name Description
InvalidArgumentException for a missing or mismatched rendering, or for a non-empty attachment list.
FeatureNotSupportedException when the FFmpeg build has no MJPEG encoder.
IoException on write failure. No partial file is left behind on failure.

SaveCsv

static void SaveCsv(const optris::sdk::ThermalFrame &frame, const std::string &path, const SnapshotInfo &info={}, const SnapshotOptions &opts={})

Save frame temperatures as CSV, one row per scanline.

Values are Celsius with two decimals, separated by ,, with . before the decimals and nan for a pixel that was not measured. Comment header lines prefixed with # are written before the data. The overload taking a CsvOptions changes any of that; this one writes what it always has, whatever the process locale.

Exceptions

Name Description
InvalidArgumentException for a non-empty attachment list, or for a path this platform cannot express.
IoException when the file cannot be opened.

Note: The refusals above are the only things this raises. In particular the path conversion's own failure is answered rather than thrown from underneath, and then raised here as InvalidArgumentException; see the comment at the call site in src/record/snapshot.cc. The distinction matters because the C ABI's firewall can only flatten an exception it does not recognise to OPTRIS_SDK_ERROR_UNKNOWN, so a std::filesystem error escaping would reach every binding as "something went wrong" rather than as "that path is not usable".

SaveCsv

static void SaveCsv(const optris::sdk::ThermalFrame &frame, const std::string &path, const SnapshotInfo &info, const SnapshotOptions &opts, const CsvOptions &csv)

Save frame temperatures as CSV, spelled the way csv asks.

The same file as the overload above, with the delimiter, the decimal separator, how an unmeasured pixel is written and whether the # header lines appear taken from csv. A default-constructed CsvOptions writes byte for byte what the overload above writes.

opts is accepted so the call reads like every other Save*(); nothing in SnapshotOptions applies to a CSV.

Exceptions

Name Description
InvalidArgumentException for a delimiter other than ,, ; or a tab, a decimal separator other than . or ,, the two being the same character, a non-empty attachment list, or a path this platform cannot express. Nothing is written then.
IoException when the file cannot be written.

ReadInfo

static auto ReadInfo(const std::string &path) -> SnapshotInfo

Read the metadata and attachments from a snapshot.

Populates Attachment::data for every attachment found and verifies each SHA-256 recorded in the metadata, so a payload mangled by third-party tooling is caught rather than returned.

Parameters

Name Description
path PNG, TIFF or JPEG written by this SDK. Recognised by the file's own leading bytes, not by its extension, so a snapshot renamed on the way through a mail server still reads.

Returns: The metadata.

Exceptions

Name Description
IoException when the file cannot be read or an attachment fails its digest.
InvalidArgumentException when the file carries no otc:meta, which is how a file from before this format is recognized.

Note: A JPEG is read for its metadata and nothing else. The document lives in a comment segment, so the file still says which camera took it, when, at what emissivity and what the scene's extremes were; the attachment list comes back empty because a JPEG refuses attachments rather than carrying them, and LoadThermal() refuses the file outright. A JPEG is not reported as a corrupt PNG.

ReadMetadata

static auto ReadMetadata(const std::string &path) -> FileMetadata

Read the full metadata document from a snapshot.

The same call as ReadInfo, but returning the shared schema rather than the write-side view of it; this is what carries the scale, the scene statistics and the capture telemetry.

LoadThermal

static auto LoadThermal(const std::string &path) -> optris::sdk::ThermalFrame

Load a temperature snapshot back into a ThermalFrame.

Exact for every file this SDK writes: the internal value that went in is the internal value that comes out.

Exceptions

Name Description
InvalidArgumentException when the file holds raw ADU rather than temperature, carries a scale that is not on the ladder, or is a JPEG, which is not a measurement.
IoException when the file cannot be read.

LoadRaw

static auto LoadRaw(const std::string &path) -> optris::sdk::RawFrame

Load a raw-ADU snapshot back into a RawFrame.

Exceptions

Name Description
InvalidArgumentException when the file holds temperature rather than raw ADU.
IoException when the file cannot be read.

EncodeAttachment

static auto EncodeAttachment(const Attachment &attachment) -> std::vector< std::byte >

Encode one attachment as an otCa chunk payload.

The payload is deflated when Attachment::compress is set, which is the default. A reader that cannot inflate must reject such a record rather than hand the deflate stream back as content.

DecodeAttachment

static auto DecodeAttachment(const std::vector< std::byte > &payload) -> std::optional< Attachment >

Decode an otCa chunk payload, inflating when needed.

Returns: The attachment, or nullopt when the record is malformed, truncated, fails its digest, or uses a compression method this build does not know.

ReadAttachments

static auto ReadAttachments(const std::string &path) -> std::vector< Attachment >

Read the attachments back out of a snapshot.

Works for both carriers this SDK writes: the otCa chunks of a PNG and private tag 65200 of a TIFF.

These are the files the application attached, and not every file the snapshot carries. Three of the SDK's own are left out on purpose, each matched on name and MIME type so that an application which attached something of its own under one of those names keeps it:

Left out What it is
thermal.png On a colour snapshot, the measurement itself. It is the image's data rather than a payload; LoadThermal() is how to reach it.
characteristic-curve.otc The camera's characteristic curve.
radiometry.otc The radiometry bundle.

So a file carrying nothing but those returns an empty vector, and that is not a failure. An attachment list has always meant "the files I attached", and putting the SDK's own in front of them would shift every index and every count in code written before any of them existed.

All three stay in the container and stay in the attachments array of the metadata document, which describes the file literally -- so a reader that has never heard of this SDK sees them, and so does ReadMetadata().

Reading the curve itself: Reading the curve itself There is no way to, and that is deliberate for now. Neither the characteristic curve nor the radiometry bundle is readable as data through any API, on any binding. What a file's curve is for is reached instead by opening the snapshot as a StillSource: the measurement is then redone through the carried curve, which is what makes a per-region emissivity and a different global emissivity work on a still. StillSource::HonoursRegionEmissivity() answers whether this file carried one at all.

Exceptions

Name Description
IoException on a record this build cannot decode, rather than silently returning fewer attachments than the file holds.

See also: StillSource for measuring a snapshot through its own curve