Thermal Camera SDK 10.0.1
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
TemperatureConverter.h
Go to the documentation of this file.
1// Copyright (c) 2025 Optris GmbH Co. KG
2
11
12#pragma once
13
14#include "otcsdk/Api.h"
16
17
18namespace optris
19{
20
23{
24public:
27
34
35
42
48 TemperaturePrecision getPrecision() const noexcept;
49
57 float toTemperature(float value) const noexcept;
58
66 unsigned short toValue(float temperature) const noexcept;
67
75 bool isTemperatureValid(float temperature) noexcept;
76
84 bool isValueValid(unsigned short value) noexcept;
85
86
87private:
88 TemperaturePrecision _precision;
89
90 float _factor;
91 float _offset;
92};
93
94
95// Inline implementations
97{
98 return _precision;
99}
100
101inline float TemperatureConverter::toTemperature(float value) const noexcept
102{
103 return value / _factor + _offset;
104}
105
106inline unsigned short TemperatureConverter::toValue(float temperature) const noexcept
107{
108 return static_cast<unsigned short>((temperature - _offset) * _factor);
109}
110
111inline bool TemperatureConverter::isTemperatureValid(float temperature) noexcept
112{
113 return temperature > INVALID_TEMPERATURE;
114}
115
116inline bool TemperatureConverter::isValueValid(unsigned short value) noexcept
117{
118 return value > INVALID_VALUE;
119}
120
121} // namespace optris
Contains defines controlling the Windows DLL export and import of symbols.
#define OTC_SDK_API
Only needed when working with Windows DLLs.
Definition Api.h:65
Contains an enum representing the different temperature precisions and constants denoting invalid tem...
bool isValueValid(unsigned short value) noexcept
Checks if an internal value is valid.
Definition TemperatureConverter.h:116
OTC_SDK_API TemperatureConverter() noexcept
Constructor.
float toTemperature(float value) const noexcept
Converts an internal value to a temperature in °C.
Definition TemperatureConverter.h:101
TemperaturePrecision getPrecision() const noexcept
Returns the temperature precision.
Definition TemperatureConverter.h:96
unsigned short toValue(float temperature) const noexcept
Converts a temperature in °C to an internal value.
Definition TemperatureConverter.h:106
OTC_SDK_API void setPrecision(TemperaturePrecision precision) noexcept
Set the temperature precision.
bool isTemperatureValid(float temperature) noexcept
Checks if the given temperature in °C is valid.
Definition TemperatureConverter.h:111
Main SDK namespace.
Definition DeviceInfo.h:23
static constexpr float INVALID_TEMPERATURE
All temperatures in °C equal or lower are invalid.
Definition TemperaturePrecision.h:21
static constexpr unsigned short INVALID_VALUE
All internal temperature values equal to this are invalid.
Definition TemperaturePrecision.h:24
TemperaturePrecision
Represents the available temperature precisions.
Definition TemperaturePrecision.h:29