OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Python API referencev12.0

Frame

class optris_sdk.camera.Frame

One thermal frame.

A frame from Camera.acquire is yours: its pixels stay valid until you close it, and closing it is what with does. A frame delivered to a callback is borrowed and stops being valid when the callback returns -- see optris_sdk.callbacks.

samples is the SDK's internal fixed-point format, not Celsius. It is exposed because that is what the camera sends and what a zero-copy path can hand over; celsius converts, and to_numpy gives the whole frame at once.

Every temperature a frame answers -- min_c, max_c, the probe temperatures, celsius, temperatures and to_numpy(celsius=True) -- is in the SDK's temperature unit (Celsius unless optris_sdk.set_temperature_unit chose Fahrenheit), whatever the names say: they are older than the switch. Each is read in the unit in force when it is asked for. The raw samples stay in their own format, which is defined in Celsius.

Frame — properties

width

height

pixel_count

timestamp_us

When the frame was captured, in microseconds.

A stopwatch reading, not a date. The clock is monotonic and its epoch is whatever the transport counts from -- the host's boot on the Linux transports, whatever the capture stack stamps a sample with on Windows. The difference between two frames of one stream is how long passed between them; the value on its own does not compare between runs and is not a point in time. Non-zero on every frame.

sequence

flag_temp_c

The internal shutter's temperature in the SDK's temperature unit, or None.

None means this camera reported no shutter reading for this frame -- not that the shutter is at 0 C.

A shutter at 0 C is a cold camera; a camera whose telemetry row never decoded has no probe reading at all, and in earlier releases the two were the same number on every surface the SDK has. A readout, a chart, a data log or an alarm therefore showed 0 C for a probe the camera had never reported. Do not reconstruct that by testing the value: if frame.flag_temp_c: is false for a shutter at 0 C, which is the one case this distinction exists for.

None for the whole session on a camera whose telemetry row cannot decode. Measured on a PI 160x120 at 100 Hz -- the one format Optris ships with too few metadata pixels to carry a telemetry row -- which published a shutter of 0 C and a housing of 0 C on every frame of every session while thermal_data_reliable was True. 0 C is inside the band the decoder accepts, so the refusal that protects the other probes never covered a row of zeros.

A reading once a row has decoded, which on every other supported camera happens within the first frames and then stays. A row that fails to decode later does not take it away: the value then holds the last decoded row's reading, which is a frame or so old and is still a measurement.

None says nothing about the rest of the frame. box_temp_c, chip_temp_c, flag_open, sequence and timestamp_us are all still this frame's: one unreadable probe is a fact about that probe.

Never None from the simulated camera. From a recording it is None exactly when the file carries no shutter reading for that frame, so a replay answers the same question a camera does. The name is the alarm signal's name: a rule on optris_sdk.FIELD_FLAG_TEMP watches this field, and reads optris_sdk.ALARM_ORPHANED on such a frame rather than comparing its limits with a zero.

box_temp_c

The housing temperature in the SDK's temperature unit, or None.

The housing probe's half of flag_temp_c, on the same rule, from the same decoder, and with the same meaning when it is None: the camera reported no reading, not 0 C. None for the whole session on a camera whose telemetry row cannot decode, measured on the same PI 160x120 at 100 Hz, and a fact about this probe only -- flag_temp_c, chip_temp_c, flag_open and sequence are all still this frame's.

Never None from the simulated camera. From a recording it is None exactly when the file carries no housing reading for that frame. Watched by a rule on optris_sdk.FIELD_BOX_TEMP, which reads optris_sdk.ALARM_ORPHANED on such a frame rather than comparing its limits with a zero.

A separate property because it describes a separate probe, and a caller asking about the housing should not have to know which probes share a decoder. Both of today's decoders judge the telemetry row as a unit, so in practice the two agree; the HAL decodes each probe separately and a future decoder may.

chip_temp_c

The detector temperature in the SDK's temperature unit, or None.

None means this camera produced no detector reading for this frame -- not that the detector is cold.

A detector at 0 C is a cold camera; a detector that did not decode is no reading at all, and in earlier releases the two were the same number on every surface the SDK has. A readout, a chart, a data log or an alarm therefore showed 0 C for a camera that had never measured its own detector, with nothing to tell it from a genuine zero. Do not reconstruct that by testing the value: if frame.chip_temp_c: is false for a camera at 0 C, which is the one case this distinction exists for.

The detector is the only probe whose telemetry row does not state a temperature. It arrives as a raw ADC count, converted by a curve shared across the product line and then by this unit's own TempChipFactor and TempChipOffset; where the finished value lands outside the band a detector can physically be at, there is no reading. Measured on a PI 450 (hardware revision 410) and a PI 640i (602), whose counts run far above the converter's width. The SDK logs that once per connection at error level, naming the unit's factor, offset and finished value, because it should be a defect with a cause rather than a routine outcome.

None says nothing about the rest of the frame. flag_temp_c, box_temp_c, flag_open, sequence and timestamp_us are all still this frame's: one unreadable probe is a fact about that probe.

Never None from the simulated camera. From a recording it is None exactly when the file carries no detector reading for that frame, so a replay answers the same question a camera does. An alarm rule on optris_sdk.FIELD_CHIP_TEMP reads optris_sdk.ALARM_ORPHANED on such a frame rather than comparing its limits with a zero.

flag_open

Whether the shutter was open when this frame was taken.

thermal_data_reliable

Whether this frame is a measurement at all.

False until the camera's startup calibration has finished and the detector has stopped warming, and again after a mode switch. The first frames clamp to the top of the camera's range (a flat 125 C on a PI 4x0 in a 25 C room); the ones after can drift by several kelvin at every shutter cycle while the camera warms.

How long that takes belongs to the camera rather than to a clock: one that has been running clears inside the startup calibration, about 18 s, while one switched on cold waits for its own warm-up -- about four and a half minutes on a PI 4x0 measured from cold. Skip frames until this is True.

Also False when the camera's raw data is not a picture at all: on every frame whose raw detector data is one value across the whole detector, and on every frame converted with a dark reference that is: a detector that has stopped reading out. Measured on an Xi 80 that sent 16383, the 14-bit full scale, for every pixel of every frame with the shutter open and shut; the temperatures computed from it looked like a plausible 26 to 37 C picture. The SDK logs an error once when this starts and once when it clears, and keeps this False for a few frames after the data varies again. No real scene can cause it: every working detector pixel has an offset of its own, even looking at the closed shutter.

From a recording it is what the camera said when the frame was recorded, so the startup frames of a recording replay as False too; a recording made by SDK 12.0.8 or earlier does not carry it, and every frame of one is True. From a still (Camera.open_still, Snapshot.load_thermal) it is what the file records about the frame it was saved from, so a snapshot of a frame that was not a measurement reads back as False. Every PNG and TIFF snapshot records it from 12.0.17 on; a file that does not (a TIFF, or a PNG saved before the camera had drawn a picture, by 12.0.16 or earlier) reads as True. SDK 12.0.14 and earlier read every still as True, whatever its file said. Always True from the simulated camera, except on the frames that the environment variables OTC_SIM_UNRELIABLE_FRAMES and OTC_SIM_SATURATED_FRAMES ask for.

detector_settling

What the SDK concluded about the detector's warm-up.

One of DETECTOR_SETTLING_UNKNOWN (0), DETECTOR_SETTLING_SETTLING (1) or DETECTOR_SETTLING_SETTLED (2).

thermal_data_reliable is this reduced to a bool together with four unrelated conditions, and the reduction loses the half you need to explain a reading. That flag is False for five different reasons -- no dark reference yet, the startup calibration still running, the detector still moving, raw data that is one value across the detector, or the camera's calibration missing -- and it is True on a camera whose detector the SDK cannot judge at all. So "this frame is a measurement" and "the SDK checked the detector" are different claims, and this property is the second one.

Read it to disclose, not to gate. Nothing is withheld on DETECTOR_SETTLING_UNKNOWN, deliberately: a frame format with too few metadata pixels to decode telemetry carries no detector reading at all -- a PI 160x120 at 100 Hz has two metadata pixels, and it is a configuration Optris ships -- so resolving "cannot tell" to "not settled" would leave it publishing nothing, firing no alarm rule and driving no analog output.

DETECTOR_SETTLING_UNKNOWN from a recording and from the simulated camera, which run no settling criterion.

DETECTOR_SETTLING_SETTLED is not "fully settled". Optris's own figure for a full thermal settle is 60 to 90 minutes, which is a policy statement rather than something the SDK measures. What the criterion answers is whether the violent part of the warm-up has stopped. An application that needs the hour owns that clock.

is_repeated_frame

Whether this frame repeats the previous one.

Count this, not callbacks, when you care how often the scene was actually measured. While the shutter flag is in the way of the sensor -- a calibration cycle, or a process interface holding it shut -- the SDK keeps the stream going by delivering the last frame taken with the flag open, again. Also True for a few frames after the flag reopens, which hides a shutter that bounces as it settles.

The metadata beside it is not held: the timestamp, the probe temperatures and flag_open are all this frame's. Only the pixels, the picture drawn from them, min_c/max_c and the region and field statistics are held, and all of those together, so one delivered frame always describes one captured frame.

Not the same question as thermal_data_reliable: a repeat was converted with a dark reference that exists and has settled, so it is reliable and it is not new. Always False from a recording and the simulated camera. See Camera.measured_frame_rate for the rate of frames that are not repeats.

min_c

max_c

extremes_known

Whether this frame has a coldest and warmest pixel at all.

False when nothing in the frame was measurable, and then min_c, max_c, min_index and max_index are all 0 -- which is not a coldest pixel of 0.0 degC in the top-left corner. In Fahrenheit min_c and max_c are NaN instead, so they never read as 32 F. The same distinction chip_temp_c draws by answering None.

Not a rare case: radial distortion correction in Wide mode leaves about a sixth of every frame unmeasurable by design, and a whole frame can be unmeasurable before the startup calibration finishes.

min_index

Where min_c is, as a linear index into the pixels.

The same index samples and to_numpy use. Only a pixel when extremes_known is true.

Prefer min_location. The arithmetic used to be described here as divmod(frame.min_index, frame.width), which is correct about divmod and hands back (y, x) -- the reverse of the (x, y) every other binding's helper returns. Doing it for you is how that stops mattering.

max_index

Where max_c is, as a linear index into the pixels.

Only a pixel when extremes_known is true; see min_index.

min_location

Where the coldest measured pixel is, as (x, y).

None when the frame had nothing measurable in it. Row-major from the top-left, and (x, y) -- the same order the .NET, C++ and Rust helpers use, which the divmod spelling this replaces did not.

max_location

Where the warmest measured pixel is, as (x, y).

None when the frame had nothing measurable; see min_location.

Frame — methods

celsius(x, y)

The temperature at one pixel, in the SDK's temperature unit (Celsius unless optris_sdk.set_temperature_unit chose Fahrenheit); the name is older than the switch.

Convenient for a handful of probes. For a whole frame use to_numpy, which converts without a call per pixel.

samples()

The raw fixed-point samples, without copying.

Returns a ctypes array viewing the SDK's memory. Nothing is copied, which is the point: at 32 Hz on a 640x480 sensor, copying every frame is 19 MB/s of pure overhead. The view is only as valid as the frame.

These are the internal format, not temperatures, and the sentinel lives here: a pixel the SDK could not measure reads -32768. For temperatures call temperatures or to_numpy, which convert the whole frame and answer nan for such a pixel.

temperatures()

The whole frame in the SDK's temperature unit, needing no NumPy.

A ctypes float array of width * height values, row-major from the top-left. The SDK converts it -- this binding does not apply the fixed-point formula itself, which is deliberate twice over: the scale is the SDK's internal business and may change, and a pixel the SDK could not measure comes back as nan rather than as the plausible-looking -3376.8 that converting samples by hand produces.

That is not a hypothetical. Until the SDK grew a bulk float reader this package converted frames itself, and to_numpy(celsius=True) returned -3376.8 for every pixel radial distortion correction could not measure -- 1.9 % of a PI 640i frame and 15.8 % of a G7 frame, on every frame.

Note that nan propagates: min() or statistics.mean() over this array is nan if any pixel was unmeasured. That is a loud wrong answer rather than a quiet one. For the coldest pixel that was measured read min_c, which excludes them.

to_numpy(celsius = True)

The frame as a 2-D NumPy array.

With celsius=True (the default) this is a new float array in the SDK's temperature unit (Celsius unless optris_sdk.set_temperature_unit chose Fahrenheit; the argument's name is older than the switch), converted by the SDK -- so a pixel it could not measure is nan. Use numpy.nanmean() and friends, or min_c for the coldest measured pixel.

With celsius=False it is an int16 view of the SDK's own memory in the internal format -- no copy, only valid while the frame is, and carrying -32768 where the SDK could not measure. That format is Celsius-based in either unit; decode it with internal_to_celsius.

NumPy is an optional dependency: everything else in this package works without it, including temperatures.

clone()

An owned copy, valid until it is closed.

This is how a frame outlives the callback it arrived in.

close()

Release an owned frame. A borrowed one is merely invalidated.

__enter__()

__exit__(*exc)

__del__()

__repr__()