Snapshot File Formats
In Fahrenheit: with the SDK switched to Fahrenheit (SetTemperatureUnit() and its counterparts, see Temperatures in Fahrenheit), every temperature on this page is read and written in Fahrenheit, and every difference in Fahrenheit degrees; the samples are unchanged.
What a snapshot is
A single frame written to a file that describes itself. Everything needed to turn a pixel into a temperature is in the file, in a form standard tools already read.
Two radiometric image formats are written, and a third that carries no measurement:
| Format | For | Primary pixels | Temperatures | Attached files |
|---|---|---|---|---|
| PNG | the standard one | the colorized picture as it was on screen, 8-bit RGB | the 16-bit radiometric data, losslessly, in the same file | otCa chunks |
| TIFF | the analysis export | float32 by default, one rigidly fixed profile | the pixels themselves | private tag 65200 |
| JPEG | looking at, not analysing. See JPEG | the colour picture, lossy | none to read back | refused |
TIFF's profile is fixed so that ImageJ, MATLAB, GDAL and tifffile all open it without argument and without extra packages. Snapshot::ReadAttachments() reads either carrier.
PNG and TIFF carry the same metadata document, and so does a recording: one schema, three carriers. It is what makes a saved still measurable again rather than merely readable, recording the emissivity, the transmissivity and the ambient the temperatures were computed at, so a file reopened later can be measured on the terms it was captured on. See Opening a still as a measurable source.
The temperature grid
Temperature pixels are anchored at absolute zero, with a per-file step size:
T_kelvin = pixel * scale T_celsius = pixel * scale - 273.15
scale is one of three values, chosen automatically as the finest rung covering both the camera's configured range maximum and the hottest pixel in the frame, so a pixel hotter than the configured range does not fail the write:
scale |
Highest temperature | Covers |
|---|---|---|
| 0.01 K | 382.2 °C | the −20…100 and 0…250 ranges |
| 0.025 K | 1365.2 °C | the 150…900 range |
| 0.05 K | 3003.6 °C | the 200…1500 and 2200 °C ranges |
All three are exact: converting the SDK's internal encoding to a pixel and back gives the same value, for every value the rung can hold, with nothing rounded at any camera range.
Why these three and not 0.1. A step is exact in both Kelvin and Celsius when it divides both 0.1 (the SDK's internal step) and 273.15. 0.01, 0.025 and 0.05 all do; 0.1 does not, because 273.15 is an odd multiple of 0.05, so a 0.1 K grid anchored on whole decikelvin cannot represent exactly 25.00 °C.
Without a camera range, the frame's own maximum decides. A caller may set the scale explicitly through SnapshotOptions::scale. A scale coarser than needed is accepted and only costs resolution; one that cannot represent a value actually in the frame is rejected with kInvalidParameter rather than clipping a measurement.
PNG
A PNG snapshot has two images in it: the picture and the measurement.
The primary image is the colorized picture: colour type 2, bit depth 8, no interlace. A browser, a mail client, a file manager thumbnailer or an image viewer shows it with no thermal tooling and no knowledge of Optris. It is the frame as the operator saw it: their palette, the colour scale their auto-scale mode had settled on, their isotherm bands, and their region and blob overlays where those are composited into the live image.
The measurement is an otCa attachment named thermal.png: a 16-bit greyscale PNG in its own right (colour type 0, bit depth 16, samples most significant byte first) holding exactly the radiometric pixels this SDK has always written. Snapshot::LoadThermal() finds it and returns the identical temperatures either way; nothing is scaled, clipped or rounded on the way in or out.
ReadAttachments() deliberately does not list the measurement, and it is not the only thing it leaves out: that call answers "which files did I attach". The attachments array of otc:meta does list it. See What an attachment list leaves out for the whole rule.
Note: Why the picture is primary. A 16-bit greyscale thermal frame opens as a nearly flat grey rectangle: at room temperature a pixel sits near 45% grey and a whole room's contrast occupies a few hundred of 65535 values. Putting the picture first makes looking at the file work everywhere and costs the measurement nothing, which is still there at full precision.
Note: Why the measurement is a PNG rather than raw bytes. Extracting the attachment gives a file ImageJ, Fiji, Pillow or tifffile opens directly, instead of a blob that needs otc:meta to interpret. PNG's row filtering also compresses thermal data better than flat deflate, so it costs no size either.
Chunk layout
\x89PNG\r\n\x1a\n IHDR 8-bit RGB, no interlace otCa thermal.png the measurement, 16-bit greyscale otCa <attachment> your own files, repeatable otCa <attachment> tEXt Software "OTC.SDK 12.0.1" the running version, whatever it is tEXt Description the human-readable line, below iTXt otc:meta deflate-compressed JSON IDAT ... IEND
Everything except the pixels comes before the first IDAT, so a streaming reader has the metadata and all attachments (including the measurement) before any image data arrives. The attachments come before the text chunks: write a streaming parser against that order. They are registered as unknown chunks at PNG_HAVE_IHDR, and libpng emits those ahead of the text. Confirm it against the committed goldens under tests/data/snapshot_golden/.
The Description line tells anyone opening the file in a viewer, or running exiftool, what they are holding:
Optris thermal image, colorized as displayed. The measurement is the 16-bit greyscale PNG attached as 'thermal.png': T[K] = pixel * 0.01; T[C] = pixel * 0.01 - 273.15. Full metadata in iTXt otc:meta.
Greyscale-primary snapshots
With no picture to write, the snapshot keeps the 16-bit greyscale primary image it has always had, with no attached thermal.png and no render block in the metadata. Two cases: Snapshot::SavePng() called directly with no SnapshotInfo::rendering (there is no live view to reproduce, and inventing a palette would put the file in colours nobody chose), and a raw-ADU snapshot, which is uncalibrated and has no colour scale.
A streaming camera's SaveSnapshot() has a picture. During the startup calibration the automatic colour scale has not settled on a range yet (it waits for the first frame that is a measurement), and the live view draws each frame over that frame's own range; a snapshot then is that picture, its render block names the range it was drawn with and says "thermal_data_reliable": false. Up to 12.0.16 such a PNG was the greyscale one and such a JPEG was refused. The Description line is then the radiometric or the raw one:
Optris radiometric thermal image. T[K] = pixel * 0.01; T[C] = pixel * 0.01 - 273.15. Full metadata in iTXt otc:meta.
Optris raw detector image, 14-bit ADU right-aligned in 16-bit samples. Uncalibrated. Full metadata in iTXt otc:meta.
Warning: Both shapes must be handled by any reader of your own. The colour-primary PNG is new: every snapshot written by 12.0.0 and earlier is greyscale-primary, and they keep opening unchanged. A reader that assumes colour type 0 and bit depth 16, as this SDK's own reader did before the change, rejects a colorized snapshot outright. Branch on the IHDR, or use Snapshot::LoadThermal(), which handles both.
What the colours meant
A colorized snapshot records its presentation in the render block of otc:meta, so the picture is reproducible and a reader can put a legend beside it:
"render": { "palette": "Iron", "range_min_c": 17.91, "range_max_c": 30.90, "auto_scale_mode": "percentile", "overlays": true, "thermal_data_reliable": true }
| Field | What it says |
|---|---|
range_min_c, range_max_c |
The ends of the palette, not the scene's extremes: under percentile the scene runs past both. Read the extremes from scene.min_c / scene.max_c. |
auto_scale_mode |
Absent when a fixed range was in force: the caller chose the range and no mode did. |
palette |
"custom", with the application's own name in palette_name, when a custom palette was set. |
overlays |
Whether the boxes and contours in the picture are painted on rather than in the scene. It reports what is in the image, not what was configured: a camera with a GPU backend draws the outlines unless SetOverlayCompositing(false) switched them off, and a camera on the CPU pipeline or the simulated camera only after SetOverlayCompositing(true), so a fresh simulated camera records false although the setting reads true. SDK 12.0.16 and earlier recorded false for every camera without a GPU backend, even with outlines in the picture. |
thermal_data_reliable |
False when the detector had not settled, so a reader can tell the colours were computed from temperatures that were not yet trustworthy. |
The otc:meta document
A compressed iTXt chunk holding JSON. exiftool, Pillow and libpng all read it without knowing anything about Optris.
{ "otc_format": 1, "encoding": "temperature", "unit": "K", "scale": 0.01, "width": 640, "height": 480, "software": "OTC.SDK 12.0.1", "device": { "model": "Xi 400", "serial": "24120005", "hardware_revision": "3002", "firmware_version": "3.7.1", "optics_fov_deg": 29.9 }, "capture": { "timestamp_us": 1718205600123456, "sequence": 42, "flag_temp_c": 35.2, "box_temp_c": 28.1, "chip_temp_c": 24.5, "flag_open": true, "thermal_data_reliable": true }, "radiation": { "emissivity": 0.95, "transmissivity": 1.0, "ambient_temp_c": 23.0 }, "range": { "min_c": -20.0, "max_c": 100.0 }, "scene": { "min_c": 21.4, "max_c": 68.9, "min_index": 84213, "max_index": 12007 }, "attachments": [ { "name": "calibration.bin", "mime": "application/octet-stream", "size": 262144, "sha256": "9f86d081884c7d659a2feaa0c55ad015…" } ], "description": "free text from the caller" }
Only otc_format, encoding, width and height are always present. rois and attachments appear only when there is something in them, never as an empty array. Every other field is written only when it is known, so a reader can tell "not recorded" from "recorded as zero", which matters when the value is a measurement. An emissivity of 1.0 in the file means the emissivity was one; an absent emissivity means nobody recorded it.
capture.thermal_data_reliable is false when the frame was not a measurement: the camera's startup calibration, or the first frames after a range or mode switch, whose pixels are not yet temperatures. It is written on every temperature snapshot (PNG, either primary, and TIFF), and a colour snapshot says the same in render.thermal_data_reliable. A CSV snapshot carries it as the header line # ThermalDataReliable: true or false. Snapshot::LoadThermal(), a still opened as a source (StillSource, Camera.open_still() and the other bindings) and the C ABI's snapshot frame all hand the verdict back as the frame's thermal_data_reliable. For a frame the application built itself it is that frame's own thermal_data_reliable, true unless the application set it. Absent means a file from 12.0.16 or earlier, which reads back as a measurement as it always did. FileMetadata has no member for it in 12.0, so ReadMetadata() does not show it; read the frame instead.
capture.chip_temp_c had been written regardless, so a snapshot from a camera whose detector count does not decode recorded a detector at 0 degC, a temperature a detector can genuinely be at. It now follows the rule above: absent means there was no reading, StillSource::GetTelemetry() reports chip_temp_known false for it, and 0.0 in the file means a detector at zero.
For a raw-ADU image, encoding is "raw_adu", unit and scale are absent, adu_bit_depth is present, and radiation and scene are omitted entirely: they are meaningless on uncalibrated counts, and writing them would suggest a correction that never happened.
encoding says what the quantity is and deliberately not which numeric grid it sits on. The grid is unit, scale and offset, and the rule is always
value = pixel * scale + offset
offset is absent from every still image, and absent means zero: a snapshot's grid is anchored at absolute zero, so pixel * scale is the whole rule here. The field exists for a recording, whose video track is the SDK's internal int16 and therefore sits on a grid with a zero of its own (scale: 0.1, offset: 173.15). See What a third party may rely on. A reader that applies scale without offset is right on every still and out by 173.15 K on a recording, so apply both.
SnapshotInfo::extra_json is merged into this document at the top level. Keys the schema already uses are never overwritten, so no application can redefine what a pixel means.
The otCa attachment chunk
One chunk per attached file, repeatable. The name is valid per the PNG chunk-naming rules, byte by byte:
| Byte | Value | Case | Meaning |
|---|---|---|---|
| 0 | o |
lower | ancillary: decoders may ignore it |
| 1 | t |
lower | private: not a registered public chunk |
| 2 | C |
upper | reserved bit clear, as the spec requires |
| 3 | a |
lower | safe to copy: editors preserve it across edits that do not touch pixels |
Payload, all multi-byte fields big-endian per PNG convention:
uint8 version = 1 uint8 flags bit0: payload is a zlib deflate stream uint16 reserved = 0 uint8 name_len char name[name_len] UTF-8, e.g. "calibration.bin" uint8 mime_len char mime[mime_len] e.g. "application/octet-stream" uint32 uncompressed_len uint32 payload_len uint8 payload[payload_len]
payload_len makes a record self-delimiting. PNG would not need it (the chunk header gives the extent) but TIFF concatenates these same records into a single tag, where a compressed payload has no discoverable end. One length field lets one parser serve both carriers.
Compression is attempted when requested and silently skipped when it would not pay. Deflating random or already-compressed data makes it larger, and an attachment must never grow by being attached; the flag reflects what is in the file, not what was asked for.
What foreign tools see. otc:meta is standard iTXt and anything reads it; the otCa payloads are ours alone, which is the cost of not inflating binary blobs by a third with base64. The attachments array in the JSON means a foreign reader can at least see what it is missing, with a name, a size and a digest for each.
What an attachment list leaves out
An attachment list is the files the application attached, not every file the snapshot carries. A snapshot written by a camera with a pipeline carries up to three files nobody asked for, and a caller's list has always meant "the files I attached". The reader therefore removes three of the SDK's own, 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 | How to reach what it is for |
|---|---|---|
thermal.png |
On a colour-primary snapshot, the measurement itself: a 16-bit greyscale PNG in its own right, the image's data rather than a payload. | Snapshot::LoadThermal(), or optris_sdk_snapshot_acquire_frame() on the flat ABI. |
characteristic-curve.otc |
The camera's characteristic curve, written by every camera that has one. | Open the snapshot as a StillSource, see below. |
radiometry.otc |
The radiometry bundle: the calibration that rebuilds that curve at a different global emissivity. | The same. |
So a snapshot whose only attachments are the SDK's own reports an empty list, and that is routine rather than a failure. A simulated camera's colour PNG is that case: otc:meta's attachments array names two files and ReadAttachments() returns none. Counting them instead would have shifted every index and every count in code written before any of them existed.
All three stay in the container and in the attachments array of otc:meta, with a name, a MIME type, a size and a SHA-256 for each, so the file remains literally self-describing to a reader that has never heard of this SDK, and ReadMetadata() sees them too.
The rule is the same on every binding: Snapshot::ReadAttachments(), optris_sdk_snapshot_get_attachment_count() and _get_attachment_info(), Snapshot.Attachments in C#, Snapshot.attachments in Python, Snapshot::attachment_count() and ::attachments() in Rust.
Reading the curve itself
There is no way to, on any binding. Neither the characteristic curve nor the radiometry bundle is readable as data: the types that decode them are internal to the SDK and are not in the shipped headers, and no ABI entry point returns either.
What the curve is for is reachable. Open the file as a measurable source and the measurement is redone through the carried curve:
#include <optrissdk.h> auto still = optris::sdk::StillSource::Open("capture.png"); if (!still->HonoursRegionEmissivity()) { // The file carried no usable curve: a region's own emissivity will // read at the camera's instead, and the region says so. }
optris_sdk_imager *still = NULL; int honours = 0; if (optris_sdk_still_open("capture.png", &still) == OPTRIS_SDK_OK) { optris_sdk_still_honours_region_emissivity(still, &honours); if (!honours) { /* The file carried no usable curve: a region's own emissivity * will read at the camera's instead, and the region says so. */ } optris_sdk_imager_destroy(still); }
using ThermalCamera still = ThermalCamera.OpenStill("capture.png"); if (!still.HonoursRegionEmissivity) { // The file carried no usable curve: a region's own emissivity // will read at the camera's instead, and the region says so. }
with optris_sdk.Camera.open_still('capture.png') as still: if not still.honours_region_emissivity: # The file carried no usable curve: a region's own emissivity # will read at the camera's instead, and the region says so. pass
let still = Camera::open_still("capture.png")?; if !still.honours_region_emissivity()? { // The file carried no usable curve: a region's own emissivity // will read at the camera's instead, and the region says so. }
StillSource::HonoursRegionEmissivity() asks whether this file carried a curve at all. With one, a per-region emissivity is resolved by the same object a live camera resolves it with, and StillSource::ApplyConfig() re-measures the whole still at a different global emissivity out of the bundle. Without one, both say so rather than returning plausible numbers.
TIFF
The locked profile
TIFF is a container with enormous freedom (strips or tiles, either byte order, a dozen compressions, planar or contiguous, predictor on or off) and every reader implements a different subset, so two perfectly valid TIFFs can have almost nothing in common. Every TIFF this SDK writes has exactly this profile:
| Axis | Value | Never |
|---|---|---|
| Version | 42 (classic) | 43 (BigTIFF) |
| Byte order | little-endian (II) |
big-endian |
| Layout | strips, ≈8 KB of samples each | tiles |
| Planar config | CONTIG |
SEPARATE |
| Samples per pixel | 1 | multi-sample |
| Photometric | MINISBLACK |
palette, YCbCr |
| Compression | DEFLATE (tag value 8) |
LZW, JPEG, PackBits |
| Predictor | 2 for integer, none for float | 3, see below |
| Pages | 1 | multi-page stacks |
Standard tags on every variant: ImageDescription (the same JSON as otc:meta, uncompressed), Software, Make = "Optris", Model, and DateTime, when the picture was taken, in UTC to the second. Attachments go in private tag 65200 as TIFF_UNDEFINED, holding the same concatenated records as the PNG's otCa chunks. libtiff passes an unregistered private tag through as opaque bytes and warns; it does not stop any conforming reader from decoding the pixels.
Where DateTime comes from depends on the source the snapshot was saved from:
| Source | DateTime |
|---|---|
| A camera, the simulated camera included | The computer's clock when the frame arrived. A frame passed to SaveSnapshot() is dated the same way when it came from that camera. |
| A replay | The time the recording began (Player::GetStartTimeUs()) plus the frame's place in the recording. |
| A still opened from a TIFF | That TIFF's own DateTime. |
| A still opened from a PNG | None: a PNG carries no date. |
rec::Snapshot::SaveTiff() called directly |
The frame's timestamp_us, when that is a date (microseconds since 1970, from the year 2000 on); otherwise none. |
"None" means the tag is left out, never a made-up date. capture.timestamp_us in the metadata is the frame's capture stamp either way: a stopwatch reading for timing frames against each other, not a date. Up to 12.0.25, DateTime was that stamp formatted as a date, so a TIFF of a live camera said it was taken in the first week of January 1970.
Why float samples carry no predictor. TIFF's floating-point predictor (value 3) compresses a float thermal field 27–64% better, and libtiff, GDAL, ImageJ, MATLAB and Pillow all decode it. tifffile does not: it needs the separate imagecodecs package, which Debian does not package at all, so apt install python3-tifffile gives a reader that raises ValueError on such a file. float32 is the default variant and tifffile is what an analyst reaches for, so the predictor would put the most likely file in front of the reader least able to open it. The bytes are given up instead. The integer variants keep predictor 2, which every reader handles.
The profile is a testable invariant, not a guideline: the test suite asserts every row of that table against every TIFF it produces, so changing any of them fails the build rather than shipping a file a customer's reader rejects.
Never BigTIFF. It changes only the file skeleton (64-bit offsets, so files may exceed 4 GB) and introduces no new pixel formats at all; float32 has been a plain TIFF 6.0 feature since 1992. What it costs is readers: it announces version 43 at byte 2, and a reader that does not know 43 rejects the file outright, with no partial read and no degraded mode. Windows viewers, WIC and System.Drawing all do, and Pillow cannot write it. A 640×480 float32 frame is 1.2 MB, so there is nothing to buy and a whole column of readers to lose. A write that would pass the 4 GB ceiling is refused with kInvalidParameter, never silently upgraded.
Pixel variants
| Source | Option | BitsPerSample | SampleFormat | Predictor | Pixels are |
|---|---|---|---|---|---|
ThermalFrame |
default | 32 | IEEEFP |
(none) | float32 Kelvin |
ThermalFrame |
tiff_int16 |
16 | UINT |
2 | the 0 K grid, identical to the PNG |
RawFrame |
(none) | 16 | UINT |
2 | ADU, bit-exact |
EnergyFrame |
(none) | 32 | INT |
2 | linear energy, post-NUC/pre-PRN |
Both temperature variants speak Kelvin: an Optris still image is in Kelvin, with no exceptions. This differs from SaveCsv and ExternalPixelFormat::kThermalFloat32, which are Celsius (a CSV can be asked for in Fahrenheit, and every CSV names its unit on a # Unit: header line); the file always states its own unit in otc:meta.
tiff_int16 is the universal-compatibility escape hatch: same profile, same tags, same metadata, and a pixel meaning a reader can look up from the PNG rules above.
JPEG
Snapshot::SaveJpeg() writes the colour picture and nothing measurable. JPEG is eight bits a channel and lossy, so there is no way to put temperatures into one and get them back out. It is for a report, a work order, an email, anywhere the file is looked at rather than analysed. For anything that has to stay measurable, SavePng() shows the same picture to the same viewers and keeps the 16-bit data in an attachment.
The file says what it is rather than looking measurable:
encodingis"color", the one value in the schema that is not a measurement.unitandscaleare meaningless on it and are not written.- The
Descriptionline opens "NOT radiometric". Snapshot::LoadThermal()refuses a JPEG rather than returning approximate temperatures.- The scene's extremes are still recorded, so the file says what the camera saw though its pixels no longer do.
Two things it requires of the caller, both refusals rather than silent fallbacks:
SnapshotInfo::renderingmust be set. It is the only part of aSnapshotInfoa JPEG can hold, and without it there is no picture; inventing a greyscale ramp would be the SDK choosing a palette on the caller's behalf without saying so.Recorder::SaveSnapshot()fills it from the live view, andSnapshotFormat::kJpegreaches it:SaveSnapshot(), a snapshot action and interval capture all write a JPEG, from a camera, a replay or a still.rec::Snapshot::SaveJpeg()remains the direct call for a caller supplying its own rendering.- Attachments are refused, not dropped. A non-empty
SnapshotInfo::attachmentsfails withkInvalidParameter.
The metadata document still travels, in a JPEG comment segment prefixed otc:meta, so the file records which camera took it, at what emissivity, with what colour scale. The picture is encoded 4:4:4, not the usual 4:2:0: a false-colour image carries its information in the chroma, and subsampling can erase a one-pixel isotherm band. SnapshotOptions::jpeg_quality selects the quality. Encoding goes through FFmpeg's mjpeg encoder, already linked for the recorder, so it costs no new dependency.
Worked example: PNG
Write a PNG with a calibration blob inside it, then read the picture, the metadata, the blob and the temperatures back.
Going through Recorder().SaveSnapshot() makes the file colour-primary: the picture is the primary image and the 16-bit measurement rides in the otCa attachment thermal.png. LoadThermal() returns the same temperatures either way, so the C++ below does not have to care. A reader written without the SDK does, and the Python further down says how.
#include <optrissdk.h> namespace rec = optris::sdk::rec; // -- Writing -------------------------------------------------- rec::SnapshotInfo info; info.description = "line 7, bearing check"; rec::Attachment calibration; calibration.name = "calibration.bin"; calibration.mime = "application/octet-stream"; calibration.data = LoadCalibrationBlob(); // yours: any bytes you like info.attachments.push_back(std::move(calibration)); imager->Recorder().SaveSnapshot(frame, "/data/bearing.png", optris::sdk::SnapshotFormat::kPng, info); // -- Reading, possibly on another machine, months later -------- // Every read here throws on failure, like the rest of the C++ // surface. Catch optris::sdk::SdkException, or a derived type to tell // "that is not one of our files" from "the disk refused it". auto meta = rec::Snapshot::ReadMetadata("/data/bearing.png"); spdlog::info("{} {} at {} K per count", meta.device.model, meta.device.serial, *meta.scale); auto back = rec::Snapshot::ReadInfo("/data/bearing.png"); // back.attachments[0].data has been verified against the SHA-256 // recorded in the file; a payload mangled in transit raises // IoException rather than being handed back. auto pixels = rec::Snapshot::LoadThermal("/data/bearing.png"); // Bit-exact against the frame that was saved.
/* -- Writing ------------------------------------------------- */ /* The ABI's attachment writer is a provider: the SDK calls you with a * sink and you add to it, so the bytes are produced when the file is * being written rather than held in a list beforehand. */ optris_sdk_snapshot_info info; optris_sdk_snapshot_info_init(&info, sizeof(info)); snprintf(info.description, sizeof(info.description), "line 7, bearing check"); optris_sdk_imager_save_snapshot_ex(imager, "/data/bearing.png", OPTRIS_SDK_SNAPSHOT_PNG, &info, NULL, NULL); /* -- Reading, possibly on another machine, months later ------- */ /* Every read answers a status; nothing is thrown. */ optris_sdk_snapshot *snap = NULL; if (optris_sdk_snapshot_open("/data/bearing.png", &snap) == OPTRIS_SDK_OK) { char document[8192]; optris_sdk_frame *pixels = NULL; size_t attachment_count = 0; optris_sdk_snapshot_get_metadata_json(snap, document, sizeof(document), NULL); optris_sdk_snapshot_get_attachment_count(snap, &attachment_count); /* An attachment's payload is verified against the SHA-256 recorded * in the file; a mangled one is refused rather than handed back. */ if (optris_sdk_snapshot_acquire_frame(snap, &pixels) == OPTRIS_SDK_OK) { /* Bit-exact against the frame that was saved. */ optris_sdk_frame_free(pixels); } optris_sdk_snapshot_close(snap); }
// -- Writing -------------------------------------------------- var info = new SnapshotInfo { Description = "line 7, bearing check" }; camera.SaveSnapshot("/data/bearing.png", SnapshotFormat.Png, info); // -- Reading, possibly on another machine, months later -------- using Snapshot snap = Snapshot.Open("/data/bearing.png"); SnapshotInfo back = snap.Info; Console.WriteLine($"{back.DeviceModel} {back.DeviceSerial}"); // Each attachment's payload is verified against the SHA-256 recorded // in the file; a mangled one throws rather than being handed back. Console.WriteLine(snap.Attachments.Count); using ThermalFrame pixels = snap.LoadThermal(); // Bit-exact against the frame that was saved.
# -- Writing -------------------------------------------------- info = optris_sdk.SnapshotInfo(description='line 7, bearing check') camera.save_snapshot('/data/bearing.png', info=info) # -- Reading, possibly on another machine, months later -------- snap = optris_sdk.Snapshot.open('/data/bearing.png') back = snap.info print(back.device_model, back.device_serial) # Each attachment's payload is verified against the SHA-256 recorded # in the file; a mangled one raises rather than being handed back. print(len(snap.attachments)) pixels = snap.load_thermal() # Bit-exact against the frame that was saved. snap.close()
// -- Writing -------------------------------------------------- let mut info = SnapshotInfo::default(); info.description = "line 7, bearing check".to_string(); camera.save_snapshot_with("/data/bearing.png", SnapshotFormat::Png, Some(&info), None, None)?; // -- Reading, possibly on another machine, months later -------- let snap = Snapshot::open("/data/bearing.png")?; let back = snap.info()?; println!("{} {}", back.device_model, back.device_serial); // Each attachment's payload is verified against the SHA-256 recorded // in the file; a mangled one is an Err rather than being handed back. println!("{}", snap.attachments()?.len()); let pixels = snap.load_thermal()?; // Bit-exact against the frame that was saved.
The same reader is on every binding, so a C#, Python, C or Rust caller can open one of these files and not only write it. The flat ABI carries optris_sdk_snapshot_open(), _get_info(), _get_metadata_json(), _acquire_frame(), _read_raw_pixels() and the attachment calls, and every binding is built on them. See Snapshots and Interval Capture for the C form and the equivalents.
What follows is what a reader gets without the SDK at all.
Check the IHDR first, because that file is not greyscale. Recorder().SaveSnapshot() fills in SnapshotInfo::rendering from the live view, and a PNG written with a rendering is colour-primary: Pillow opens it as RGB, and multiplying those bytes by scale produces nonsense. The measurement is in the otCa attachment named thermal.png. See Greyscale-primary snapshots for which files are which, and the chunk table for the payload layout.
otc:meta is plain iTXt and reads the same either way:
import json from PIL import Image image = Image.open("bearing.png") meta = json.loads(image.text["otc:meta"]) print(image.mode, meta["device"]["model"], meta["scale"], "K per count")
On a greyscale-primary file (one written by Snapshot::SavePng() directly with no rendering, or by 12.0.0 and earlier) the pixels are the measurement and one multiply finishes the job:
import numpy as np assert image.mode == "I;16" pixels = np.asarray(image, dtype=np.float64) celsius = pixels * meta["scale"] - 273.15 print(celsius.max(), "C")
On a colour-primary file, image is the picture. Getting the numbers without the SDK means walking the PNG chunks for the otCa record named thermal.png and opening its payload (itself a 16-bit greyscale PNG) as above; otc:meta's attachments array lists it, so a foreign reader can see that it is there. The SDK route, on any binding, is one call: Snapshot::LoadThermal() / optris_sdk_snapshot_acquire_frame(), which handles both shapes.
Worked example: TIFF
// float32 Kelvin, the default. imager->Recorder().SaveSnapshot(frame, "/data/bearing.tiff", optris::sdk::SnapshotFormat::kTiff); // uint16 on the PNG's grid, for a tool that will not take floats. rec::SnapshotOptions opts; opts.tiff_int16 = true; imager->Recorder().SaveSnapshot(frame, "/data/bearing_u16.tiff", optris::sdk::SnapshotFormat::kTiff, {}, opts);
optris_sdk_snapshot_options opts; /* float32 Kelvin, the default. */ optris_sdk_imager_save_snapshot(imager, "/data/bearing.tiff", OPTRIS_SDK_SNAPSHOT_TIFF); /* uint16 on the PNG's grid, for a tool that will not take floats. */ optris_sdk_snapshot_options_init(&opts, sizeof(opts)); opts.tiff_int16 = 1; optris_sdk_imager_save_snapshot_ex(imager, "/data/bearing_u16.tiff", OPTRIS_SDK_SNAPSHOT_TIFF, NULL, NULL, &opts);
// float32 Kelvin, the default. camera.SaveSnapshot("/data/bearing.tiff", SnapshotFormat.Tiff); // uint16 on the PNG's grid, for a tool that will not take floats. camera.SaveSnapshot("/data/bearing_u16.tiff", SnapshotFormat.Tiff, options: new SnapshotOptions { WriteTiffAsInt16 = true });
# float32 Kelvin, the default. camera.save_snapshot('/data/bearing.tiff', format=optris_sdk.SNAPSHOT_TIFF) # uint16 on the PNG's grid, for a tool that will not take floats. camera.save_snapshot('/data/bearing_u16.tiff', format=optris_sdk.SNAPSHOT_TIFF, options=optris_sdk.SnapshotOptions(tiff_int16=True))
// float32 Kelvin, the default. camera.save_snapshot("/data/bearing.tiff", SnapshotFormat::Tiff)?; // uint16 on the PNG's grid, for a tool that will not take floats. let mut opts = SnapshotOptions::default(); opts.tiff_int16 = true; camera.save_snapshot_with("/data/bearing_u16.tiff", SnapshotFormat::Tiff, None, Some(&opts), None)?;
In ImageJ the float file opens directly as a 32-bit image; subtract 273.15 to read Celsius. From Python:
import json import tifffile with tifffile.TiffFile("bearing.tiff") as handle: page = handle.pages[0] kelvin = page.asarray() # float32 meta = json.loads(page.tags["ImageDescription"].value) celsius = kelvin - 273.15 print(meta["device"]["serial"], celsius.max(), "C")
Worked example: raw ADU with its calibration
A raw-ADU PNG carrying its dark frame and calibration blob is fully re-processable offline: an uncalibrated frame plus exactly the data needed to cook it, in one file, for field diagnostics and for feeding the replay harness.
rec::SnapshotInfo info; // LoadDarkFrame() and LoadCalibrationBlob() are yours. The SDK // attaches whatever bytes you hand it and does not interpret them. rec::Attachment dark; dark.name = "dark_frame.bin"; dark.data = LoadDarkFrame(); info.attachments.push_back(std::move(dark)); rec::Attachment calibration; calibration.name = "calibration.bin"; calibration.data = LoadCalibrationBlob(); info.attachments.push_back(std::move(calibration)); // The overload decides what lands in the file: a RawFrame in means // uncalibrated counts out. There is no mode flag to get wrong. rec::Snapshot::SavePng(raw_frame, "/data/diag.png", info); // ... elsewhere: auto counts = rec::Snapshot::LoadRaw("/data/diag.png"); // bit-exact auto blobs = rec::Snapshot::ReadInfo("/data/diag.png");
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. Calling LoadThermal() on this file raises InvalidArgumentException: it holds counts, not temperatures, and the file says so.
What the reader refuses
A snapshot can arrive from anywhere: an email attachment, a shared drive, a customer. The reader refuses rather than trusts:
| Claim in the file | Ceiling | Why |
|---|---|---|
| Image dimensions | 65535 per side | libpng's own default allows a million square, which is not a thermal frame |
| Total pixels | 2^28 (a 16384-square image) | ~200× the largest sensor the SDK supports, so it never bites a real file |
| A single PNG chunk | 64 MB | bounds an oversized iTXt or otCa |
| Attachment uncompressed size | payload bytes × 1032 | DEFLATE's own maximum expansion ratio |
Every one is checked before anything is allocated on the strength of it: a number read out of a file is not a number to size a buffer from. A 30-byte attachment record claiming three gigabytes, or a 185-byte PNG declaring 700000×700000, are both refused with an InvalidArgumentException naming the claim. Previously each took the process down with a bad_alloc out of a reader that had no answer for it.
None of these limits constrain a legitimate snapshot: the largest sensor the SDK supports is under 1.4 million pixels, and no honestly-compressed attachment can exceed DEFLATE's expansion ratio.
Telling a new file from an old one
This is a new format, not a revision of the old one. Nothing here reads or writes the T × 10 + 1000 deci-Celsius files that v11 and PIX Connect produce.
The two are unambiguously distinguishable: a new-format file always carries otc:meta with an otc_format and an explicit encoding, and a legacy file never does. Absence of the chunk is a reliable signal, so a legacy reader can be added later without guessing and without either format needing to know about the other.
That does not protect code that skips the check. Anything hardcoding (pixel - 1000) / 10 reads a new file as wildly wrong temperatures rather than failing loudly. Since these are new files rather than replacements, that only bites where old tooling is pointed at new output.