libirimager
IR Imager Direct-SDK
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)
25 typedef signed char int8_t;
26 typedef signed short int16_t;
27 typedef signed int int32_t;
28 typedef unsigned char uint8_t;
29 typedef unsigned short uint16_t;
30 typedef unsigned int uint32_t;
31 typedef signed long long int64_t;
32 typedef unsigned long long uint64_t;
33 #else
34 #include <inttypes.h>
35 #endif
36 
37 class BaseControlDevice;
38 struct NewFrameBuffer;
39 class ImageProcessing;
40 
41 namespace 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 
83 typedef void(__CALLCONV *fptrIRThermalFrame)(unsigned short* data, unsigned int w, unsigned int h, IRFrameMetadata meta, void* arg);
84 
93 typedef void(__CALLCONV *fptrIRVisibleFrame)(unsigned char* data, unsigned int w, unsigned int h, IRFrameMetadata meta, void* arg);
94 
104 typedef void(__CALLCONV *fptrIRVisibleSnapshot)(unsigned char* data, unsigned int w, unsigned int h, IRFrameMetadata meta, const IRArray<IREventData>& events, void* arg);
105 
106 
107 
118 typedef void(__CALLCONV *fptrIRThermalSnapshot)(unsigned short* thermal, unsigned short* energy, unsigned int w, unsigned int h, IRFrameMetadata meta, const IRArray<IREventData>& events, void* arg);
119 
125 typedef void(__CALLCONV *fptrIRFlagState)(EnumFlagState fs, void* arg);
126 
131 typedef void(__CALLCONV *fptrIRProcessEvent)(void* arg);
132 
133 class Timer;
134 
140 class __IRDIRECTSDK_API__ IRImager
141 {
142 public:
143 
147  IRImager();
148 
152  ~IRImager();
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 
181  Tchar* checkCalibration();
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 std::string 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 
307  bool hasBispectralTechnology() const;
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 
378  void setClient(IRImagerClient* client);
379 
384  ImageProcessing* getImageProcessingChain();
385 
391  void process(unsigned char* buffer, void* arg=NULL);
392 
397  void forceFlagEvent(float time=0.f);
398 
402  void raiseSnapshotEvent();
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 
438  bool isChipHeatingEnabled() const;
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 
512  void onProcessExit();
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 
539  void setClippedFormatPosition(Point p);
540 
545  Point getClippedFormatPosition() const;
546 
552  void setFlagForecast(bool value);
553 
560  bool getFlagForecast() const;
561 
566  double getRadialDistortionCorrFact1() const;
567 
572  void setRadialDistortionCorrFact1(double value);
573 
578  double getRadialDistortionCorrFact2() const;
579 
584  void setRadialDistortionCorrFact2(double value);
585 
587  {
588  Off,
589  Normal,
590  Wide
591  };
592 
597  void setRadialDistortionCorr(RadialDistortionCorrectionMode value);
598 
603  RadialDistortionCorrectionMode getRadialDistortionCorr();
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 
658  const IRFrameMetadata& getLastMetadata();
659 
665  IRPifConfig getPifConfig() const;
666 
672  void setPifConfig(IRPifConfig config);
673 
681  IRPifConfig setPifType(IRPifType::Value pifType, unsigned char pifDeviceCount);
682 
688  IRPifType::Value getPifType() const;
689 
695  short getTemprangeDecimal() const;
696 
703  void setReferenceTemperature(float referenceTemperature, float measuredTemperature, float tAmbient = -999.f);
704 
705 private:
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  bool _init;
718 
719  IRDeviceParams _params;
720 
721  unsigned int _widthIn;
722 
723  unsigned int _heightIn;
724 
725  unsigned int _widthOut;
726 
727  unsigned int _heightOut;
728 
729  long long _avgTimePerFrame;
730 
731  unsigned short _bitCount;
732 
733  unsigned short* _buffer;
734 
735  unsigned short* _bufferEnergy;
736 
737  unsigned int _widthOutVisible;
738 
739  unsigned int _heightOutVisible;
740 
741  unsigned char* _bufferVisible;
742 
743  fptrIRThermalFrame _cbThermalFrame;
744 
745  fptrIRVisibleFrame _cbVisibleFrame;
746 
747  fptrIRFlagState _cbFlag;
748 
749  fptrIRThermalSnapshot _cbThermalSnapshot;
750 
751  fptrIRVisibleSnapshot _cbVisibleSnapshot;
752 
753  fptrIRProcessEvent _cbProcessExit;
754 
755  IRImagerClient* _client;
756 
757  float _maxFramerate;
758 
759  unsigned int _frequency;
760 
761  float _tBox;
762 
763  float _tChip;
764 
765  float _tFlag;
766 
767  float _emissivity;
768 
769  float _transmissivity;
770 
771  Timer* _t;
772 
773  Timer* _tManual;
774 
775  float _timeToManualEvent;
776 
777  BaseControlDevice* _udev;
778 
779  NewFrameBuffer* _srcBuffer;
780 
781  ImageProcessing* _ip;
782 
783  unsigned int _instanceID;
784 
785  float _hwinterval;
786 
787  EnumFlagState _eFlagstate;
788 
789  bool _startFlag;
790 
791  IRFrameMetadata _lastMetaData;
792 
793  IRPifConfig _pifConfig;
794 
795  EnumFlagState _eFlagstatePrev;
796 
797  struct InitState {
798  enum Value { SetAutoSkimDirect, WaitAutoSkimDirect, StartFlag, WaitAndStartFlag, Finished = 100 };
799  };
800 
801  InitState::Value _initState;
802 
803  unsigned short _highPrecisionTempOffset;
804 };
805 
806 }
807 #endif
808 
C-Array wrapper for handle size, copy and memory.
Definition: IRArray.h:22
Meta data structure describing camera parameters of image stream.
Definition: IRImager.h:53
Structure containing device parameters.
Definition: IRDeviceParams.h:124
Structure containing meta data acquired from the PI imager.
Definition: IRDeviceParams.h:97
Config for pif.
Definition: IRPifConfig.h:36
Wrapper for PI driver and image processing library.
Definition: IRImager.h:140
RadialDistortionCorrectionMode
Definition: IRImager.h:586
Time measurement class.
Definition: Timer.h:26
Definition: IRImager.h:41
Value
Definition: IRDeviceParams.h:60
Interface for specifying object-oriented frame callback methods.
Definition: IRImagerClient.h:29