optris::sdk::ThermalFrame
Thermal frame containing calibrated temperature data. Internal format: internal = (celsius * 10) + 1000 Conversion: T_celsius = (internal - 1000) / 10.0
Public functions
ThermalFrame
ThermalFrame()=default
ThermalFrame
ThermalFrame(uint32_t width, uint32_t height)
GetWidth
auto GetWidth() const -> uint32_t
GetHeight
auto GetHeight() const -> uint32_t
GetPixelCount
auto GetPixelCount() const -> uint32_t
GetMetadata
auto GetMetadata() const -> const FrameMetadata &
GetMetadata
auto GetMetadata() -> FrameMetadata &
GetTemperature
auto GetTemperature(uint32_t x, uint32_t y) const -> float
Temperature at (x, y), in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit).
A pixel outside the frame reads as NaN rather than reading past the buffer. This is not defensiveness about caller mistakes: the SDK delivers a 0x0 frame as the first frame on the GPU backend, so GetTemperature(GetWidth() / 2, GetHeight() / 2) -- the centre pixel, the most obvious thing to ask for, and what the documented examples do -- segfaulted inside the SDK on a frame the SDK itself had just handed over.
A pixel the SDK could not measure also reads as NaN. Radial distortion correction in Wide mode leaves 15.8% of a G7 frame with no source inside the sensor, and those pixels hold kInvalidPixel; converting one would give -3376.8 C, which reads as a measurement. Test with std::isnan(), or reach for the raw buffer and optris::sdk::IsMeasurablePixel() if you want to tell "outside the frame" from "not measured".
GetTemperature
auto GetTemperature(uint32_t index) const -> float
Temperature at a linear index, in the SDK's temperature unit. Out of range, and a pixel that could not be measured, both read as NaN, for the reasons above.
GetMinTemperature
auto GetMinTemperature() const -> float
Coldest and warmest MEASURABLE pixel in the frame, in the SDK's temperature unit as it was when the SDK handed you the frame (AcquireFrame(), a frame callback, rec::Snapshot::LoadThermal()).
The SDK writes these two into your frame as it hands it over, so a frame you took before calling SetTemperatureUnit() keeps the unit it was taken in; GetTemperature() answers in the unit in force when you call it. Take a new frame after switching. A frame you fill yourself with SetSceneStats() reads back what you put in.
Unmeasurable pixels are excluded, so on a Wide-mode frame these describe the ~84% of the field that was measured. A frame with nothing measurable in it reports 0 for both in Celsius, and NaN in Fahrenheit, where 0 would read as 32 F.
GetMaxTemperature
auto GetMaxTemperature() const -> float
GetMinIndex
auto GetMinIndex() const -> uint32_t
Linear index of the coldest measured pixel.
Only a pixel when AreExtremesKnown() is true. Otherwise it is 0, which is not the top-left corner. Prefer MinLocation(), which does the row-major arithmetic and answers nothing when there is no such pixel.
GetMaxIndex
auto GetMaxIndex() const -> uint32_t
Linear index of the warmest measured pixel. Only a pixel when AreExtremesKnown() is true; see GetMinIndex().
AreExtremesKnown
auto AreExtremesKnown() const -> bool
Whether this frame has extremes at all.
False when nothing in the frame was measurable, and then GetMinIndex(), GetMaxIndex(), GetMinTemperature() and GetMaxTemperature() are all 0 (the two temperatures NaN in Fahrenheit) -- which is not a coldest pixel of 0.0 C at the corner. The same distinction chip_temp_known draws for the detector temperature, and for the same reason: 0 is a legitimate value, so it cannot also mean "no value".
MinLocation
auto MinLocation() const -> std::optional< PixelLocation >
Where the coldest measured pixel is, or nothing.
Row-major from the top-left. Takes no index, which is the point: there is no out-of-range case to have a behaviour for, and the three bindings that had this arithmetic had three different edge behaviours between them.
MaxLocation
auto MaxLocation() const -> std::optional< PixelLocation >
Where the warmest measured pixel is, or nothing.
GetFlagTemperature
auto GetFlagTemperature() const -> std::optional< float >
The shutter flag's temperature for this frame, in the SDK's temperature unit, or nothing when the frame carries no such reading (FrameMetadata::flag_temp_known).
GetMetadata() holds the same reading in Celsius, as the camera reported it: FrameMetadata is the record a frame shares with every consumer, and it does not follow SetTemperatureUnit(). These four getters do.
GetBoxTemperature
auto GetBoxTemperature() const -> std::optional< float >
The housing temperature, in the SDK's temperature unit, or nothing (FrameMetadata::box_temp_known).
GetChipTemperature
auto GetChipTemperature() const -> std::optional< float >
The detector (chip) temperature, in the SDK's temperature unit, or nothing (FrameMetadata::chip_temp_known).
GetAmbientTemperature
auto GetAmbientTemperature() const -> std::optional< float >
The ambient temperature this frame was computed with, in the SDK's temperature unit, or nothing (FrameMetadata::ambient_temp_valid).
CopyTemperaturesTo
auto CopyTemperaturesTo(Span< float > destination) const -> size_t
Every pixel's temperature in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit), written into your buffer.
The bulk counterpart of GetTemperature(), and the call to reach for when you want a whole frame as floats. It answers the same way per pixel -- a pixel the SDK could not measure is written as NaN -- so a buffer filled by this and a loop of GetTemperature(i) are the same numbers.
Prefer it over converting GetData() yourself, for two reasons that have both cost somebody already:
- The scale is not yours to carry.
(raw - 1000) / 10is the SDK's internal fixed-point format, not part of what a temperature is, and it may change. A caller that asks for floats keeps getting floats; one that transcribed the formula has to be found and edited. - The sentinel is easy to forget.
GetData()carries kInvalidPixel, which that formula turns into a plausible-looking -3376.8 C. Two of this SDK's own bindings converted a frame in a loop without guarding it, and both handed -3376.8 to an application as a reading.
Parameters
| Name | Description |
|---|---|
destination |
Where to write, at least GetPixelCount() floats, row-major from the top-left. |
Returns: How many temperatures were written. Zero, with nothing written, when destination is smaller than GetPixelCount() -- a short buffer is refused rather than partly filled, so a caller cannot mistake a truncated frame for a whole one.
The allocating form is one line, and is what the bindings' ToArray-shaped calls do:
std::vector<float> temperatures(frame.GetPixelCount()); frame.CopyTemperaturesTo(temperatures);
Note what the NaN does to a statistic taken over the whole buffer: std::min_element and an accumulated mean both propagate it. That is deliberate -- a loud wrong answer rather than a quiet one -- but if what you want is the coldest pixel that was measured, GetMinTemperature() already excludes them and costs nothing.
GetData
auto GetData() const -> const int16_t *
Get raw data pointer (internal format).
The SDK's internal fixed-point samples, not temperatures, and the sentinel lives here: a pixel the SDK could not measure carries kInvalidPixel. For temperatures use CopyTemperaturesTo() above, which converts the whole frame and answers NaN for such a pixel; this accessor exists for a caller that wants the samples themselves, without a copy.
GetMutableData
auto GetMutableData() -> int16_t *
Get mutable raw data pointer.
GetDataSize
auto GetDataSize() const -> size_t
Get raw data element count.
Resize
auto Resize(uint32_t width, uint32_t height) -> void
SetSceneStats
auto SetSceneStats(float min_c, float max_c, uint32_t min_idx, uint32_t max_idx, bool extremes_known) -> void
Record the scene extremes and whether they are extremes at all.
The library calls this in Celsius on its own frames and converts a frame's extremes into the SDK's unit when it hands the frame over; it never reads back the extremes of a frame you pass in.
extremes_known has no default on purpose. Every producer here already knew the answer and threw it away -- client_bridge.h counts the measurable pixels and zeroes the temperatures when the count is nought, two lines above this call -- and a defaulted parameter would let the next producer not decide.