These are the pre-v12 classes, kept so existing code keeps building. New code should use the modern API — see Migration Guide: v11 to v12.
optris::Sdk
Deprecated
Legacy SDK initialization; the new API auto-initializes. Static helpers for logging, calibration sources, and palette loading.
Text encoding of paths. Every path this class takes as a std::string is read in the platform's own narrow encoding, as it was in version 11: UTF-8 on Linux, and the ANSI code page on Windows (code page 1252 on a Western system). That is kept so that an existing caller's files stay where they are. On Windows it means that a folder whose name the code page cannot hold (a Chinese or Cyrillic name on a Western system) cannot be named through these functions at all. The functions ending in Utf8 (setCustomDataDirectoryUtf8(), setCalibrationFileSourceDirectoryUtf8() and loadPalettesUtf8()) read UTF-8 on every platform, like the version 12 API, and reach any folder.
Public types
LogCallback
void(OTC_SDK_C_CALL *)(int verbosityLevel, const char *message) LogCallback
Callback function type for receiving SDK log messages.
Parameters
| Name | Description |
|---|---|
verbosityLevel |
0=Error, 1=Warning, 2=Info, 3=Debug, 4=Trace. |
message |
the log message text. |
Public static functions
init
static OTC_SDK_API void init(Verbosity logScreen, Verbosity logFile, std::string logFilenamePrefix="", std::string customDataDirectory="")
Initializes the SDK. It sets the verbosity levels of the internal logger of the SDK, starts the EnumerationManager in a dedicated thread to monitor the availability of devices, and loads color palettes from the SDK, working, and user palette directories.
Parameters
| Name | Description |
|---|---|
logScreen |
defines the minimum verbosity level of log messages displayed on the standard output and error. |
logFile |
defines the minimum verbosity level of log messages out to the logfile. |
logFilenamePrefix |
for the log file <logFilenamePrefix>_<YYYY_MM_DDThh-mm-ss>.log. If empty, it defaults to "OtcSDK". |
customDataDirectory |
for the SDK to use. An empty string will have no effect. The SDK requires read and write access to this directory. For detail on how specify it see Sdk::setCustomDataDirectory(). Read in the platform's narrow encoding (the ANSI code page on Windows). For a folder in UTF-8, pass an empty string here and call setCustomDataDirectoryUtf8() and then loadPalettes(). |
configureLogger
static OTC_SDK_API void configureLogger(Verbosity logScreen, Verbosity logFile, std::string logFilenamePrefix="")
Configures the SDK internal logger. If you change the logFilenamePrefix from the one used in Sdk::init() or in a previous call to Sdk::configure(), the current log file will be closed and new one will be created.
Parameters
| Name | Description |
|---|---|
logScreen |
defines the minimum verbosity level of log messages displayed on the standard output and error. |
logFile |
defines the minimum verbosity level of log messages out to the logfile. |
logFilenamePrefix |
for the log file <logFilenamePrefix>_<YYYY_MM_DDThh-mm-ss>.log. If empty, it defaults to "OtcSDK". |
setLogCallback
static OTC_SDK_API void setLogCallback(LogCallback callback, bool exclusive=false)
Sets a callback that receives SDK log messages.
Parameters
| Name | Description |
|---|---|
callback |
function pointer to invoke on each log message, or nullptr to remove. |
exclusive |
when true, disables file and screen output while the callback is active. |
Note: Must not be called from inside the callback itself: this waits for any callback in flight to return, so it would wait for itself. Doing so throws std::logic_error. It used to deadlock.
Note: optris::sdk::SetLogHandler() is the version 12 equivalent. Both are served by one sink and may be used together; note that the level numbering is reversed between them.
setCustomDataDirectory
static OTC_SDK_API void setCustomDataDirectory(const std::string &customDataDirectory)
Sets a custom data directory for the SDK to use.
Attention: A custom data directory can only be set when there are no active device connections. If the given directory does not exist, the SDK will try to create it (recursively). When specifying the directory path the following symbols/variables are supported: - ~, %USERPROFILE% refer to ~/ on Linux and <User Home>/ on Windows. - %APPDATA% refers to ~/.config/ on Linux and <User AppData>/Roaming/ on Windows. Relative paths are not supported. You can either use / as system independet directory separator or utilize system dependent ones like / for Linux and \ on Windows.
Parameters
| Name | Description |
|---|---|
customDataDirectory |
for the SDK to use. An empty string will have no effect. The SDK requires read and write permission to this directory. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if - there is an active device connection. - the given path is not a directory. - the SDK can not access the directory - the SDK failed to create the directory. |
Note: On Windows the string is read in the ANSI code page, as in version 11, so a folder whose name that code page cannot hold cannot be named here. setCustomDataDirectoryUtf8() reads UTF-8.
setCustomDataDirectoryUtf8
static OTC_SDK_API void setCustomDataDirectoryUtf8(const std::string &utf8Path)
Sets a custom data directory for the SDK to use, given in UTF-8. Does exactly what setCustomDataDirectory() does, but reads the path as UTF-8 on every platform, so any folder can be named, including one whose name the Windows ANSI code page cannot hold. On Linux the two functions are the same. The same symbols (~, %USERPROFILE%, %APPDATA%) are supported.
Parameters
| Name | Description |
|---|---|
utf8Path |
the directory, in UTF-8. An empty string will have no effect. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if - the string is not valid UTF-8 (Windows). - there is an active device connection. - the given path is not a directory. - the SDK can not access the directory - the SDK failed to create the directory. |
clearCustomDataDirectory
static OTC_SDK_API void clearCustomDataDirectory()
Clears a previously set custom data directory for the SDK. Once cleared the SDK reverts to the default user data directory:
- Linux
~/.config/optris/ - Windows
<User AppData>/Roaming/Imager/Exceptions | Name | Description | | --- | --- | |SDKException| if there is an active device connection or if the default user data directory path could not be determined. |
setCalibrationFileSources
static OTC_SDK_API bool setCalibrationFileSources(CalibrationFileSource first, CalibrationFileSource second, CalibrationFileSource third)
Sets the priority of the calibration file sources. The priority of the sources needs to be set prior to connecting to a device. If you want to use less than three potential calibration file source, set the one you do not require to Empty. The different sources have individual requirements for them to work:
- Device. Not all types of Optris cameras have their calibration files stored on-device.
- Filesystem. The source directory should be accessible and the SDK should have the rights to copy the calibration files from it to their target destination. The source directory needs to be specified via the
Sdk::setCalibrationFileSourceDirectory()method. - Internet. Access to the internet is required.
- User. The client is asked for a directory through the
ConnectionState::CaliCopySourceDirectorycallback. Note: The SDK does not yet feature the ability to download the calibration from the device. Parameters | Name | Description | | --- | --- | |first| source with the highest priority. | |second| source with a medium priority. | |third| source with the lowest priority. | Returns: true, if priority was successfully set. False, otherwise.
setCalibrationFileSources
static OTC_SDK_API bool setCalibrationFileSources(const std::vector< CalibrationFileSource > &sources)
Sets the priority of the calibration file sources from an ordered list. This is the flexible counterpart to the fixed-arity overload: it accepts any number of sources, in any order, allowing the CalibrationFileSource::User prompt to be placed independently of the other sources. CalibrationFileSource::Empty entries are ignored. The sources are tried from the front of the list to the back. See the three-parameter overload for the individual source requirements.
Parameters
| Name | Description |
|---|---|
sources |
ordered list of calibration file sources to try, highest priority first. |
Returns: true, if at least one non-Empty source was set. False otherwise (the previous configuration is then kept).
setCalibrationFileSourceDirectory
static OTC_SDK_API void setCalibrationFileSourceDirectory(const std::string &sourceDirectory)
Sets the source directory from which calibration files can be copied. When specifying the directory path the following symbols/variables are supported:
~,%USERPROFILE%refer to~/on Linux and<User Home>/on Windows.%APPDATA%refers to~/.config/on Linux and<User AppData>/Roaming/on Windows. Relative paths are not supported. You can either use/as system independet directory separator or utilize system dependent ones like/for Linux and\on Windows. Parameters | Name | Description | | --- | --- | |sourceDirectory| from which calibration files can be copied. An empty string will have no effect. | Exceptions | Name | Description | | --- | --- | |SDKException| if the given path does not exist or is not a directory. | Note: On Windows the string is read in the ANSI code page, as in version 11, so a folder whose name that code page cannot hold cannot be named here.setCalibrationFileSourceDirectoryUtf8()reads UTF-8.
setCalibrationFileSourceDirectoryUtf8
static OTC_SDK_API void setCalibrationFileSourceDirectoryUtf8(const std::string &utf8Path)
Sets the source directory from which calibration files can be copied, given in UTF-8. Does exactly what setCalibrationFileSourceDirectory() does, but reads the path as UTF-8 on every platform, so any folder can be named, including one whose name the Windows ANSI code page cannot hold. On Linux the two functions are the same. The same symbols (~, %USERPROFILE%, %APPDATA%) are supported.
Parameters
| Name | Description |
|---|---|
utf8Path |
the directory, in UTF-8. An empty string will have no effect. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if the string is not valid UTF-8 (Windows), or if the given path does not exist or is not a directory. |
clearCalibrationFileSourceDirectory
static OTC_SDK_API void clearCalibrationFileSourceDirectory()
Clears a previously set source directory for calibration files. When cleared, the SDK will skip the CalibrationFileSource::Filesystem option when acquiring calibration files.
addCalibrationFallbackServer
static OTC_SDK_API void addCalibrationFallbackServer(const std::string &url)
Registers an additional server the CalibrationFileSource::Internet source may download calibration files from.
The Internet source always starts with the built-in servers https://calibration.optris.com/api and the mirror https://calibration.optris-ir.cn/api. Servers registered here are tried after those, in registration order (for a site that keeps a company-internal mirror).
A registered server must mirror the REST layout of the built-in ones, including the Digest: sha-256=... response header used to verify what arrived. The URL must use https:// and carry the full API base path; the SDK appends /healthz and /v1/calibration/... to it.
optris::Sdk::addCalibrationFallbackServer( "https://mirror.example.com/api");
Note: The internet-access consent requested via ConnectionState::CaliAccessInternet covers all configured servers, the built-in ones and these alike. A client that declines it reaches none of them.
Parameters
| Name | Description |
|---|---|
url |
of the mirror, including the API base path. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if the URL is empty, does not start with https://, contains whitespace, a query or a fragment, or if the registration limit (8) is reached. A URL that is already built in or already registered is ignored with a warning. |
clearCalibrationFallbackServers
static OTC_SDK_API void clearCalibrationFallbackServers()
Removes all servers registered via Sdk::addCalibrationFallbackServer(). The built-in servers are unaffected and always remain active.
getCalibrationFallbackServers
static OTC_SDK_API std::vector< std::string > getCalibrationFallbackServers()
Returns the servers registered via Sdk::addCalibrationFallbackServer(), in registration order.
Returns: the registered fallback servers. Built-ins are not included.
getVersionInfo
static OTC_SDK_API VersionInfo getVersionInfo()
Returns an object holding version and build information about the SDK.
Returns: object holding version and build information about the SDK.
loadPalettes
static OTC_SDK_API void loadPalettes()
Loads palettes from the SDK and user palette directories. Scans the SDK data directory first, then the user data directory so that user-supplied palettes with the same name override the built-in ones. Missing directories are silently skipped. This method is idempotent: calling it more than once reloads all palettes from disk, replacing any previously registered entries.
loadPalettes
static OTC_SDK_API void loadPalettes(const std::string &directory)
Loads palettes from a custom directory. Adds or overwrites palette entries in the registry without clearing previously loaded palettes. When specifying the directory path the following symbols/variables are supported:
~,%USERPROFILE%refer to~/on Linux and<User Home>/on Windows.%APPDATA%refers to~/.config/on Linux and<User AppData>/Roaming/on Windows. Relative paths are not supported. You can either use/as system independet directory separator or utilize system dependent ones like/for Linux and\on Windows. Parameters | Name | Description | | --- | --- | |directory| path to scan for.csvpalette files. | Exceptions | Name | Description | | --- | --- | |SDKException| ifdirectorydoes not exist or is not a directory. | Note: On Windows the string is read in the ANSI code page, as in version 11, so a folder whose name that code page cannot hold cannot be named here.loadPalettesUtf8()reads UTF-8.
loadPalettesUtf8
static OTC_SDK_API void loadPalettesUtf8(const std::string &utf8Path)
Loads palettes from a custom directory, given in UTF-8. Does exactly what loadPalettes(const std::string &) does, but reads the path as UTF-8 on every platform, so any folder can be named, including one whose name the Windows ANSI code page cannot hold. On Linux the two functions are the same. The same symbols (~, %USERPROFILE%, %APPDATA%) are supported.
Parameters
| Name | Description |
|---|---|
utf8Path |
path to scan for .csv palette files, in UTF-8. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if the string is not valid UTF-8 (Windows), or if the directory does not exist or is not a directory. |
getPaletteNames
static OTC_SDK_API std::vector< std::string > getPaletteNames()
Returns the names of all currently loaded palettes in sorted order.
Returns: sorted list of palette name strings.
getPaletteColors
static OTC_SDK_API std::vector< std::array< uint8_t, 3 > > getPaletteColors(const std::string &name)
Returns the 240 RGB color entries of the named palette. Each entry is an array of three bytes: { R, G, B }.
Parameters
| Name | Description |
|---|---|
name |
palette name (case-sensitive). |
Returns: vector of 240 RGB triples.
Exceptions
| Name | Description |
|---|---|
SDKException |
if the palette is not found. |
registerPalette
static OTC_SDK_API void registerPalette(const std::string &name, const std::vector< std::array< uint8_t, 3 > > &colors)
Registers a palette at runtime without persisting it to disk. An existing palette with the same name is overwritten.
Parameters
| Name | Description |
|---|---|
name |
unique palette name. |
colors |
exactly 240 RGB triples { R, G, B }. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if colors does not contain exactly 240 entries. |
savePalette
static OTC_SDK_API void savePalette(const std::string &name)
Saves a registered palette as a CSV file in the user palette directory. The output filename is <name>.csv. The user palette directory is not created: saving into a directory that does not exist throws.
Parameters
| Name | Description |
|---|---|
name |
palette name to save (case-sensitive). |
Exceptions
| Name | Description |
|---|---|
SDKException |
if the palette is not found or the file cannot be written. |
Public functions
Sdk
Sdk()=delete
No constructor.