Temperatures in Fahrenheit
One call switches the whole SDK to degrees Fahrenheit. Every temperature your program reads from then on is in Fahrenheit, and every temperature it hands the SDK is taken as Fahrenheit: frames, measuring areas, alarm limits, the colour range, camera settings, and what a recording or a snapshot says about itself. Nothing else in your program converts. Celsius is the default, so a program that never makes the call sees nothing change.
On this page
- Switching the SDK to Fahrenheit
- What follows the unit
- A temperature and a difference
- What stays in Celsius
- The text the SDK draws itself
- Changing the unit while cameras run
- Converting one number yourself
Switching the SDK to Fahrenheit
Make the call once, at the start of your program, before you open a camera. The _init functions of the C interface fill their defaults in the unit in force, so a C program sets the unit first.
optris::sdk::SetTemperatureUnit(optris::sdk::TemperatureUnit::kFahrenheit); // A measuring area's mean, in Fahrenheit. const auto region = imager->Regions().Get(region_id); const float mean_f = region ? region->stats.mean_c : 0.0F; // An alarm above 140 F, with 3.6 F of hysteresis (2 K). optris::sdk::Rule rule; rule.input = optris::sdk::SignalId::Region(0, optris::sdk::SignalField::kMax); rule.condition.compare = optris::sdk::Compare::kAbove; rule.condition.alarm.high = 140.0F; rule.condition.alarm.hysteresis = 3.6F; imager->Alarms().Add(region_id, std::move(rule));
optris_sdk_region_stats stats; optris_sdk_rule *rule = NULL; optris_sdk_signal_id input; optris_sdk_condition condition; uint64_t rule_id = 0; optris_sdk_set_temperature_unit(OPTRIS_SDK_TEMPERATURE_UNIT_FAHRENHEIT); /* A measuring area's mean, in Fahrenheit. */ optris_sdk_region_stats_init(&stats, sizeof(stats)); optris_sdk_imager_get_region_stats(imager, region_id, &stats); /* An alarm above 140 F, with 3.6 F of hysteresis (2 K). */ optris_sdk_rule_create(&rule); optris_sdk_signal_id_init(&input, sizeof(input)); input.domain = OPTRIS_SDK_SIGNAL_DOMAIN_REGION; input.field = OPTRIS_SDK_FIELD_MAX; optris_sdk_rule_set_input(rule, &input); optris_sdk_condition_init(&condition, sizeof(condition)); condition.compare = OPTRIS_SDK_COMPARE_ABOVE; condition.alarm.high = 140.0F; condition.alarm.hysteresis = 3.6F; optris_sdk_rule_set_condition(rule, &condition); optris_sdk_imager_add_rule(imager, region_id, rule, &rule_id); optris_sdk_rule_free(rule);
Sdk.TemperatureUnit = TemperatureUnit.Fahrenheit; using ThermalCamera camera = ThermalCamera.OpenSimulated( new SimulatedCameraOptions()); ulong regionId = camera.AddRegion( Region.Rect(new System.Numerics.Vector2(0.5f, 0.5f), new System.Numerics.Vector2(0.4f, 0.3f))); // A measuring area's mean, in Fahrenheit. float meanF = camera.GetRegionStats(regionId).Mean; // An alarm above 140 F, with 3.6 F of hysteresis (2 K). camera.AddRule(regionId, new AlarmRule { Input = SignalId.Region(SignalField.Max), Condition = AlarmCondition.Above(140.0f, 3.6f), });
optris_sdk.set_temperature_unit(optris_sdk.TEMPERATURE_UNIT_FAHRENHEIT) # A measuring area's mean, in Fahrenheit. mean_f = camera.regions.stats(region_id).mean_c # An alarm above 140 F, with 3.6 F of hysteresis (2 K). rule = optris_sdk.Rule( name='hot', input=optris_sdk.SignalId.region(optris_sdk.FIELD_MAX), condition=optris_sdk.Condition( compare=optris_sdk.COMPARE_ABOVE, alarm=optris_sdk.Limits(high=140.0, hysteresis=3.6))) camera.alarms.add(rule, region_id=region_id)
set_temperature_unit(TemperatureUnit::Fahrenheit)?; // A measuring area's mean, in Fahrenheit. let mean_f = camera.region_stats(region_id)?.mean_c; // An alarm above 140 F, with 3.6 F of hysteresis (2 K). let mut rule = Rule::new()?; rule.set_input(SignalId::region(SignalField::Max))?; rule.set_condition(Condition::above(140.0, 3.6))?; camera.add_rule(region_id, &rule)?;
A name that says Celsius, such as mean_c, threshold_c or to_numpy(celsius=True), follows the unit as well. The names are older than the switch and are kept so that no program has to change.
Every example that shows a temperature takes --fahrenheit and is built this way, in all five languages: one call before it opens a camera, the limits and scenes it sets written in Fahrenheit, and the letter it prints after each reading taken from the SDK's own answer to "which unit?". frames/minimal is the shortest of them. See Example Applications.
What follows the unit
Everything that crosses the interface as a temperature, in either direction, in all five languages:
| What | Follows the unit |
|---|---|
| A frame's pixels, its coldest and hottest point, its shutter, housing and detector temperatures | yes |
| A measuring area's minimum, maximum, mean, median, percentiles, line samples, blob temperatures, threshold and spot search band | yes |
| Alarm limits and the readings an alarm reports, for an alarm on a temperature | yes |
| The colour range, colour windows, motion zones | yes |
| The camera's temperature range and operation modes, the ambient temperature, the reference temperature, the chip heating setpoint | yes |
| A process interface channel that carries a temperature: its scaling, its clamps, its threshold, the value written to an output and the value decoded from an input | yes |
| What a recording, a snapshot or a RAVI file says about itself, read back | yes |
| The settings of a simulated camera and of a video export | yes |
| A standard deviation, a hysteresis, the limits of an alarm that compares against another reading, the bands of the automatic colour scale | yes, as a difference |
| An alarm on something that is not a temperature: a coverage, an area, a pixel count, a voltage | no, it has its own unit |
| What a process interface has on its pins: an analog output read back, a snapshot's analog outputs, a raw analog input, the signal of an analog output | no, volts or milliamperes, even on a temperature channel |
A wire value is never a temperature. A process interface output configured to carry a temperature takes that temperature in the unit in force, and its gain and offset turn it into a level on the pin. Reading the output back answers that level, so it reads the same in both units: 50 °C written at 0.1 V per degree and 0.5 V at zero (122 °F in Fahrenheit) reads back 5.5 V either way. See What is on the wire.
A value that is not a reading is "not a number" in Fahrenheit. A percentile a measuring area was not asked to compute, a median nobody asked for, a probe the camera does not report: in Celsius they are what they always were, and in Fahrenheit they are NaN, because the zero they carry would read as 32 degrees and look like a measurement. The flag beside each one (valid, *_known) is still the test to make.
A temperature and a difference
They are converted differently, and the SDK does it for you. A temperature is a point on the scale: °F = °C × 9/5 + 32. A difference is a distance on it: °F = K × 9/5, with no offset. So a hysteresis of 2 K is 3.6 °F, not 35.6 °F, and an alarm that compares a region against another region (a rule with a reference) has limits that are differences. The alarms page and the region statistics page say which of their numbers is which.
What stays in Celsius
| What | Unit |
|---|---|
| Recordings, snapshots, the configuration file, the region and alarm files | °C, whichever unit your program uses. The same frame and the same settings write the same bytes in either unit, so a file means the same on every computer, and a recording made by a Fahrenheit program replays correctly in a Celsius one and the other way round |
| A CSV snapshot | its own setting, temperature_unit in CsvOptions, °C by default. See Snapshots and Interval Capture |
The raw samples and the functions that decode them (InternalToCelsius(), optris_sdk_internal_to_celsius(), ThermalFrame.ToCelsius(short), internal_to_celsius()) |
°C, because that is how the samples are defined |
In C++ only: FrameMetadata, the per-frame record a frame shares with every part of the SDK |
°C. ThermalFrame::GetFlagTemperature(), GetBoxTemperature(), GetChipTemperature() and GetAmbientTemperature() give the same readings in the unit |
In C++ only: the toolkit under optris::sdk::view and the version 11 measuring fields (Roi) |
they compute on the numbers you hand them, in whatever unit those are |
The version 11 interface (IRImager, Optris.OtcSdk) |
°C, as in version 11 |
| Log lines | °C, always with the unit written |
Defaults written into a C++ struct are Celsius numbers. RadiationConfig::ambient_temp_c starts at 20, which is 20 °C. In Fahrenheit, start from what the camera has (imager->Radiometry().Get() reads back in Fahrenheit) and change what you mean to change, rather than from a struct you built yourself. The C _init functions, and the constructors of the .NET, Python and Rust types that read their defaults from them, fill the defaults in the unit in force.
The text the SDK draws itself
The reading in a region's label drawn into the picture, and the sentence a JPEG snapshot opens with, follow the SDK's unit. A camera, a replay or a still can still choose its own unit for that text (SetDisplayTemperatureUnit() in C++, optris_sdk_imager_set_display_temperature_unit() in C, DisplayTemperatureUnit in .NET, display_temperature_unit in Python, set_display_temperature_unit() in Rust); once it has, its labels stay in that unit whatever the SDK's unit is. A program written for 12.0.24, which set only the label unit, behaves exactly as before.
Changing the unit while cameras run
Each value is converted with the unit in force at the moment it crosses the interface. The SDK stores every setting in Celsius, so a setting made before a change keeps its meaning and reads back in the new unit: an alarm limit set at 50 °C reads 122 °F after the switch, and the alarm fires where it always did. A callback that runs while the unit changes may see some values in each unit, which is why the call belongs at the start of a program. The call is safe from any thread.
A C++ frame's coldest and hottest point are the one exception. ThermalFrame::GetMinTemperature() and GetMaxTemperature() are written into the frame when the SDK hands it to you (AcquireFrame(), a frame callback, rec::Snapshot::LoadThermal()), so a frame you took before a change keeps the unit it was taken in, while its pixels (GetTemperature()) read in the unit in force when you ask. Take a new frame after switching. In C, C#, Python and Rust a frame's coldest and hottest point follow the unit in force when you read them, like everything else.
Converting one number yourself
The conversion functions stay for a program that has a number from somewhere else: Temperatures::FromCelsius(), ToCelsius(), FromKelvinDifference() and ToKelvinDifference() in C++, their optris_sdk_temperature_* counterparts in C, Temperatures in .NET, optris_sdk.temperatures in Python and optris_sdk::temperatures in Rust. Format() and FormatDifference() turn a Celsius number into text with the SDK's one rounding rule, so your text and the SDK's labels agree to the last digit; Symbol() gives °C or °F.