Thermal Camera SDK 11.4.10
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
ImageBuilder.h
Go to the documentation of this file.
1// Copyright (c) 2008-2026 Optris GmbH & Co. KG
2
11#pragma once
12
13#include <array>
14#include <cstdint>
15#include <vector>
16#include <string>
17
18#include "otcsdk/Api.h"
19
21#include "otcsdk/common/Image.h"
22
23
24namespace optris
25{
26
43struct OTC_SDK_API TemperatureRegion
44{
47
56 TemperatureRegion(int x1, int y1, int x2, int y2) noexcept;
57
59 void reset() noexcept;
60
70 bool fitsInRectangle(int width, int height, int padding = 0) const noexcept;
71
72
74 float temperature;
75
77 int x1;
79 int y1;
80
82 int x2;
84 int y2;
85};
86
87
90{
92 std::uint64_t value = 0;
94 std::uint32_t count = 0;
95};
96
97
98
101{
102 Manual,
103 MinMax,
104 Sigma1,
105 Sigma3,
106};
107
108
111{
112public:
114 using LookupTable = std::array<unsigned int, 65536>;
115
116
126 OTC_SDK_API ImageBuilder(ColorFormat colorFormat, WidthAlignment widthAlignment);
127
128
136 OTC_SDK_API void setThermalFrame(const ThermalFrame& thermalFrame);
137
143 const ThermalFrame& getThermalFrame() const noexcept;
144
150 int getWidth() const noexcept;
151
157 int getHeight() const noexcept;
158
168 OTC_SDK_API float getTemperature(int index) const;
169
183 OTC_SDK_API float getTemperature(int x, int y) const;
184
196 OTC_SDK_API bool getMeanTemperatureInRegion(TemperatureRegion& meanRegion);
197
210 OTC_SDK_API bool getMinMaxRegions(int radius, TemperatureRegion& minRegion, TemperatureRegion& maxRegion);
211
212
213 // Image conversion
225 OTC_SDK_API void setTemperatureScaling(float min, float max);
226
232 OTC_SDK_API float getTemperatureScalingMin() const noexcept;
233
239 OTC_SDK_API float getTemperatureScalingMax() const noexcept;
240
251 OTC_SDK_API float getTemperatureScalingMinFiltered() const noexcept;
252
259 OTC_SDK_API float getTemperatureScalingMaxFiltered() const noexcept;
260
272 OTC_SDK_API void setTemperatureScalingFilterFactor(float filterFactor);
273
279 OTC_SDK_API float getTemperatureScalingFilterFactor() const noexcept;
280
286 void setTemperatureScalingMode(TemperatureScalingMode mode) noexcept;
287
293 TemperatureScalingMode getTemperatureScalingMode() const noexcept;
294
306 OTC_SDK_API void setPalette(const std::string& name);
307
313 OTC_SDK_API std::string getPaletteName() const noexcept;
314
320 const Image& getImage() noexcept;
321
327 int getImageSizeInBytes() const noexcept;
328
336 int getImageStride() const noexcept;
337
344 OTC_SDK_API void copyImageDataTo(unsigned char* destination, int size) const noexcept;
345
351 OTC_SDK_API LookupTable createLookupTable();
352
353
355 OTC_SDK_API void convertTemperatureToPaletteImage();
356
362 OTC_SDK_API void convertTemperatureToPaletteImage(const LookupTable& lut);
363
373 OTC_SDK_API void convertTemperatureToPaletteImage(void* destination, int size);
374
375
376private:
378 static constexpr float DEFAULT_TEMPERATURE_SCALING_FILTER_FACTOR = 0.96F;
379
380
382 void calculateIntegralImage();
383
385 void calcMinMaxScalingFactor();
386
388 void updateMinValue(float filterFactor = 1.F);
389
391 void updateMaxValue(float filterFactor = 1.F);
392
398 void calcSigmaScalingFactor(float sigma);
399
405 void writeColorImage(unsigned char* dest);
406
408 void updateBgraPalette() noexcept;
409
410
412 ThermalFrame _thermalFrame;
414 TemperatureConverter _converter;
415
417 std::vector<IntegralPixel> _integral;
419 bool _integralIsDirty;
420
422 Image _image;
423
425 ImageInfo _imageInfo;
426
428 TemperatureScalingMode _scalingMode;
429
431 unsigned short _min;
432
434 unsigned short _max;
435
442 float _minFloat;
443
445 float _maxFloat;
446
450 float _minFiltered;
451
454 float _maxFiltered;
455
457 float _scalingFilterFactor;
458
460 std::string _paletteName;
462 std::array<std::array<uint8_t, 3>, 240> _paletteColors;
466 std::array<std::uint32_t, 240> _paletteColorsBgra;
467};
468
469
470// Inline implementations
471inline const ThermalFrame& ImageBuilder::getThermalFrame() const noexcept
472{
473 return _thermalFrame;
474}
475
476inline int ImageBuilder::getWidth() const noexcept
477{
478 return _thermalFrame.getWidth();
479}
480
481inline int ImageBuilder::getHeight() const noexcept
482{
483 return _thermalFrame.getHeight();
484}
485
486inline void ImageBuilder::setTemperatureScalingMode(TemperatureScalingMode mode) noexcept
487{
488 _scalingMode = mode;
489}
490
491inline TemperatureScalingMode ImageBuilder::getTemperatureScalingMode() const noexcept
492{
493 return _scalingMode;
494}
495
496inline std::string ImageBuilder::getPaletteName() const noexcept
497{
498 return _paletteName;
499}
500
501inline const Image& ImageBuilder::getImage() noexcept
502{
503 return _image;
504}
505
506inline int ImageBuilder::getImageSizeInBytes() const noexcept
507{
508 return _imageInfo.getHeight() * _imageInfo.getStride();
509}
510
511inline int ImageBuilder::getImageStride() const noexcept
512{
513 return _imageInfo.getStride();
514}
515
516} // namespace optris
Contains defines controlling the Windows DLL export and import of symbols.
Contains a class that encapsulates false color images.
Contains a class encapsulating a processed thermal frame.
OTC_SDK_API int getWidth() const noexcept
Returns the width in pixels of the frame.
Definition Frame.h:159
Creates false color images from thermal frames.
Definition ImageBuilder.h:111
std::array< unsigned int, 65536 > LookupTable
Type for look up tables.
Definition ImageBuilder.h:114
OTC_SDK_API ImageBuilder(ColorFormat colorFormat, WidthAlignment widthAlignment)
Constructor.
OTC_SDK_API void setThermalFrame(const ThermalFrame &thermalFrame)
Sets a new thermal frame.
Encapsulates all relevant information about a false color image.
Definition ImageInfo.h:60
Encapsulates false color images with 8-bit color depth.
Definition Image.h:37
OTC_SDK_API int getHeight() const noexcept
Returns the height of the image in pixels.
Definition Image.h:221
Converts temperatures in °C to and from their internal SDK representation.
Definition TemperatureConverter.h:23
Encapsulates processed thermal frame data.
Definition ThermalFrame.h:23
Main SDK namespace.
Definition AlarmChannel.h:21
ColorFormat
Represents the different available color formats.
Definition ImageInfo.h:32
TemperatureScalingMode
Represents the different mode to scale temperatures when generating a false color image.
Definition ImageBuilder.h:101
@ Sigma3
Same as Sigma1, but with factor 3.
@ MinMax
Dynamic determination of minimum and maximum temperature as upper and lower limit.
@ Manual
User-defined upper and lower limit (fixed values).
@ Sigma1
Dynamic determination of upper and lower limit from standard deviation of temperature image.
WidthAlignment
Represents the different available width alignments.
Definition ImageInfo.h:50
Helper struct for calculating an integral image.
Definition ImageBuilder.h:90
Characterizes a rectangular region by the indexes of the upper left and the lower right corners along...
Definition ImageBuilder.h:44
TemperatureRegion() noexcept
Constructor.