Version 8.8.5
 
Loading...
Searching...
No Matches
IRImager.h
1/******************************************************************************
2 * Copyright (c) 2012-2019 All Rights Reserved, http://www.evocortex.com *
3 * Evocortex GmbH *
4 * Emilienstr. 1 *
5 * 90489 Nuremberg *
6 * Germany *
7 * *
8 * Contributors: *
9 * Initial version for Linux 64-Bit platform supported by Fraunhofer IPA, *
10 * http://www.ipa.fraunhofer.de *
11 *****************************************************************************/
12
13#ifndef IRIMAGER_H
14#define IRIMAGER_H
15
16#include <stdlib.h>
17#include "IRDeviceParams.h"
18#include "IRImagerClient.h"
19#include "unicode.h"
20#include "irdirectsdk_defs.h"
21#include "IRCommonTypes.h"
22#include "pif_config/IRPifConfig.h"
23
24#if(_WIN32 & _MSC_VER <= 1700)
25typedef signed char int8_t;
26typedef signed short int16_t;
27typedef signed int int32_t;
28typedef unsigned char uint8_t;
29typedef unsigned short uint16_t;
30typedef unsigned int uint32_t;
31typedef signed long long int64_t;
32typedef unsigned long long uint64_t;
33#else
34#include <inttypes.h>
35#endif
36
37class BaseControlDevice;
38struct NewFrameBuffer;
39class ImageProcessing;
40
41namespace evo
42{
43
44#define GPSBUFFERSIZE 80
45#define HEADERVERSION 1003
46
52#pragma pack(push, 1)
54{
55 uint16_t sizeOfHeader;
56 uint16_t headerVersion;
57 char sdate[8];
58 char stime[6];
59 uint32_t serial;
60 int32_t width;
61 int32_t height;
62 uint16_t bitCount;
63 int64_t avgTimePerFrame;
64 uint16_t optics; // Optics in ° or mm
65 uint16_t tempMinRange; // minimum temprange
66 uint16_t tempMaxRange; // maximum temprange
67 uint16_t hwRev; // hardware release
68 uint16_t fwRev; // firmware release
69 uint16_t gpsStringBufferSize; // size of the GPS string buffer of each frame
70 uint16_t devFrequency; // Device Frequency
71 char opticsText[8]; // Optics Text
72};
73#pragma pack(pop)
74
83typedef void(__CALLCONV *fptrIRThermalFrame)(unsigned short* data, unsigned int w, unsigned int h, IRFrameMetadata meta, void* arg);
84
93typedef void(__CALLCONV *fptrIRVisibleFrame)(unsigned char* data, unsigned int w, unsigned int h, IRFrameMetadata meta, void* arg);
94
104typedef void(__CALLCONV *fptrIRVisibleSnapshot)(unsigned char* data, unsigned int w, unsigned int h, IRFrameMetadata meta, const IRArray<IREventData>& events, void* arg);
105
106
107
118typedef void(__CALLCONV *fptrIRThermalSnapshot)(unsigned short* thermal, unsigned short* energy, unsigned int w, unsigned int h, IRFrameMetadata meta, const IRArray<IREventData>& events, void* arg);
119
125typedef void(__CALLCONV *fptrIRFlagState)(EnumFlagState fs, void* arg);
126
131typedef void(__CALLCONV *fptrIRProcessEvent)(void* arg);
132
133class Timer;
134
140class __IRDIRECTSDK_API__ IRImager
141{
142public:
143
148
153
164 bool init(IRDeviceParams* params, unsigned int frequency, unsigned int width, unsigned int height, bool useHID, unsigned short hwRev=0, unsigned short fwRev=0);
165
170 void initRawdataHeader(RawdataHeader &header) const;
171
175 bool reconnect(IRDeviceParams* params, unsigned int frequency, unsigned int width, unsigned int height, bool useHID, unsigned short hwRev=0, unsigned short fwRev=0);
176
182
187 void setAutoFlag(bool autoFlag);
188
193 bool getAutoFlag() const;
194
199 void setFlagMinInterval(float seconds);
200
205 float getFlagMinInterval() const;
206
211 void setFlagMaxInterval(float seconds);
212
217 float getFlagMaxInterval() const;
218
224 bool setTempRange(int tMin, int tMax);
225
230 unsigned int getHWRevision() const;
231
236 unsigned int getFWRevision() const;
237
241 static const char* const getVersion();
242
247 unsigned int getWidth() const;
248
253 unsigned int getHeight() const;
254
259 unsigned int getVisibleWidth() const;
260
265 unsigned int getVisibleHeight() const;
266
271 unsigned int getWidthIn() const;
272
277 unsigned int getHeightIn() const;
278
283 unsigned short getBitCount() const;
284
289 long long getAvgTimePerFrame() const;
290
295 float getMaxFramerate() const;
296
301 float getHWInterval() const;
302
308
314 int getEnergyBuffer(unsigned short* buffer) const;
315
322 int getMetaData(unsigned char* buffer, int size) const;
323
336 bool getTemperatureTableParameters(double* t1, double* t3, double* tJunct, short* e1, short* e3, short* eJunct, double* lambda, double* lambda2) const;
337
342 void setThermalFrameCallback(fptrIRThermalFrame callback);
343
348 void setVisibleFrameCallback(fptrIRVisibleFrame callback);
349
354 void setFlagStateCallback(fptrIRFlagState callback);
355
360 void setThermalFrameEventCallback(fptrIRThermalSnapshot callback);
361
366 void setVisibleFrameEventCallback(fptrIRVisibleSnapshot callback);
367
372 void setProcessExitCallback(fptrIRProcessEvent callback);
373
379
384 ImageProcessing* getImageProcessingChain();
385
391 void process(unsigned char* buffer, void* arg=NULL);
392
397 void forceFlagEvent(float time=0.f);
398
403
408 bool isFlagOpen() const;
409
414 float getTempFlag() const;
415
420 float getTempBox() const;
421
426 float getTempChip() const;
427
432 void enableChipHeating(bool enable);
433
439
444 void setTempChipReference(float t);
445
450 float getTempChipReference() const;
451
458 void setRadiationParameters(float emissivity, float transmissivity, float tAmbient=-999.f);
459
464 void setUseMultiThreading(bool useMultiThreading);
465
471 bool setFocusmotorPos(float pos);
472
477 float getFocusmotorPos() const;
478
482 void onFlagState(unsigned int flagstate);
483
487 void onThermalFrameInit(unsigned int width, unsigned int height, unsigned short bitCount, long long avgTimePerFrame);
488
492 void onThermalFrame(unsigned short* buffer, IRFrameMetadata meta);
493
497 void onVisibleFrameInit(unsigned int width, unsigned int height);
498
502 void onVisibleFrame(unsigned char* buffer, IRFrameMetadata meta);
503
507 void onSnapshotEvent(unsigned short* thermal, unsigned short* energy, unsigned char* rgb, IRFrameMetadata meta, const IRArray<IREventData>& events);
508
513
520 //int serialize(const char* filename, const char* preview, int sizePreview);
521
527 void activateTrace(bool activate);
528
533 void printTrace(const unsigned int pixelID);
534
540
546
552 void setFlagForecast(bool value);
553
560 bool getFlagForecast() const;
561
567
573
579
585
587 {
588 Off,
589 Normal,
590 Wide
591 };
592
598
604
610 unsigned short getPifDICount() const;
611
617 unsigned short getPifAICount() const;
618
624 unsigned short getPifDOCount() const;
625
631 unsigned short getPifAOCount() const;
632
637 unsigned char getPifDeviceCount(bool actual) const;
638
645 void setPifAO(unsigned char channel, float value);
646
653 void setPifDO(unsigned char channel, bool value);
654
659
666
673
681 IRPifConfig setPifType(IRPifType::Value pifType, unsigned char pifDeviceCount);
682
689
695 short getTemprangeDecimal() const;
696
703 void setReferenceTemperature(float referenceTemperature, float measuredTemperature, float tAmbient = -999.f);
704
705private:
706
707 void freeMemory();
708
709 void startFlag();
710
711 void initPifConfig();
712
713 void checkResult(long result, const char* functionName) const;
714
715 void onAutoSkimOperation(int operation);
716
717 inline void adaptMetadata(IRFrameMetadata& meta);
718
719 bool _init;
720
721 IRDeviceParams _params;
722
723 unsigned int _widthIn;
724
725 unsigned int _heightIn;
726
727 unsigned int _widthOut;
728
729 unsigned int _heightOut;
730
731 long long _avgTimePerFrame;
732
733 unsigned short _bitCount;
734
735 unsigned short* _buffer;
736
737 unsigned short* _bufferEnergy;
738
739 unsigned int _widthOutVisible;
740
741 unsigned int _heightOutVisible;
742
743 unsigned char* _bufferVisible;
744
745 fptrIRThermalFrame _cbThermalFrame;
746
747 fptrIRVisibleFrame _cbVisibleFrame;
748
749 fptrIRFlagState _cbFlag;
750
751 fptrIRThermalSnapshot _cbThermalSnapshot;
752
753 fptrIRVisibleSnapshot _cbVisibleSnapshot;
754
755 fptrIRProcessEvent _cbProcessExit;
756
757 IRImagerClient* _client;
758
759 float _maxFramerate;
760
761 unsigned int _frequency;
762
763 float _tBox;
764
765 float _tChip;
766
767 float _tFlag;
768
769 float _emissivity;
770
771 float _transmissivity;
772
773 Timer* _t;
774
775 Timer* _tManual;
776
777 float _timeToManualEvent;
778
779 BaseControlDevice* _udev;
780
781 NewFrameBuffer* _srcBuffer;
782
783 ImageProcessing* _ip;
784
785 unsigned int _instanceID;
786
787 float _hwinterval;
788
789 EnumFlagState _eFlagstate;
790
791 bool _startFlag;
792
793 IRFrameMetadata _lastMetaData;
794
795 IRPifConfig _pifConfig;
796
797 EnumFlagState _eFlagstatePrev;
798
799 struct InitState {
800 enum Value { SetAutoSkimDirect, WaitAutoSkimDirect, StartFlag, WaitAndStartFlag, WaitForFlagFinished, Finished = 100 };
801 };
802
803 InitState::Value _initState;
804
805 unsigned short _highPrecisionTempOffset;
806};
807
808}
809#endif
810
C-Array wrapper for handle size, copy and memory.
Definition: IRArray.h:23
Interface for specifying object-oriented frame callback methods.
Definition: IRImagerClient.h:30
Wrapper for PI driver and image processing library.
Definition: IRImager.h:141
unsigned short getBitCount() const
Get # of bits used for temperature coding.
void setPifDO(unsigned char channel, bool value)
Set the Pif Digital Output.
void onVisibleFrameInit(unsigned int width, unsigned int height)
Internal method not to be used by any application!
short getTemprangeDecimal() const
Returns the number of decimal places in thermal data.
bool isFlagOpen() const
Check if shutter flag is open.
const IRFrameMetadata & getLastMetadata()
Returns the last meta data.
unsigned short getPifAICount() const
Get the Pif count of analog input's.
void setClient(IRImagerClient *client)
Set client as callback receiver.
bool init(IRDeviceParams *params, unsigned int frequency, unsigned int width, unsigned int height, bool useHID, unsigned short hwRev=0, unsigned short fwRev=0)
Initializing routine, to be called after instantiation.
bool hasBispectralTechnology() const
Check if bispectral technology is available.
bool setFocusmotorPos(float pos)
Set the position of the focusmotor.
void onVisibleFrame(unsigned char *buffer, IRFrameMetadata meta)
Internal method not to be used by any application!
void setThermalFrameEventCallback(fptrIRThermalSnapshot callback)
Set callback function to be called for PIF or software trigger events.
void setThermalFrameCallback(fptrIRThermalFrame callback)
Set callback function to be called for new frames.
float getFocusmotorPos() const
Get the position of the focusmotor.
~IRImager()
Destructor.
double getRadialDistortionCorrFact1() const
Get the first radial distortion correction factor (r^2).
unsigned int getHeight() const
Get image height of thermal channel.
Tchar * checkCalibration()
Check existence of calibration file set.
RadialDistortionCorrectionMode getRadialDistortionCorr()
Get the radial distortion correction mode.
void setAutoFlag(bool autoFlag)
Set flag automatic.
void printTrace(const unsigned int pixelID)
Print trace record (needs to be activated before)
unsigned char getPifDeviceCount(bool actual) const
Get the Pif Device Count.
void forceFlagEvent(float time=0.f)
Force shutter flag event manually (close/open cycle)
void setVisibleFrameEventCallback(fptrIRVisibleSnapshot callback)
Set callback function to be called for PIF or software trigger events.
bool getTemperatureTableParameters(double *t1, double *t3, double *tJunct, short *e1, short *e3, short *eJunct, double *lambda, double *lambda2) const
Get temperature table parameters @params[out] t1 Temperature for 1st operating point @params[out] t3 ...
void setTempChipReference(float t)
Set reference input of bolometer heating (limited to +20° - 55°).
RadialDistortionCorrectionMode
Definition: IRImager.h:587
int getMetaData(unsigned char *buffer, int size) const
Get meta data container of previously acquired frame.
static const char *const getVersion()
Get libirimager version.
void setRadiationParameters(float emissivity, float transmissivity, float tAmbient=-999.f)
Set radiation properties, i.e.
float getTempFlag() const
Get temperature of shutter flag.
unsigned int getWidthIn() const
Get width of raw format (from UVC stream)
float getTempChipReference() const
Get reference input of bolometer heating.
unsigned int getVisibleWidth() const
Get image width of visible channel (if available)
void process(unsigned char *buffer, void *arg=NULL)
Process raw data.
void setFlagMinInterval(float seconds)
Set flag min interval.
void setReferenceTemperature(float referenceTemperature, float measuredTemperature, float tAmbient=-999.f)
Set a reference temperature to a known reference source inside the view of the camera to improve came...
void setRadialDistortionCorrFact1(double value)
Set the first (r^2) radial distortion correction factor (Brown's distortion model).
void enableChipHeating(bool enable)
Enable heating of bolometers.
unsigned short getPifDOCount() const
Get the Pif count of digital output's.
void setRadialDistortionCorrFact2(double value)
Set the second (r^4) radial distortion correction factor (Brown's distortion model).
int getEnergyBuffer(unsigned short *buffer) const
Get energy buffer of previously acquired frame.
void setClippedFormatPosition(Point p)
Set the clipped format position.
bool getAutoFlag() const
Get flag automatic.
void onProcessExit()
Internal method not to be used by any application!
void setFlagStateCallback(fptrIRFlagState callback)
Set callback function to be called for changing flag states.
long long getAvgTimePerFrame() const
Get average time per frame.
void setRadialDistortionCorr(RadialDistortionCorrectionMode value)
Set the radial distortion correction mode.
void setProcessExitCallback(fptrIRProcessEvent callback)
Set callback function to be called when the process method has finalized its work.
unsigned int getHeightIn() const
Get height of raw format (from UVC stream)
IRPifConfig getPifConfig() const
Get the Pif Config object.
void onThermalFrameInit(unsigned int width, unsigned int height, unsigned short bitCount, long long avgTimePerFrame)
Internal method not to be used by any application!
void initRawdataHeader(RawdataHeader &header) const
Initialize Rawdata header with camera specific parameters.
bool setTempRange(int tMin, int tMax)
Set temperature range.
unsigned int getVisibleHeight() const
Get image height of visible channel (if available)
unsigned short getPifDICount() const
Get the Pif count of digital input's.
float getHWInterval() const
Get time interval between hardware frames (camera timestamp)
bool isChipHeatingEnabled() const
Get state of bolometers heating.
Point getClippedFormatPosition() const
Get the clipped format position.
IRImager()
Standard constructor.
IRPifType::Value getPifType() const
Returns the current pif type.
float getFlagMinInterval() const
Get flag min interval.
void raiseSnapshotEvent()
Raise a software triggered snapshot event (comparable with PIF event)
ImageProcessing * getImageProcessingChain()
Get pointer to image processing chain.
float getTempChip() const
Get temperature of chip.
float getFlagMaxInterval() const
Get flag max interval.
void setPifAO(unsigned char channel, float value)
Set the Pif Analog Output.
void setPifConfig(IRPifConfig config)
Set the Pif Config.
void setUseMultiThreading(bool useMultiThreading)
Experimental feature: Use multi-threading to accelerate process call.
void setFlagForecast(bool value)
Enable/Disable the flag forecast.
float getMaxFramerate() const
Get maximum frame rate of device return frame rate (in frames/second)
bool getFlagForecast() const
Returns if flag forecast is enabled/disabled.
void setFlagMaxInterval(float seconds)
Set flag max interval.
unsigned short getPifAOCount() const
Get the Pif count of analog output's.
unsigned int getFWRevision() const
Get firmware revision.
unsigned int getHWRevision() const
Get hardware revision.
float getTempBox() const
Get temperature of housing.
bool reconnect(IRDeviceParams *params, unsigned int frequency, unsigned int width, unsigned int height, bool useHID, unsigned short hwRev=0, unsigned short fwRev=0)
Reconnect resets internal variables and calls init method again.
void setVisibleFrameCallback(fptrIRVisibleFrame callback)
Set callback function to be called for new frames.
void onThermalFrame(unsigned short *buffer, IRFrameMetadata meta)
Internal method not to be used by any application!
void onFlagState(unsigned int flagstate)
Internal method not to be used by any application.
void onSnapshotEvent(unsigned short *thermal, unsigned short *energy, unsigned char *rgb, IRFrameMetadata meta, const IRArray< IREventData > &events)
Internal method not to be used by any application!
void activateTrace(bool activate)
Serialize image.
double getRadialDistortionCorrFact2() const
Get the second radial distortion correction factor (r^4).
IRPifConfig setPifType(IRPifType::Value pifType, unsigned char pifDeviceCount)
Currently only for Xi80.
unsigned int getWidth() const
Get image width of thermal channel.
Time measurement class.
Definition: Timer.h:27
Structure containing device parameters.
Definition: IRDeviceParams.h:125
Structure containing meta data acquired from the PI imager.
Definition: IRDeviceParams.h:98
Config for pif.
Definition: IRPifConfig.h:37
Value
Definition: IRDeviceParams.h:61
Meta data structure describing camera parameters of image stream.
Definition: IRImager.h:54