XFilters.h 17.7 KB
Newer Older
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
/** \file	XFilters.h */
#ifndef _XENICS_XFILTERS_H_
#   define _XENICS_XFILTERS_H_

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Filters, query available list / start
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#   include <XCamera.h>

    ///
    /// @brief Generates a comma separated list of image filters usable in QueueFilter().
    ///
    /// @param[in]  cam         Camera class instance.
    /// @param[out] fltlist     String buffer.
    /// @param[in]  fltlistmax  Bytes allocated to fltlist.
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode  IMPEXP GetFilterList   (XCamera *cam, char *fltlist, int fltlistmax);

    
    ///
    /// Queue's the given filter identified by the filter name.
    /// The filter name can be obtained using the GetFilterList()-function..
    ///
    /// @param[in]  cam          Camera class instance.
    /// @param[in]  fltname      Filter name (see #GetFilterList()).
    /// @param[in]  fltparms     Start-up parameters (not available for all filters)
    ///
    /// @return     Returns the id to the new queued filter. When a negative return value is returned, queueing the filter failed.
    ///
    // Examples:
    // FilterID fID = QueueFilter(cam, "SoftwareCorrection", "");
    // FilterID fID = QueueFilter(cam, "Thermography"      , "unit:celsius");
    FilterID IMPEXP QueueFilter     (XCamera *cam, const char *fltname, const char *fltparms);

#   ifdef __cplusplus
    extern "C" 
    {
#   endif

        ErrCode  IMPEXPC XC_FLT_GetFilterList (XCHANDLE hnd, char *fltlist, int fltlistmax);              ///< @sa GetFilterList
        FilterID IMPEXPC XC_FLT_Queue         (XCHANDLE hnd, const char *fltname, const char *fltparms);  ///< @sa QueueFilter

#   ifdef __cplusplus
    }
#   endif


    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Filter data structures
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    //////////////////////////////////////////////////////////////////////////////////////
    //  XFilters - Xenics image filters
    //////////////////////////////////////////////////////////////////////////////////// 

    //////////////////////////////////
    // Information exchange messages
    ////////////////////////////////

    ///
    /// @brief Fetch a point value from the temperature filter
    ///
    typedef struct {
        dword   x;          ///< X coordinate
        dword   y;          ///< Y coordinate
        double  e;          ///< Emissivity
        double  value;      ///< Resulting value
    } XMsgGetTempData;

    ///
    /// @brief Ask a filter to convert an adu value to temperature
    ///
    typedef struct {
        dword   adu;        ///< Raw adu value
        double  temp;       ///< Resulting temperature
    } XMsgADUToTempData;

    ///
    /// @brief Temperature conversion modes
    /// These constants determine what temperature unit is used to interact with the thermal filter(s)
    ///
    enum TempConvT 
    { 
        TC_Kelvin       = 0, ///< Kelvin
        TC_Celsius      = 1, ///< Degrees celsius
        TC_Fahrenheit   = 2, ///< Fahrenheit
        TC_WMM2         = 3  ///< W.m^-2
    };

    ///
    /// @brief Filter structure used to fetch/store scene emissivity/focal parameters (see #XMsgGetEN and #XMsgSetEN)
    ///
    typedef struct {
        int         size;           ///< sizeof(XMsgTempParms)
        double      e;              ///< Scene emissivity (1-100)
        double      n;              ///< Focal/aperture parameter (1->)
        double      ambient;        ///< Ambient/Background Temperature (Unit: chosen at filter creation)
        double      atmost;         ///< Atmosphere temperature
        double      atmostrans;     ///< Optical transmission thru the atmosphere
        TempConvT   unit;           ///< Active thermal conversion unit (read only, specified at filter instantiation)
        double      windowt;        ///< Optics: window temperature             @since Xeneth 2.6
        double      windowreflt;    ///< Optics: window reflected temperature   @since Xeneth 2.6
        double      windowtrans;    ///< Optical window transmission            @since Xeneth 2.6
        double      windowrefl;     ///< Optical window reflection              @since Xeneth 2.6
    } XMsgTempParms;

    /// Filter structure used to transmit adu offset and gain correction to the thermal filter.
    typedef struct {
        int         size;           ///< sizeof(XMsgTempAdjustmentParms)
        double      offset;         ///< linear transform (emicoradu*gain)+offset
        double      gain;           ///< linear transform
    } XMsgTempAdjustmentParms;

    /// XMsgTempParms Example: 
    ///
    /// XMsgTempParms temp;
    /// 
    /// XC_MsgImageFilter(handle, thermalfilterid, XMsgGetRadiometricParms, &temp);
    /// temp.ambient = 27.5;
    /// XC_MsgImageFilter(handle, thermalfilterid, XMsgSetRadiometricParms, &temp);

    /// Set temperature region of interest in pct
    typedef struct {
        double pctlo;       ///< Percentage of range, low point
        double pcthi;       ///< Percentage of range, high point
    } XMsgSetTROIParms;

    /// Push a new thermal linearization range to the thermal filter
    typedef struct {
        int    size;        ///< sizeof(XMsgRangeUpdate)
        double tmin;        ///< new minimum
        double tmax;        ///< new maximum
        int    reference;   ///< in/out reference to keep track of the update
        bool   add;         ///< true = new range request, false, remove reference from the range expansion queue.
    } XMsgRangeUpdate;

    /// Request the freeze filter to save its data.
    typedef struct {
        int             size;           ///< sizeof(#XMsgFltSaveData)
        char            path[512];      ///< absolute path. This is a zero terminated string.
        unsigned long   flags;          ///< Save options (see #XSaveDataFlags)
    } XMsgFltSaveData;

    /// Request the NUC filter's exposure time limits.
    typedef struct {
        int size;                       ///< sizeof(XMsgFltGetRange)
        double lo;                      ///< Low
        double hi;                      ///< Hi
    } XMsgGetRange;
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Filter utility functions, C++
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#   ifdef __cplusplus

    ///
    /// @brief Retrieves temperature filter corrected data (used internally by Xeneth)
    ///
    /// @param[in]  cam         Camera handle
    /// @param[in]  fid         Filter ID
    /// @param[in]  x           X-Coordinate
    /// @param[in]  y           Y-Coordinate
    /// @param[in]  e           Emissivity
    ///
    /// @return temperature filter corrected data.
    ///
    double IMPEXP XFltGetTValue(XCamera * cam, FilterID fid, double e, dword x, dword y);

    
    /// @deprecated
    double IMPEXP XFltGetValue(XCamera * cam, FilterID fid, dword x, dword y);

    
    ///
    /// @brief Convert an ADU value to a temperature.
    /// @note This function is used by GORATEC's thermography studio (GTS)
    ///
    /// @param[in]  cam         Camera handle
    /// @param[in]  fid         Filter ID of the temperature correction filter
    /// @param[in]  adu         Input ADU value
    /// @param[out] temp        Output Temperature Value
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltADUToTemperature(XCamera * cam, FilterID fid, dword adu, double * temp);

    
    ///
    /// @brief Convert a temperature value to an ADU
    ///
    /// @param[in]  cam         Camera handle
    /// @param[in]  fid         Filter ID of the temperature correction filter
    /// @param[in]  temp        Input temperature value
    /// @param[out] adu         Output ADU value
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltTemperatureToADU(XCamera * cam, FilterID fid, double temp, dword * adu);

    
    ///
    /// @brief Convert a linearised ADU value to temperature.
    ///
    /// This is a special feature of the thermal filters.
    ///
    /// @param[in]  cam         Camera handle.
    /// @param[in]  fid         Filter ID of the temperature correction filter.
    /// @param[in]  adu         ADU value.
    /// @param[out] temp        Temperature value.
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltADUToTemperatureLin(XCamera * cam, FilterID fid, dword adu, double * temp);

    
    ///
    /// @brief Convert a temperature value to a linearised ADU.
    ///
    /// This is a special feature of the thermal filters.
    ///
    /// @param[in]  cam         Camera handle.
    /// @param[in]  fid         Filter ID of the temperature correction filter.
    /// @param[in]  adu         ADU value.
    /// @param[out] temp        Temperature value.
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltTemperatureToADULin(XCamera * cam, FilterID fid, double temp, dword * adu);

    
    ///
    /// @brief Sends a stream to an image filter.
    ///
    /// @param[in]  cam         Camera handle
    /// @param[in]  fid         Filter ID
    /// @param[in]  msg         Message (see #XFilterMessage)
    /// @param[in]  p           Buffer pointer
    /// @param[in]  len         Length to transmit in bytes
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltSendStream(XCamera * cam, FilterID fid, XFilterMessage msg, const char * p, int len);

    
    ///
    /// @brief Receives a stream from an image filter.
    ///
    /// @param[in]  cam         Camera handle
    /// @param[in]  fid         Filter ID
    /// @param[in]  msg         Message (see #XFilterMessage)
    /// @param[out] p           Buffer pointer
    /// @param[in]  len         Length to transmit in bytes
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltRecvStream(XCamera * cam, FilterID fid, XFilterMessage msg, char * p, int * len);

    
    ///
    /// @brief Simplified access to filter parameters
    ///
    /// @param[in]  cam         Camera handle.
    /// @param[in]  fid         Filter ID.
    /// @param[in]  parm        Filter property name (use "XML" to transmit an entire XML structure to a filter).
    /// @param[in]  value       Zero terminated string.
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltSetParameter(XCamera * cam, FilterID fid, const char * parm, const char * value);

    
    ///
    /// @brief Simplified access to filter parameters
    ///
    /// @param[in]      cam     Camera handle
    /// @param[in]      fid     Filter ID
    /// @param[in]      parm    Filter property name (use "XML" to transmit an entire XML structure to a filter)
    /// @param[out]     value   Output buffer
    /// @param[in,out]  len     When calling this function the length should contain the total number of 
    ///                         allocated bytes, on return the len will contain the actual length copied to value.
    ///
    /// @return This method will return #I_OK on success.
    ///         On failure one of the other possible values is returned. (see #ErrorCodes)
    ///
    /// @retval     #I_OK   Success.
    ///
    ErrCode IMPEXP XFltGetParameter(XCamera * cam, FilterID fid, const char * parm, char * value, int * len);

#endif
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Filter utility functions, C
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#   ifdef __cplusplus
    extern "C" 
    {
#   endif

        
        double IMPEXPC XC_FLT_GetTValue(XCHANDLE hnd, FilterID fid, double e, dword x, dword y);                        ///< @sa XFltGetTValue
        double IMPEXPC XC_FLT_GetValue(XCHANDLE hnd, FilterID fid, dword x, dword y);                                   ///< @deprecated
        ErrCode IMPEXPC XC_FLT_ADUToTemperature(XCHANDLE hnd, FilterID fid, dword adu, double * temp);                  ///< @sa XFltADUToTemperature
        ErrCode IMPEXPC XC_FLT_TemperatureToADU(XCHANDLE hnd, FilterID fid, double temp, dword * adu);                  ///< @sa XFltTemperatureToADU
        ErrCode IMPEXPC XC_FLT_ADUToTemperatureLin(XCHANDLE hnd, FilterID fid, dword adu, double * temp);               ///< @sa XFltADUToTemperatureLin
        ErrCode IMPEXPC XC_FLT_TemperatureToADULin(XCHANDLE hnd, FilterID fid, double temp, dword * adu);               ///< @sa XFltTemperatureToADULin
        ErrCode IMPEXPC XC_FLT_SendStream(XCHANDLE hnd, FilterID fid, XFilterMessage msg, const char * p, int len);     ///< @sa XFltSendStream
        ErrCode IMPEXPC XC_FLT_RecvStream(XCHANDLE hnd, FilterID fid, XFilterMessage msg, char * p, int * len);         ///< @sa XFltRecvStream
        ErrCode IMPEXPC XC_FLT_SetParameter(XCHANDLE hnd, FilterID fid, const char * parm, const char * value);         ///< @sa XFltSetParameter
        ErrCode IMPEXPC XC_FLT_GetParameter(XCHANDLE hnd, FilterID fid, const char * parm, char * value, int * len);    ///< @sa XFltGetParameter
        
#   ifdef __cplusplus
    }
#   endif


    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // User plug in development functions
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#   ifdef __cplusplus
    extern "C" 
    {
#   endif

        /// Filter interface version number.
#       define _FLT_IFV (43)

        /// Convert a Xeneth API stream to a C text string
        /**
        <h3>Filter serialisation structure</h3>
        This function is used in conjunction with the XMsgSerialise and XMsgDeserialise filter messages.<br><br>
        &lt;XFilter&gt;<br>
        &lt;version&gt;versionid&lt;/version&gt;<br>
        &lt;propertyname1 type='string' label='PropertyLabel' range='' editable='1'&gt;propertyvalue&lt;/propertyname1&gt;<br>
        &lt;propertyname2 type='int'    label='PropertyLabel' range='' editable='1'&gt;propertyvalue&lt;/propertyname2&gt;<br>
        &lt;propertyname3 type='float'  label='PropertyLabel' range='' editable='1'&gt;propertyvalue&lt;/propertyname3&gt;<br>
        &lt;propertyname4 type='enum'   label='PropertyLabel' range='choicea,choiceb,choicec' editable='1'&gt;choicea&lt;/propertyname4&gt;<br>
        &lt;propertyname5 type='bool'   label='PropertyLabel' range='' editable='1'&gt;True/propertyname5&gt;<br>
        &lt;propertyname6 type='colour' label='PropertyLabel' range='' editable='1'&gt;rgb(255,0,0)&lt;/propertyname6&gt;<br>
        &lt;propertyname7 type='matrix' label='PropertyLabel' range='' editable='1'&gt;1;2;3;4;5;6;7;8;9&lt;/propertyname7&gt;<br>
        &lt;propertyname8 type='file'   label='PropertyLabel' range='' editable='1'&gt;propertyvalue&lt;/propertyname8&gt;<br>
        &lt;/XFilter&gt;
        <h3>Attributes:</h3>
        type  - datatype (string,int,float,enum,bool,colour,matrix,file)<br>
        label - displayed name in the user interface<br>
        range - possible values<br>
        editable - 0 = readonly / 1 = editable<br>
        */
        /// \param pStream  - Stream pointer received by handling XMsgDeserialise
        /// \param pText    - Output -> zero terminated string
        /// \param len      - in: Space reserved in output buffer out: Actual length
        ErrCode  IMPEXPC XC_FLT_StreamToText                (void *pStream, char *pText, int *len);

        /// Convert a Xeneth API stream to a C text string
        /// \param pStream  - Stream pointer received by handling XMsgSerialise
        /// \param pText    - Zero terminated C string
        /// \param len      - Length of the string
        ErrCode  IMPEXPC XC_FLT_TextToStream                (void *pStream, const char *pText, int len);

#   ifdef __cplusplus
    }
#   endif

#endif