Thermal Camera SDK 11.3.0
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
10
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
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
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
107
108
111{
112public:
114 using LookupTable = std::array<unsigned int, 65536>;
115
116
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
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
252
260
273
280
287
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
352
353
356
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
407
409 ThermalFrame _thermalFrame;
411 TemperatureConverter _converter;
412
414 std::vector<IntegralPixel> _integral;
416 bool _integralIsDirty;
417
419 Image _image;
420
422 ImageInfo _imageInfo;
423
425 TemperatureScalingMode _scalingMode;
426
428 unsigned short _min;
429
431 unsigned short _max;
432
439 float _minFloat;
440
442 float _maxFloat;
443
447 float _minFiltered;
448
451 float _maxFiltered;
452
454 float _scalingFilterFactor;
455
457 std::string _paletteName;
459 std::array<std::array<uint8_t, 3>, 240> _paletteColors;
460};
461
462
463// Inline implementations
464inline const ThermalFrame& ImageBuilder::getThermalFrame() const noexcept
465{
466 return _thermalFrame;
467}
468
469inline int ImageBuilder::getWidth() const noexcept
470{
471 return _thermalFrame.getWidth();
472}
473
474inline int ImageBuilder::getHeight() const noexcept
475{
476 return _thermalFrame.getHeight();
477}
478
480{
481 _scalingMode = mode;
482}
483
485{
486 return _scalingMode;
487}
488
489inline std::string ImageBuilder::getPaletteName() const noexcept
490{
491 return _paletteName;
492}
493
494inline const Image& ImageBuilder::getImage() noexcept
495{
496 return _image;
497}
498
499inline int ImageBuilder::getImageSizeInBytes() const noexcept
500{
501 return _imageInfo.getHeight() * _imageInfo.getStride();
502}
503
504inline int ImageBuilder::getImageStride() const noexcept
505{
506 return _imageInfo.getStride();
507}
508
509} // 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 a class that encapsulates false color images.
Contains a class encapsulating a processed thermal frame.
OTC_SDK_API void setTemperatureScaling(float min, float max)
Sets the temperature range for the manual scaling mode.
OTC_SDK_API std::string getPaletteName() const noexcept
Returns the name of the currently active palette.
Definition ImageBuilder.h:489
const Image & getImage() noexcept
Grants read access to the generated false color image.
Definition ImageBuilder.h:494
OTC_SDK_API void setPalette(const std::string &name)
Sets the palette for the false color conversion by name.
const ThermalFrame & getThermalFrame() const noexcept
Grants read access to the stored thermal frame.
Definition ImageBuilder.h:464
TemperatureScalingMode getTemperatureScalingMode() const noexcept
Returns the current temperate scaling mode for the false color conversion.
Definition ImageBuilder.h:484
int getHeight() const noexcept
Returns the height in pixels of thermal frame.
Definition ImageBuilder.h:474
int getImageStride() const noexcept
Returns the image stride in bytes.
Definition ImageBuilder.h:504
std::array< unsigned int, 65536 > LookupTable
Type for look up tables.
Definition ImageBuilder.h:114
int getImageSizeInBytes() const noexcept
Returns the image size in bytes including potential width padding.
Definition ImageBuilder.h:499
OTC_SDK_API float getTemperatureScalingFilterFactor() const noexcept
Returns the low pass filter factor for the temperature scaling method.
OTC_SDK_API bool getMeanTemperatureInRegion(TemperatureRegion &meanRegion)
Returns the mean temperature in °C of a rectangular region.
OTC_SDK_API void convertTemperatureToPaletteImage()
Triggers the image conversion.
void setTemperatureScalingMode(TemperatureScalingMode mode) noexcept
Sets the temperature scaling mode for the false color conversion.
Definition ImageBuilder.h:479
OTC_SDK_API LookupTable createLookupTable()
Creates a lookup table for the false color conversion.
OTC_SDK_API void copyImageDataTo(unsigned char *destination, int size) const noexcept
Copies the false color image data to the given destination array.
int getWidth() const noexcept
Returns the width in pixels of the thermal frame.
Definition ImageBuilder.h:469
OTC_SDK_API float getTemperatureScalingMinFiltered() const noexcept
Returns the filtered minimum temperature actually used by the most recent frame's palette rendering.
OTC_SDK_API float getTemperatureScalingMax() const noexcept
Returns the maximum temperature used to scale the image.
OTC_SDK_API float getTemperatureScalingMaxFiltered() const noexcept
Returns the filtered maximum temperature actually used by the most recent frame's palette rendering....
OTC_SDK_API ImageBuilder(ColorFormat colorFormat, WidthAlignment widthAlignment)
Constructor.
OTC_SDK_API float getTemperatureScalingMin() const noexcept
Returns the minimum temperature used to scale the image.
OTC_SDK_API void setTemperatureScalingFilterFactor(float filterFactor)
Sets the low pass filter factor for the temperature scaling for smooth transitions.
OTC_SDK_API bool getMinMaxRegions(int radius, TemperatureRegion &minRegion, TemperatureRegion &maxRegion)
Returns the region of minimum/maximum temperature in °C with the given radius.
OTC_SDK_API void setThermalFrame(const ThermalFrame &thermalFrame)
Sets a new thermal frame.
OTC_SDK_API float getTemperature(int index) const
Returns the temperature the from last acquired image at specified pixel index.
Encapsulates all relevant information about a false color image.
Definition ImageInfo.h:57
Encapsulates false color images with 8-bit color depth.
Definition Image.h:37
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.
Definition ImageBuilder.h:105
@ MinMax
Dynamic determination of minimum and maximum temperature as upper and lower limit.
Definition ImageBuilder.h:103
@ Manual
User-defined upper and lower limit (fixed values).
Definition ImageBuilder.h:102
@ Sigma1
Dynamic determination of upper and lower limit from standard deviation of temperature image.
Definition ImageBuilder.h:104
WidthAlignment
Represents the different available width alignments.
Definition ImageInfo.h:47
Helper struct for calculating an integral image.
Definition ImageBuilder.h:90
std::uint64_t value
Summed up valid pixel values.
Definition ImageBuilder.h:92
std::uint32_t count
Number of valid pixels summed up.
Definition ImageBuilder.h:94
Characterizes a rectangular region by the indexes of the upper left and the lower right corners along...
Definition ImageBuilder.h:44
bool fitsInRectangle(int width, int height, int padding=0) const noexcept
Returns whether the region fits within a rectangle of the given dimensions.
int y2
Y index of the lower right corner.
Definition ImageBuilder.h:84
int x2
X index of the lower right corner.
Definition ImageBuilder.h:82
TemperatureRegion() noexcept
Constructor.
float temperature
Associated temperature in °C.
Definition ImageBuilder.h:74
int y1
Y index of the upper left corner.
Definition ImageBuilder.h:79
void reset() noexcept
Resets the temperature and the coordinates of the corners.
int x1
X index of the upper left corner.
Definition ImageBuilder.h:77