-
Notifications
You must be signed in to change notification settings - Fork 317
Expand file tree
/
Copy pathfff.h
More file actions
396 lines (334 loc) · 14.9 KB
/
fff.h
File metadata and controls
396 lines (334 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/***********************************************************************
*
* Description of file:
* Definition of FFF fileformat
*
***********************************************************************/
#ifndef FFF_H
#define FFF_H
/*=====================================================================*/
#define FLIR_FILE_FORMAT 0x46464600 // FFF\0
#define FILE_FORMAT_VERSION 100 // 1.00
#define FFF_EXT "FFF" // Default file name extension
#define SYSIMG_NAMELEN 15
enum { FFF_HDR_SWAP_PATTERN = 0x0001 };
// Bit mask for trig types
#define FPGA_TRIG_TYPE_MARK 0x01
#define FPGA_TRIG_TYPE_MARK_START 0x02
#define FPGA_TRIG_TYPE_MARK_STOP 0x04
#define FPGA_TRIG_TYPE_MARK_ENABLE 0x08 // Enable image flow
#define FPGA_TRIG_TYPE_MARK_DISABLE 0x10 // Disable image flow
#define FPGA_TRIG_STATE_DEASSERTED 0
#define FPGA_TRIG_STATE_ASSERTED 1
struct _fpgaheader_t {
BYTE major;
BYTE minor;
BYTE dp1_trig_type; // Digital port 1, trig type
BYTE dp2_trig_type; // Digital port 2, trig type
BYTE dp1_frame_ts; // Digital port 1, frame time stamp
BYTE dp1_line_ts_MSB; // Digital port 1, line time stamp (MSB)
BYTE dp1_line_ts_LSB; // Digital port 1, line time stamp (LSB)
BYTE dp2_frame_ts; // Digital port 2, frame time stamp
BYTE dp2_line_ts_MSB; // Digital port 2, line time stamp (MSB)
BYTE dp2_line_ts_LSB; // Digital port 2, line time stamp (LSB)
BYTE dp1_trig_state; // Digital port 1, trig state
BYTE dp2_trig_state; // Digital port 2, trig state
BYTE frame_cnt_MSB;
BYTE frame_cnt_LSB;
BYTE reserved[18];
};
typedef struct _fpgaheader_t FPGA_HEADER;
// main types
typedef enum {
/* General tags */
FFF_TAGID_FREE = 0, /* Marks unused tag descriptor */
FFF_TAGID_Pixels = 1,
FFF_TAGID_GainMap = 2,
FFF_TAGID_OffsMap = 3,
FFF_TAGID_DeadMap = 4,
FFF_TAGID_GainDeadMap = 5,
FFF_TAGID_CoarseMap = 6,
FFF_TAGID_ImageMap = 7,
FFF_TAGID_SubFlirFileHead = 0x1e,
FFF_general_high = 0x1f, /* Reserve space for other general
tags */
/* FLIR TAGs */
FFF_TAGID_BasicData = 0x20,
FFF_TAGID_Measure,
FFF_TAGID_ColorPal,
FFF_TAGID_TextComment,
FFF_TAGID_VoiceComment,
FFF_TAGID_matrix_high = 0x3f, /* reserve space for other system
image blocks */
/* FLIR Boston reserved TAG number series */
FFF_TAGID_Boston_reserved = 0x40,
FFF_TAGID_Boston_reserved_high = 0x5f,
FFF_highnum = 0x100 /* Guarantee 2 bytes enum */
} TAG_MAIN_T;
/* Sub Tags for FFF_TAGID_Pixels */
enum {
FFF_Pixels_BE = 1, /* Big endian pixel data block */
FFF_Pixels_LE = 2, /* Little endian pixel data block */
FFF_Pixels_PNG = 3 /* PNG compressed pixel data block (BE or LE) */
};
/* When appropriate, add subID enums for other TAG_MAIN_T too */
/* When subtype isn't used, fill subtype with FFF_SubID_default */
enum { FFF_SubID_default = 1 };
#pragma pack(push, 1)
typedef struct tagFLIRFILEHEAD {
char szFormatID[4]; /* Fileformat ID 'FFF\0' 4 4 */
char szOrigin[16]; /* File origin 16 20 */
unsigned long dwVersion; /* File format version 4 24 */
unsigned long dwIndexOff; /* Pointer to indexes 4 28 */
unsigned long dwNumUsedIndex; /* Number of indexes 4 32 */
unsigned long dwNextID; /* Next free index ID 4 36 */
unsigned short usSwapPattern; /* Swap pattern (0=MSBF) 2 38 */
unsigned short usSpare[7]; /* Spare 14 52 */
unsigned long reserved[2]; /* reserved 8 60 */
unsigned long dwChecksum; /* Head & index checksum 4 64 bytes */
} FLIRFILEHEAD;
typedef struct _geometric_info_t {
/** Size of one pixel in bytes.
Normal size is 2 bytes (16 bit pixels)
or 3 (for colorized YCbCr pixels) */
unsigned short pixelSize;
unsigned short imageWidth; //!< Image width in pixels
unsigned short imageHeight; //!< Image height in pixels
/** @name Upper left coordinates
X and Y coordinates for upper left corner
relative original in case this image is a
cutout, normally 0 */
/*@{*/
unsigned short upperLeftX;
unsigned short upperLeftY;
/*@}*/
/** @name Valid pixels
The following four number identifies the
valid pixels area within the image.
Sometimes the first row and column only
contains calibration pixels that should not
be considered as real pixels */
/*@{*/
unsigned short firstValidX; //!< Normally 0
unsigned short lastValidX; //!< Normally imageWidth - 1
unsigned short firstValidY; //!< Normally 0
unsigned short lastValidY; //!< Normally imageHeight - 1
/*@}*/
unsigned short detectorDeep; //!< Number of bits from detector A/D
/** Type of detector to be able to differ
between technologies if necessary.
Defined in AppCore/core_imgflow/imgflow_state.hpp */
unsigned short detectorID;
/** Type of upsampling from Detector to IR pixels.
Defined in AppCore/core_imgflow/imgflow_state.hpp */
unsigned short upSampling;
unsigned short frameCtr; //!< Image number from frame buffer
unsigned short minMeasRadius; //!< See AppCore/core_imgflow/imgflow_state.hpp for reference
unsigned char stripeFields; //!< Number of striped fields this image consists of
unsigned char reserved; //!< For future use - should be set to 0
unsigned short reserved1; //!< For future use - should be set to 0
} GEOMETRIC_INFO_T; //!< sizeof struct == 32 bytes
struct IMAGEINFO_T {
unsigned long imageTime; //!< Time in seconds since 1970-01-01 00:00 (UTC)
unsigned long imageMilliTime; //!< Milliseconds since last second
short timeZoneBias; //!< Time zone bias in minutes
//! UTC = local time + bias
short swReserved1; //!< filler == 0
long focusPos; //!< Focus position as counter value
float fTSTemp[7]; //!< Temp sensor values converted to Kelvin
float fTSTempExt[4]; //!< Lens temp sensors et.c. Converted to Kelvin
unsigned short trigInfoType; //!< 0 = No info, 1 = THV 900 type info
unsigned short trigHit; //!< hit count - microsecs from trig
//! reference
unsigned short trigFlags; //!< trig flags, type dependent
unsigned short reserved1;
unsigned long trigCount; //!< trig counter
short manipulType; //!< defines how to interpret manipFactors
short manipFactors[5]; //!< Used average factors
/** Detector settings - camera type dependent */
long detectorPars[20]; //!< Currently used detector parameters like
//! used bias, offsets. Usage is camera
//! dependent
long reserved[5]; //!< For future use
}; //!< sizeof struct == 184 bytes
/**
Distribution information
*/
struct DISTR_DATA_T {
/** Framegrab independent distribution data */
char imgName[16]; /* (4 longs) */
unsigned short distrLive; //!< TRUE (1) when image distribution is
//! 'LIVE'. FALSE (0) otherwise
unsigned short distrRecalled; //!< TRUE (1) when image distribution is
//! recalled. FALSE (0) otherwise.
//!< TRUE also implies that distrLive ==
//! FALSE
long curGlobalOffset;
float curGlobalGain; //!< globalOffset/Gain to generate LUT from
//! updated continuously when live only
#define regulationOn 1
unsigned short regulMethodMask; //!< Method used for o/g calculation
unsigned short visualImage; //!< TRUE (1) for TV (visual)
//! FALSE (0) for IR image
float focusDistance; //!< focusDistance in meters.
//! 0 means not defined.
//! NOT calculated by image source
unsigned short StripeHeight; //!< 0 = not striped
unsigned short StripeStart; //!< Striping start line if striped
unsigned short imageFreq; //!< Image frequency, defines the nominal
//! image frequency in Hz
unsigned short typePixStreamCtrlData;
//!< 0 = no such data,
//! other types TBD
unsigned short PixStreamDataLine;
//!< At which line to find
//! PixStreamCtrlData if any
#define IMGSMSK_INVALID 0x1 // Bit set means that image is non-measurable. Possibly because of a ongoing NUC.
#define IMGSMSK_ILL_LENS 0x2 // Measurement functions etc should be invalidated.
#define IMGSMSK_NONLINEAR 0x4 // Bit set means that (live) image is nonlinear (and therefore non-measurable).
#define IMGSMSK_LSLOCKED \
0x8 // Bit set means that (live) image should be locked for level/span/distr updates, but not palette changes
#define IMGSMSK_BMP_RECALL \
0x10 // Bit set means that a CSI bmp image is recalled. (Lut shall be updated even if image is non-measurable)
short errStatus; //!< bit field, mask definitions above
unsigned short imageMilliFreq; //!< Image frequency, milliHz part of imageFreq
short reserved; //!< For future use
long reserved2[3];
}; //!< sizeof struct == 64 bytes
typedef struct _pres_par_t {
signed long level; /* Level as normalized pixel value (apix), Level is defined as middle of
span (in pixel units) */
signed long span; /* Span as normalized pixel value (apix) */
BYTE reserved[40];
} PRES_PAR_T; /* sizeof struct == 48 bytes */
/**
* FFF tag index
*/
typedef struct tagFLIRFILEINDEX {
USHORT wMainType; /**< Main type of index 2 2
Should be one of TAG_MAIN_T */
USHORT wSubType; /**< Sub type of index 2 4 */
ULONG dwVersion; /**< Version for data 4 8 */
ULONG dwIndexID; /**< Index ID 4 12 */
ULONG dwDataPtr; /**< Pointer to data 4 16 */
ULONG dwDataSize; /**< Size of data 4 20 */
ULONG dwParent; /**< Parentnr 4 24
may be set to 0 when not used */
ULONG dwObjectNr; /**< This object nr 4 28
may be set to 0 when not used */
ULONG dwChecksum; /**< Data checksum 4 32 bytes
dwChecksum is a checksum of the tag data block. It may be
set to 0 when not used. The algorithm is CRC32 with the
Ethernet polynom. */
} FLIRFILEINDEX;
/**
* Object parameters
*
*/
struct OBJECT_PAR_T {
float emissivity; //!< 0 - 1
float objectDistance; //!< Meters
float ambTemp; //!< degrees Kelvin
float atmTemp; /**< degrees Kelvin
- should be set == ambTemp for basic S/W */
float extOptTemp; /**< degrees Kelvin
- should be set = ambTemp for basic S/W */
float extOptTransm; //!< 0 - 1: should be set = 1.0 for basic S/W
float estAtmTransm; //!< 0 - 1: should be set = 0.0 for basic S/W
float relHum; //!< relative humidity
long reserved[4]; //!< For future use - should be set to 0
};
struct TEMP_CALIB_T {
long Reserved1[2];
float R; //!< Calibration constant R
float B; //!< Calibration constant B
float F; //!< Calibration constant F
long Reserved2[3];
float alpha1; /* Attenuation for atmosphere without water vapor. */
float alpha2; /* Attenuation for atmosphere without water vapor */
float beta1; /* Attenuation for water vapor */
float beta2; /* Attenuation for water vapor */
float X; /* Scaling factor for attenuation. */
long Reserved3[3];
float tmax; //!< Upper temp limit [K] when calibrated for
//!< current temp range
float tmin; //!< Lower temp limit [K] when calibrated for
//!< current temp range
float tmaxClip; //!< Upper temp limit [K] over which the
//!< calibration becomes invalid
float tminClip; //!< Lower temp limit [K] under which the
//!< calibration becomes invalid
float tmaxWarn; //!< Upper temp limit [K] over which the
//!< calibration soon will become invalid
float tminWarn; //!< Lower temp limit [K] under which the
//!< calibration soon will become invalid
float tmaxSaturated; //!< Upper temp limit [K] over which pixels
//!< should be presented with overflow color
float tminSaturated; //!< Lower temp limit [K] for saturation
//!< (see also ADJUST_PAR_T:ipixOverflow).
//!< ipix over/under flow should be calculated
//!< by imgsrc from tmin/maxSaturated.
//!< LUT handler should look at ipix
//!< over/underflow.
long Reserved4[9];
}; //!< sizeof struct == 132 bytes
/*
Adjust parameters
-----------------
*/
typedef struct _adjust_par_t {
long normOffset; /* Temperature compensation offset
(globalOffset) */
float normGain; /* Temperature compensation gain
(globalGain) */
unsigned short ipixUnderflow; /* Image pixel underflow limit */
unsigned short ipixOverflow; /* Image pixel overflow limit */
long Reserved2[9];
} ADJUST_PAR_T; /* sizeof struct == 48 bytes */
/** Temp sensor data struct */
struct TEMPSENSOR_DATA_T {
float fTSTemp; //!< Converted to Kelvin
char pzTSName[SYSIMG_NAMELEN + 1];
ULONG captureTime; //!< TS updated; time in seconds since 1970-01-01 00:00
ULONG captureMilliTime; //!< TS updated; Milliseconds since last second
};
/** Detector parameter struct */
struct DETECTOR_PARAM_T {
float fData;
char pzDPName[SYSIMG_NAMELEN + 1];
}; //!< sizeof struct == 20 bytes
/**
Extended image info (more tempsensor and detector data)
*/
struct EXTENDED_IMAGEINFO_T {
TEMPSENSOR_DATA_T tsData[20]; //!< Temp sensor data
DETECTOR_PARAM_T detectorPars[20]; //!< Currently used detector parameters like
//! used bias, offsets. Usage is camera
//! dependent
};
struct _bidata_t {
GEOMETRIC_INFO_T GeometricInfo; // 32 bytes
OBJECT_PAR_T ObjectParameters;
TEMP_CALIB_T CalibParameters;
BYTE CalibInfo[564];
ADJUST_PAR_T AdjustParameters;
PRES_PAR_T PresentParameters;
BYTE DisplayParameters[28];
IMAGEINFO_T ImageInfo;
DISTR_DATA_T DistributionData;
EXTENDED_IMAGEINFO_T ExtendedImageInfo;
};
typedef struct _bidata_t BI_DATA_T;
struct _fff_header_t {
FLIRFILEHEAD header;
FLIRFILEINDEX itag;
FLIRFILEINDEX btag;
};
typedef struct _fff_header_t FFF_FILE_HEADER;
#define BASICDATAREV 102
#define IMAGEPIXELREV 100L
#pragma pack(pop)
/*---------------------------------------------------------------------*/
/* #endif for fff.h include */
/*---------------------------------------------------------------------*/
#endif