1 #ifndef __altaircam_h__
2 #define __altaircam_h__
3 
4 /* Version: 48.18195.2020.1222 */
5 /*
6    Platform & Architecture:
7        (1) Win32:
8               (a) x86: XP SP3 or above; CPU supports SSE2 instruction set or above
9               (b) x64: Win7 or above
10               (c) arm: Win10 or above
11               (d) arm64: Win10 or above
12        (2) WinRT: x86, x64, arm, arm64; Win10 or above
13        (3) macOS: universal (x64 + x86); macOS 10.10 or above
14        (4) Linux: kernel 2.6.27 or above
15               (a) x86: CPU supports SSE3 instruction set or above; GLIBC 2.8 or above
16               (b) x64: GLIBC 2.14 or above
17               (c) armel: GLIBC 2.17 or above; built by toolchain arm-linux-gnueabi (version 4.9.2)
18               (d) armhf: GLIBC 2.17 or above; built by toolchain arm-linux-gnueabihf (version 4.9.2)
19               (e) arm64: GLIBC 2.17 or above; built by toolchain aarch64-linux-gnu (version 4.9.2)
20        (5) Android: arm, arm64, x86, x64; built by android-ndk-r18b; __ANDROID_API__ = 23
21 */
22 /*
23     doc:
24        (1) en.html, English
25        (2) hans.html, Simplified Chinese
26 */
27 
28 #ifdef _WIN32
29 #ifndef _INC_WINDOWS
30 #include <windows.h>
31 #endif
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #if defined(__cplusplus) && (__cplusplus >= 201402L)
39 #define ALTAIRCAM_DEPRECATED  [[deprecated]]
40 #elif defined(_MSC_VER)
41 #define ALTAIRCAM_DEPRECATED  __declspec(deprecated)
42 #elif defined(__GNUC__) || defined(__clang__)
43 #define ALTAIRCAM_DEPRECATED  __attribute__((deprecated))
44 #else
45 #define ALTAIRCAM_DEPRECATED
46 #endif
47 
48 #ifdef _WIN32 /* Windows */
49 
50 #pragma pack(push, 8)
51 #ifdef ALTAIRCAM_EXPORTS
52 #define ALTAIRCAM_API(x)    __declspec(dllexport)   x   __stdcall  /* in Windows, we use __stdcall calling convention, see https://docs.microsoft.com/en-us/cpp/cpp/stdcall */
53 #elif !defined(ALTAIRCAM_NOIMPORTS)
54 #define ALTAIRCAM_API(x)    __declspec(dllimport)   x   __stdcall
55 #else
56 #define ALTAIRCAM_API(x)    x   __stdcall
57 #endif
58 
59 #else   /* Linux or macOS */
60 
61 #define ALTAIRCAM_API(x)    x
62 #if (!defined(HRESULT)) && (!defined(__COREFOUNDATION_CFPLUGINCOM__)) /* CFPlugInCOM.h */
63 #define HRESULT int
64 #endif
65 #ifndef SUCCEEDED
66 #define SUCCEEDED(hr)   (((HRESULT)(hr)) >= 0)
67 #endif
68 #ifndef FAILED
69 #define FAILED(hr)      (((HRESULT)(hr)) < 0)
70 #endif
71 
72 #ifndef __stdcall
73 #define __stdcall
74 #endif
75 
76 #ifndef __BITMAPINFOHEADER_DEFINED__
77 #define __BITMAPINFOHEADER_DEFINED__
78 typedef struct {
79     unsigned        biSize;
80     int             biWidth;
81     int             biHeight;
82     unsigned short  biPlanes;
83     unsigned short  biBitCount;
84     unsigned        biCompression;
85     unsigned        biSizeImage;
86     int             biXPelsPerMeter;
87     int             biYPelsPerMeter;
88     unsigned        biClrUsed;
89     unsigned        biClrImportant;
90 } BITMAPINFOHEADER;
91 #endif
92 
93 #ifndef __RECT_DEFINED__
94 #define __RECT_DEFINED__
95 typedef struct {
96     int left;
97     int top;
98     int right;
99     int bottom;
100 } RECT, *PRECT;
101 #endif
102 
103 #endif
104 
105 #ifndef TDIBWIDTHBYTES
106 #define TDIBWIDTHBYTES(bits)  ((unsigned)(((bits) + 31) & (~31)) / 8)
107 #endif
108 
109 /********************************************************************************/
110 /* HRESULT                                                                      */
111 /*    |----------------|---------------------------------------|------------|   */
112 /*    | S_OK           |   Operation successful                | 0x00000000 |   */
113 /*    | S_FALSE        |   Operation successful                | 0x00000001 |   */
114 /*    | E_FAIL         |   Unspecified failure                 | 0x80004005 |   */
115 /*    | E_ACCESSDENIED |   General access denied error         | 0x80070005 |   */
116 /*    | E_INVALIDARG   |   One or more arguments are not valid | 0x80070057 |   */
117 /*    | E_NOTIMPL      |   Not supported or not implemented    | 0x80004001 |   */
118 /*    | E_NOINTERFACE  |   Interface not supported             | 0x80004002 |   */
119 /*    | E_POINTER      |   Pointer that is not valid           | 0x80004003 |   */
120 /*    | E_UNEXPECTED   |   Unexpected failure                  | 0x8000FFFF |   */
121 /*    | E_OUTOFMEMORY  |   Out of memory                       | 0x8007000E |   */
122 /*    | E_WRONG_THREAD |   call function in the wrong thread   | 0x8001010E |   */
123 /*    | E_GEN_FAILURE  |   device not functioning              | 0x8007001F |   */
124 /*    |----------------|---------------------------------------|------------|   */
125 /********************************************************************************/
126 /*                                                                              */
127 /* Please note that the return value >= 0 means success                         */
128 /* (especially S_FALSE is also successful, indicating that the internal value and the value set by the user is equivalent, which means "no operation"). */
129 /* Therefore, the SUCCEEDEDand FAILED macros should generally be used to determine whether the return value is successful or failed. */
130 /* (Unless there are special needs, do not use "==S_OK" or "==0" to judge the return value) */
131 /*                                                                              */
132 /* #define SUCCEEDED(hr)   (((HRESULT)(hr)) >= 0)                               */
133 /* #define FAILED(hr)      (((HRESULT)(hr)) < 0)                                */
134 /*                                                                              */
135 /********************************************************************************/
136 
137 /* handle */
138 typedef struct AltaircamT { int unused; } *HAltaircam, *HAltairCam;
139 
140 #define ALTAIRCAM_MAX                      16
141 
142 #define ALTAIRCAM_FLAG_CMOS                0x00000001  /* cmos sensor */
143 #define ALTAIRCAM_FLAG_CCD_PROGRESSIVE     0x00000002  /* progressive ccd sensor */
144 #define ALTAIRCAM_FLAG_CCD_INTERLACED      0x00000004  /* interlaced ccd sensor */
145 #define ALTAIRCAM_FLAG_ROI_HARDWARE        0x00000008  /* support hardware ROI */
146 #define ALTAIRCAM_FLAG_MONO                0x00000010  /* monochromatic */
147 #define ALTAIRCAM_FLAG_BINSKIP_SUPPORTED   0x00000020  /* support bin/skip mode, see Altaircam_put_Mode and Altaircam_get_Mode */
148 #define ALTAIRCAM_FLAG_USB30               0x00000040  /* usb3.0 */
149 #define ALTAIRCAM_FLAG_TEC                 0x00000080  /* Thermoelectric Cooler */
150 #define ALTAIRCAM_FLAG_USB30_OVER_USB20    0x00000100  /* usb3.0 camera connected to usb2.0 port */
151 #define ALTAIRCAM_FLAG_ST4                 0x00000200  /* ST4 port */
152 #define ALTAIRCAM_FLAG_GETTEMPERATURE      0x00000400  /* support to get the temperature of the sensor */
153 #define ALTAIRCAM_FLAG_RAW10               0x00001000  /* pixel format, RAW 10bits */
154 #define ALTAIRCAM_FLAG_RAW12               0x00002000  /* pixel format, RAW 12bits */
155 #define ALTAIRCAM_FLAG_RAW14               0x00004000  /* pixel format, RAW 14bits */
156 #define ALTAIRCAM_FLAG_RAW16               0x00008000  /* pixel format, RAW 16bits */
157 #define ALTAIRCAM_FLAG_FAN                 0x00010000  /* cooling fan */
158 #define ALTAIRCAM_FLAG_TEC_ONOFF           0x00020000  /* Thermoelectric Cooler can be turn on or off, support to set the target temperature of TEC */
159 #define ALTAIRCAM_FLAG_ISP                 0x00040000  /* ISP (Image Signal Processing) chip */
160 #define ALTAIRCAM_FLAG_TRIGGER_SOFTWARE    0x00080000  /* support software trigger */
161 #define ALTAIRCAM_FLAG_TRIGGER_EXTERNAL    0x00100000  /* support external trigger */
162 #define ALTAIRCAM_FLAG_TRIGGER_SINGLE      0x00200000  /* only support trigger single: one trigger, one image */
163 #define ALTAIRCAM_FLAG_BLACKLEVEL          0x00400000  /* support set and get the black level */
164 #define ALTAIRCAM_FLAG_AUTO_FOCUS          0x00800000  /* support auto focus */
165 #define ALTAIRCAM_FLAG_BUFFER              0x01000000  /* frame buffer */
166 #define ALTAIRCAM_FLAG_DDR                 0x02000000  /* use very large capacity DDR (Double Data Rate SDRAM) for frame buffer */
167 #define ALTAIRCAM_FLAG_CG                  0x04000000  /* Conversion Gain: HCG, LCG */
168 #define ALTAIRCAM_FLAG_YUV411              0x08000000  /* pixel format, yuv411 */
169 #define ALTAIRCAM_FLAG_VUYY                0x10000000  /* pixel format, yuv422, VUYY */
170 #define ALTAIRCAM_FLAG_YUV444              0x20000000  /* pixel format, yuv444 */
171 #define ALTAIRCAM_FLAG_RGB888              0x40000000  /* pixel format, RGB888 */
172 #define ALTAIRCAM_FLAG_RAW8                0x80000000  /* pixel format, RAW 8 bits */
173 #define ALTAIRCAM_FLAG_GMCY8               0x0000000100000000  /* pixel format, GMCY, 8bits */
174 #define ALTAIRCAM_FLAG_GMCY12              0x0000000200000000  /* pixel format, GMCY, 12bits */
175 #define ALTAIRCAM_FLAG_UYVY                0x0000000400000000  /* pixel format, yuv422, UYVY */
176 #define ALTAIRCAM_FLAG_CGHDR               0x0000000800000000  /* Conversion Gain: HCG, LCG, HDR */
177 #define ALTAIRCAM_FLAG_GLOBALSHUTTER       0x0000001000000000  /* global shutter */
178 #define ALTAIRCAM_FLAG_FOCUSMOTOR          0x0000002000000000  /* support focus motor */
179 #define ALTAIRCAM_FLAG_PRECISE_FRAMERATE   0x0000004000000000  /* support precise framerate & bandwidth, see ALTAIRCAM_OPTION_PRECISE_FRAMERATE & ALTAIRCAM_OPTION_BANDWIDTH */
180 #define ALTAIRCAM_FLAG_HEAT                0x0000008000000000  /* heat to prevent fogging up */
181 #define ALTAIRCAM_FLAG_LOW_NOISE           0x0000010000000000  /* low noise mode */
182 #define ALTAIRCAM_FLAG_LEVELRANGE_HARDWARE 0x0000020000000000  /* hardware level range, put(get)_LevelRangeV2 */
183 #define ALTAIRCAM_FLAG_EVENT_HARDWARE      0x0000040000000000  /* hardware event, such as exposure start & stop */
184 
185 #define ALTAIRCAM_TEMP_DEF                 6503    /* temp, default */
186 #define ALTAIRCAM_TEMP_MIN                 2000    /* temp, minimum */
187 #define ALTAIRCAM_TEMP_MAX                 15000   /* temp, maximum */
188 #define ALTAIRCAM_TINT_DEF                 1000    /* tint */
189 #define ALTAIRCAM_TINT_MIN                 200     /* tint */
190 #define ALTAIRCAM_TINT_MAX                 2500    /* tint */
191 #define ALTAIRCAM_HUE_DEF                  0       /* hue */
192 #define ALTAIRCAM_HUE_MIN                  (-180)  /* hue */
193 #define ALTAIRCAM_HUE_MAX                  180     /* hue */
194 #define ALTAIRCAM_SATURATION_DEF           128     /* saturation */
195 #define ALTAIRCAM_SATURATION_MIN           0       /* saturation */
196 #define ALTAIRCAM_SATURATION_MAX           255     /* saturation */
197 #define ALTAIRCAM_BRIGHTNESS_DEF           0       /* brightness */
198 #define ALTAIRCAM_BRIGHTNESS_MIN           (-64)   /* brightness */
199 #define ALTAIRCAM_BRIGHTNESS_MAX           64      /* brightness */
200 #define ALTAIRCAM_CONTRAST_DEF             0       /* contrast */
201 #define ALTAIRCAM_CONTRAST_MIN             (-100)  /* contrast */
202 #define ALTAIRCAM_CONTRAST_MAX             100     /* contrast */
203 #define ALTAIRCAM_GAMMA_DEF                100     /* gamma */
204 #define ALTAIRCAM_GAMMA_MIN                20      /* gamma */
205 #define ALTAIRCAM_GAMMA_MAX                180     /* gamma */
206 #define ALTAIRCAM_AETARGET_DEF             120     /* target of auto exposure */
207 #define ALTAIRCAM_AETARGET_MIN             16      /* target of auto exposure */
208 #define ALTAIRCAM_AETARGET_MAX             220     /* target of auto exposure */
209 #define ALTAIRCAM_WBGAIN_DEF               0       /* white balance gain */
210 #define ALTAIRCAM_WBGAIN_MIN               (-127)  /* white balance gain */
211 #define ALTAIRCAM_WBGAIN_MAX               127     /* white balance gain */
212 #define ALTAIRCAM_BLACKLEVEL_MIN           0       /* minimum black level */
213 #define ALTAIRCAM_BLACKLEVEL8_MAX          31              /* maximum black level for bit depth = 8 */
214 #define ALTAIRCAM_BLACKLEVEL10_MAX         (31 * 4)        /* maximum black level for bit depth = 10 */
215 #define ALTAIRCAM_BLACKLEVEL12_MAX         (31 * 16)       /* maximum black level for bit depth = 12 */
216 #define ALTAIRCAM_BLACKLEVEL14_MAX         (31 * 64)       /* maximum black level for bit depth = 14 */
217 #define ALTAIRCAM_BLACKLEVEL16_MAX         (31 * 256)      /* maximum black level for bit depth = 16 */
218 #define ALTAIRCAM_SHARPENING_STRENGTH_DEF  0       /* sharpening strength */
219 #define ALTAIRCAM_SHARPENING_STRENGTH_MIN  0       /* sharpening strength */
220 #define ALTAIRCAM_SHARPENING_STRENGTH_MAX  500     /* sharpening strength */
221 #define ALTAIRCAM_SHARPENING_RADIUS_DEF    2       /* sharpening radius */
222 #define ALTAIRCAM_SHARPENING_RADIUS_MIN    1       /* sharpening radius */
223 #define ALTAIRCAM_SHARPENING_RADIUS_MAX    10      /* sharpening radius */
224 #define ALTAIRCAM_SHARPENING_THRESHOLD_DEF 0       /* sharpening threshold */
225 #define ALTAIRCAM_SHARPENING_THRESHOLD_MIN 0       /* sharpening threshold */
226 #define ALTAIRCAM_SHARPENING_THRESHOLD_MAX 255     /* sharpening threshold */
227 #define ALTAIRCAM_AUTOEXPO_THRESHOLD_DEF   5       /* auto exposure threshold */
228 #define ALTAIRCAM_AUTOEXPO_THRESHOLD_MIN   2       /* auto exposure threshold */
229 #define ALTAIRCAM_AUTOEXPO_THRESHOLD_MAX   15      /* auto exposure threshold */
230 #define ALTAIRCAM_BANDWIDTH_DEF            90      /* bandwidth */
231 #define ALTAIRCAM_BANDWIDTH_MIN            1       /* bandwidth */
232 #define ALTAIRCAM_BANDWIDTH_MAX            100     /* bandwidth */
233 #define ALTAIRCAM_DENOISE_DEF              0       /* denoise */
234 #define ALTAIRCAM_DENOISE_MIN              0       /* denoise */
235 #define ALTAIRCAM_DENOISE_MAX              100     /* denoise */
236 
237 typedef struct{
238     unsigned    width;
239     unsigned    height;
240 }AltaircamResolution;
241 
242 /* In Windows platform, we always use UNICODE wchar_t */
243 /* In Linux or macOS, we use char */
244 
245 typedef struct {
246 #ifdef _WIN32
247     const wchar_t*      name;        /* model name, in Windows, we use unicode */
248 #else
249     const char*         name;        /* model name */
250 #endif
251     unsigned long long  flag;        /* ALTAIRCAM_FLAG_xxx, 64 bits */
252     unsigned            maxspeed;    /* number of speed level, same as Altaircam_get_MaxSpeed(), the speed range = [0, maxspeed], closed interval */
253     unsigned            preview;     /* number of preview resolution, same as Altaircam_get_ResolutionNumber() */
254     unsigned            still;       /* number of still resolution, same as Altaircam_get_StillResolutionNumber() */
255     unsigned            maxfanspeed; /* maximum fan speed */
256     unsigned            ioctrol;     /* number of input/output control */
257     float               xpixsz;      /* physical pixel size */
258     float               ypixsz;      /* physical pixel size */
259     AltaircamResolution   res[ALTAIRCAM_MAX];
260 }AltaircamModelV2; /* camera model v2 */
261 
262 typedef struct {
263 #ifdef _WIN32
264     wchar_t               displayname[64];    /* display name */
265     wchar_t               id[64];             /* unique and opaque id of a connected camera, for Altaircam_Open */
266 #else
267     char                  displayname[64];    /* display name */
268     char                  id[64];             /* unique and opaque id of a connected camera, for Altaircam_Open */
269 #endif
270     const AltaircamModelV2* model;
271 }AltaircamDeviceV2; /* camera instance for enumerating */
272 
273 /*
274     get the version of this dll/so/dylib, which is: 48.18195.2020.1222
275 */
276 #ifdef _WIN32
277 ALTAIRCAM_API(const wchar_t*)   Altaircam_Version();
278 #else
279 ALTAIRCAM_API(const char*)      Altaircam_Version();
280 #endif
281 
282 /*
283     enumerate the cameras connected to the computer, return the number of enumerated.
284 
285     AltaircamDeviceV2 arr[ALTAIRCAM_MAX];
286     unsigned cnt = Altaircam_EnumV2(arr);
287     for (unsigned i = 0; i < cnt; ++i)
288         ...
289 
290     if pti == NULL, then, only the number is returned.
291     Altaircam_Enum is obsolete.
292 */
293 ALTAIRCAM_API(unsigned) Altaircam_EnumV2(AltaircamDeviceV2 pti[ALTAIRCAM_MAX]);
294 
295 /* use the id of AltaircamDeviceV2, which is enumerated by Altaircam_EnumV2.
296     if id is NULL, Altaircam_Open will open the first camera.
297 */
298 #ifdef _WIN32
299 ALTAIRCAM_API(HAltaircam) Altaircam_Open(const wchar_t* id);
300 #else
301 ALTAIRCAM_API(HAltaircam) Altaircam_Open(const char* id);
302 #endif
303 
304 /*
305     the same with Altaircam_Open, but use the index as the parameter. such as:
306     index == 0, open the first camera,
307     index == 1, open the second camera,
308     etc
309 */
310 ALTAIRCAM_API(HAltaircam) Altaircam_OpenByIndex(unsigned index);
311 
312 ALTAIRCAM_API(void)     Altaircam_Close(HAltaircam h);  /* close the handle */
313 
314 #define ALTAIRCAM_EVENT_EXPOSURE          0x0001    /* exposure time or gain changed */
315 #define ALTAIRCAM_EVENT_TEMPTINT          0x0002    /* white balance changed, Temp/Tint mode */
316 #define ALTAIRCAM_EVENT_IMAGE             0x0004    /* live image arrived, use Altaircam_PullImage to get this image */
317 #define ALTAIRCAM_EVENT_STILLIMAGE        0x0005    /* snap (still) frame arrived, use Altaircam_PullStillImage to get this frame */
318 #define ALTAIRCAM_EVENT_WBGAIN            0x0006    /* white balance changed, RGB Gain mode */
319 #define ALTAIRCAM_EVENT_TRIGGERFAIL       0x0007    /* trigger failed */
320 #define ALTAIRCAM_EVENT_BLACK             0x0008    /* black balance changed */
321 #define ALTAIRCAM_EVENT_FFC               0x0009    /* flat field correction status changed */
322 #define ALTAIRCAM_EVENT_DFC               0x000a    /* dark field correction status changed */
323 #define ALTAIRCAM_EVENT_ROI               0x000b    /* roi changed */
324 #define ALTAIRCAM_EVENT_LEVELRANGE        0x000c    /* level range changed */
325 #define ALTAIRCAM_EVENT_ERROR             0x0080    /* generic error */
326 #define ALTAIRCAM_EVENT_DISCONNECTED      0x0081    /* camera disconnected */
327 #define ALTAIRCAM_EVENT_NOFRAMETIMEOUT    0x0082    /* no frame timeout error */
328 #define ALTAIRCAM_EVENT_AFFEEDBACK        0x0083    /* auto focus feedback information */
329 #define ALTAIRCAM_EVENT_AFPOSITION        0x0084    /* auto focus sensor board positon */
330 #define ALTAIRCAM_EVENT_NOPACKETTIMEOUT   0x0085    /* no packet timeout */
331 #define ALTAIRCAM_EVENT_EXPO_START        0x4000    /* exposure start */
332 #define ALTAIRCAM_EVENT_EXPO_STOP         0x4001    /* exposure stop */
333 #define ALTAIRCAM_EVENT_TRIGGER_ALLOW     0x4002    /* next trigger allow */
334 #define ALTAIRCAM_EVENT_FACTORY           0x8001    /* restore factory settings */
335 
336 #ifdef _WIN32
337 ALTAIRCAM_API(HRESULT)  Altaircam_StartPullModeWithWndMsg(HAltaircam h, HWND hWnd, UINT nMsg);
338 #endif
339 
340 /* Do NOT call Altaircam_Close, Altaircam_Stop in this callback context, it deadlocks. */
341 typedef void (__stdcall* PALTAIRCAM_EVENT_CALLBACK)(unsigned nEvent, void* pCallbackCtx);
342 ALTAIRCAM_API(HRESULT)  Altaircam_StartPullModeWithCallback(HAltaircam h, PALTAIRCAM_EVENT_CALLBACK pEventCallback, void* pCallbackContext);
343 
344 #define ALTAIRCAM_FRAMEINFO_FLAG_SEQ          0x01 /* sequence number */
345 #define ALTAIRCAM_FRAMEINFO_FLAG_TIMESTAMP    0x02 /* timestamp */
346 
347 typedef struct {
348     unsigned            width;
349     unsigned            height;
350     unsigned            flag;       /* ALTAIRCAM_FRAMEINFO_FLAG_xxxx */
351     unsigned            seq;        /* sequence number */
352     unsigned long long  timestamp;  /* microsecond */
353 }AltaircamFrameInfoV2;
354 
355 /*
356     bits: 24 (RGB24), 32 (RGB32), 8 (Gray) or 16 (Gray). In RAW mode, this parameter is ignored.
357     pnWidth, pnHeight: OUT parameter
358     rowPitch: The distance from one row to the next row. rowPitch = 0 means using the default row pitch.
359 
360     -------------------------------------------------------------------------------------
361     | format                                            | default row pitch             |
362     |---------------------------------------------------|-------------------------------|
363     | RGB       | RGB24                                 | TDIBWIDTHBYTES(24 * Width)    |
364     |           | RGB32                                 | Width * 4                     |
365     |           | RGB48                                 | TDIBWIDTHBYTES(48 * Width)    |
366     |           | RGB8 grey image                       | TDIBWIDTHBYTES(8 * Width)     |
367     |-----------|---------------------------------------|-------------------------------|
368     | RAW       | 8bits Mode                            | Width                         |
369     |           | 10bits, 12bits, 14bits, 16bits Mode   | Width * 2                     |
370     |-----------|---------------------------------------|-------------------------------|
371 */
372 ALTAIRCAM_API(HRESULT)  Altaircam_PullImageV2(HAltaircam h, void* pImageData, int bits, AltaircamFrameInfoV2* pInfo);
373 ALTAIRCAM_API(HRESULT)  Altaircam_PullStillImageV2(HAltaircam h, void* pImageData, int bits, AltaircamFrameInfoV2* pInfo);
374 ALTAIRCAM_API(HRESULT)  Altaircam_PullImageWithRowPitchV2(HAltaircam h, void* pImageData, int bits, int rowPitch, AltaircamFrameInfoV2* pInfo);
375 ALTAIRCAM_API(HRESULT)  Altaircam_PullStillImageWithRowPitchV2(HAltaircam h, void* pImageData, int bits, int rowPitch, AltaircamFrameInfoV2* pInfo);
376 
377 ALTAIRCAM_API(HRESULT)  Altaircam_PullImage(HAltaircam h, void* pImageData, int bits, unsigned* pnWidth, unsigned* pnHeight);
378 ALTAIRCAM_API(HRESULT)  Altaircam_PullStillImage(HAltaircam h, void* pImageData, int bits, unsigned* pnWidth, unsigned* pnHeight);
379 ALTAIRCAM_API(HRESULT)  Altaircam_PullImageWithRowPitch(HAltaircam h, void* pImageData, int bits, int rowPitch, unsigned* pnWidth, unsigned* pnHeight);
380 ALTAIRCAM_API(HRESULT)  Altaircam_PullStillImageWithRowPitch(HAltaircam h, void* pImageData, int bits, int rowPitch, unsigned* pnWidth, unsigned* pnHeight);
381 
382 /*
383     (NULL == pData) means that something is error
384     pCallbackCtx is the callback context which is passed by Altaircam_StartPushModeV3
385     bSnap: TRUE if Altaircam_Snap
386 
387     pDataCallback is callbacked by an internal thread of altaircam.dll, so please pay attention to multithread problem.
388     Do NOT call Altaircam_Close, Altaircam_Stop in this callback context, it deadlocks.
389 */
390 typedef void (__stdcall* PALTAIRCAM_DATA_CALLBACK_V3)(const void* pData, const AltaircamFrameInfoV2* pInfo, int bSnap, void* pCallbackCtx);
391 ALTAIRCAM_API(HRESULT)  Altaircam_StartPushModeV3(HAltaircam h, PALTAIRCAM_DATA_CALLBACK_V3 pDataCallback, void* pDataCallbackCtx, PALTAIRCAM_EVENT_CALLBACK pEventCallback, void* pEventCallbackContext);
392 
393 ALTAIRCAM_API(HRESULT)  Altaircam_Stop(HAltaircam h);
394 ALTAIRCAM_API(HRESULT)  Altaircam_Pause(HAltaircam h, int bPause);
395 
396 /*  for pull mode: ALTAIRCAM_EVENT_STILLIMAGE, and then Altaircam_PullStillImage
397     for push mode: the snapped image will be return by PALTAIRCAM_DATA_CALLBACK(V2), with the parameter 'bSnap' set to 'TRUE'
398 */
399 ALTAIRCAM_API(HRESULT)  Altaircam_Snap(HAltaircam h, unsigned nResolutionIndex);  /* still image snap */
400 ALTAIRCAM_API(HRESULT)  Altaircam_SnapN(HAltaircam h, unsigned nResolutionIndex, unsigned nNumber);  /* multiple still image snap */
401 /*
402     soft trigger:
403     nNumber:    0xffff:     trigger continuously
404                 0:          cancel trigger
405                 others:     number of images to be triggered
406 */
407 ALTAIRCAM_API(HRESULT)  Altaircam_Trigger(HAltaircam h, unsigned short nNumber);
408 
409 /*
410     put_Size, put_eSize, can be used to set the video output resolution BEFORE Altaircam_StartXXXX.
411     put_Size use width and height parameters, put_eSize use the index parameter.
412     for example, UCMOS03100KPA support the following resolutions:
413             index 0:    2048,   1536
414             index 1:    1024,   768
415             index 2:    680,    510
416     so, we can use put_Size(h, 1024, 768) or put_eSize(h, 1). Both have the same effect.
417 */
418 ALTAIRCAM_API(HRESULT)  Altaircam_put_Size(HAltaircam h, int nWidth, int nHeight);
419 ALTAIRCAM_API(HRESULT)  Altaircam_get_Size(HAltaircam h, int* pWidth, int* pHeight);
420 ALTAIRCAM_API(HRESULT)  Altaircam_put_eSize(HAltaircam h, unsigned nResolutionIndex);
421 ALTAIRCAM_API(HRESULT)  Altaircam_get_eSize(HAltaircam h, unsigned* pnResolutionIndex);
422 
423 /*
424     final size after ROI, rotate, binning
425 */
426 ALTAIRCAM_API(HRESULT)  Altaircam_get_FinalSize(HAltaircam h, int* pWidth, int* pHeight);
427 
428 ALTAIRCAM_API(HRESULT)  Altaircam_get_ResolutionNumber(HAltaircam h);
429 ALTAIRCAM_API(HRESULT)  Altaircam_get_Resolution(HAltaircam h, unsigned nResolutionIndex, int* pWidth, int* pHeight);
430 /*
431     numerator/denominator, such as: 1/1, 1/2, 1/3
432 */
433 ALTAIRCAM_API(HRESULT)  Altaircam_get_ResolutionRatio(HAltaircam h, unsigned nResolutionIndex, int* pNumerator, int* pDenominator);
434 ALTAIRCAM_API(HRESULT)  Altaircam_get_Field(HAltaircam h);
435 
436 /*
437 see: http://www.fourcc.org
438 FourCC:
439     MAKEFOURCC('G', 'B', 'R', 'G'), see http://www.siliconimaging.com/RGB%20Bayer.htm
440     MAKEFOURCC('R', 'G', 'G', 'B')
441     MAKEFOURCC('B', 'G', 'G', 'R')
442     MAKEFOURCC('G', 'R', 'B', 'G')
443     MAKEFOURCC('Y', 'Y', 'Y', 'Y'), monochromatic sensor
444     MAKEFOURCC('Y', '4', '1', '1'), yuv411
445     MAKEFOURCC('V', 'U', 'Y', 'Y'), yuv422
446     MAKEFOURCC('U', 'Y', 'V', 'Y'), yuv422
447     MAKEFOURCC('Y', '4', '4', '4'), yuv444
448     MAKEFOURCC('R', 'G', 'B', '8'), RGB888
449 
450 #ifndef MAKEFOURCC
451 #define MAKEFOURCC(a, b, c, d) ((unsigned)(unsigned char)(a) | ((unsigned)(unsigned char)(b) << 8) | ((unsigned)(unsigned char)(c) << 16) | ((unsigned)(unsigned char)(d) << 24))
452 #endif
453 */
454 ALTAIRCAM_API(HRESULT)  Altaircam_get_RawFormat(HAltaircam h, unsigned* nFourCC, unsigned* bitsperpixel);
455 
456 /*
457     ------------------------------------------------------------------|
458     | Parameter               |   Range       |   Default             |
459     |-----------------------------------------------------------------|
460     | Auto Exposure Target    |   10~220      |   120                 |
461     | Temp                    |   2000~15000  |   6503                |
462     | Tint                    |   200~2500    |   1000                |
463     | LevelRange              |   0~255       |   Low = 0, High = 255 |
464     | Contrast                |   -100~100    |   0                   |
465     | Hue                     |   -180~180    |   0                   |
466     | Saturation              |   0~255       |   128                 |
467     | Brightness              |   -64~64      |   0                   |
468     | Gamma                   |   20~180      |   100                 |
469     | WBGain                  |   -127~127    |   0                   |
470     ------------------------------------------------------------------|
471 */
472 
473 #ifndef __ALTAIRCAM_CALLBACK_DEFINED__
474 #define __ALTAIRCAM_CALLBACK_DEFINED__
475 typedef void (__stdcall* PIALTAIRCAM_EXPOSURE_CALLBACK)(void* pCtx);                                     /* auto exposure */
476 typedef void (__stdcall* PIALTAIRCAM_WHITEBALANCE_CALLBACK)(const int aGain[3], void* pCtx);             /* once white balance, RGB Gain mode */
477 typedef void (__stdcall* PIALTAIRCAM_BLACKBALANCE_CALLBACK)(const unsigned short aSub[3], void* pCtx);   /* once black balance */
478 typedef void (__stdcall* PIALTAIRCAM_TEMPTINT_CALLBACK)(const int nTemp, const int nTint, void* pCtx);   /* once white balance, Temp/Tint Mode */
479 typedef void (__stdcall* PIALTAIRCAM_HISTOGRAM_CALLBACK)(const float aHistY[256], const float aHistR[256], const float aHistG[256], const float aHistB[256], void* pCtx);
480 typedef void (__stdcall* PIALTAIRCAM_CHROME_CALLBACK)(void* pCtx);
481 #endif
482 
483 ALTAIRCAM_API(HRESULT)  Altaircam_get_AutoExpoEnable(HAltaircam h, int* bAutoExposure);
484 ALTAIRCAM_API(HRESULT)  Altaircam_put_AutoExpoEnable(HAltaircam h, int bAutoExposure);
485 ALTAIRCAM_API(HRESULT)  Altaircam_get_AutoExpoTarget(HAltaircam h, unsigned short* Target);
486 ALTAIRCAM_API(HRESULT)  Altaircam_put_AutoExpoTarget(HAltaircam h, unsigned short Target);
487 
488 /*set the maximum/minimal auto exposure time and agin. The default maximum auto exposure time is 350ms */
489 ALTAIRCAM_API(HRESULT)  Altaircam_put_MaxAutoExpoTimeAGain(HAltaircam h, unsigned maxTime, unsigned short maxAGain);
490 ALTAIRCAM_API(HRESULT)  Altaircam_get_MaxAutoExpoTimeAGain(HAltaircam h, unsigned* maxTime, unsigned short* maxAGain);
491 ALTAIRCAM_API(HRESULT)  Altaircam_put_MinAutoExpoTimeAGain(HAltaircam h, unsigned minTime, unsigned short minAGain);
492 ALTAIRCAM_API(HRESULT)  Altaircam_get_MinAutoExpoTimeAGain(HAltaircam h, unsigned* minTime, unsigned short* minAGain);
493 
494 ALTAIRCAM_API(HRESULT)  Altaircam_get_ExpoTime(HAltaircam h, unsigned* Time); /* in microseconds */
495 ALTAIRCAM_API(HRESULT)  Altaircam_put_ExpoTime(HAltaircam h, unsigned Time); /* in microseconds */
496 ALTAIRCAM_API(HRESULT)  Altaircam_get_RealExpoTime(HAltaircam h, unsigned* Time); /* in microseconds, based on 50HZ/60HZ/DC */
497 ALTAIRCAM_API(HRESULT)  Altaircam_get_ExpTimeRange(HAltaircam h, unsigned* nMin, unsigned* nMax, unsigned* nDef);
498 
499 ALTAIRCAM_API(HRESULT)  Altaircam_get_ExpoAGain(HAltaircam h, unsigned short* AGain); /* percent, such as 300 */
500 ALTAIRCAM_API(HRESULT)  Altaircam_put_ExpoAGain(HAltaircam h, unsigned short AGain); /* percent */
501 ALTAIRCAM_API(HRESULT)  Altaircam_get_ExpoAGainRange(HAltaircam h, unsigned short* nMin, unsigned short* nMax, unsigned short* nDef);
502 
503 /* Auto White Balance "Once", Temp/Tint Mode */
504 ALTAIRCAM_API(HRESULT)  Altaircam_AwbOnce(HAltaircam h, PIALTAIRCAM_TEMPTINT_CALLBACK fnTTProc, void* pTTCtx); /* auto white balance "once". This function must be called AFTER Altaircam_StartXXXX */
505 
506 /* Auto White Balance, RGB Gain Mode */
507 ALTAIRCAM_API(HRESULT)  Altaircam_AwbInit(HAltaircam h, PIALTAIRCAM_WHITEBALANCE_CALLBACK fnWBProc, void* pWBCtx);
508 
509 /* White Balance, Temp/Tint mode */
510 ALTAIRCAM_API(HRESULT)  Altaircam_put_TempTint(HAltaircam h, int nTemp, int nTint);
511 ALTAIRCAM_API(HRESULT)  Altaircam_get_TempTint(HAltaircam h, int* nTemp, int* nTint);
512 
513 /* White Balance, RGB Gain mode */
514 ALTAIRCAM_API(HRESULT)  Altaircam_put_WhiteBalanceGain(HAltaircam h, int aGain[3]);
515 ALTAIRCAM_API(HRESULT)  Altaircam_get_WhiteBalanceGain(HAltaircam h, int aGain[3]);
516 
517 /* Black Balance */
518 ALTAIRCAM_API(HRESULT)  Altaircam_AbbOnce(HAltaircam h, PIALTAIRCAM_BLACKBALANCE_CALLBACK fnBBProc, void* pBBCtx); /* auto black balance "once". This function must be called AFTER Altaircam_StartXXXX */
519 ALTAIRCAM_API(HRESULT)  Altaircam_put_BlackBalance(HAltaircam h, unsigned short aSub[3]);
520 ALTAIRCAM_API(HRESULT)  Altaircam_get_BlackBalance(HAltaircam h, unsigned short aSub[3]);
521 
522 /* Flat Field Correction */
523 ALTAIRCAM_API(HRESULT)  Altaircam_FfcOnce(HAltaircam h);
524 #ifdef _WIN32
525 ALTAIRCAM_API(HRESULT)  Altaircam_FfcExport(HAltaircam h, const wchar_t* filepath);
526 ALTAIRCAM_API(HRESULT)  Altaircam_FfcImport(HAltaircam h, const wchar_t* filepath);
527 #else
528 ALTAIRCAM_API(HRESULT)  Altaircam_FfcExport(HAltaircam h, const char* filepath);
529 ALTAIRCAM_API(HRESULT)  Altaircam_FfcImport(HAltaircam h, const char* filepath);
530 #endif
531 
532 /* Dark Field Correction */
533 ALTAIRCAM_API(HRESULT)  Altaircam_DfcOnce(HAltaircam h);
534 
535 #ifdef _WIN32
536 ALTAIRCAM_API(HRESULT)  Altaircam_DfcExport(HAltaircam h, const wchar_t* filepath);
537 ALTAIRCAM_API(HRESULT)  Altaircam_DfcImport(HAltaircam h, const wchar_t* filepath);
538 #else
539 ALTAIRCAM_API(HRESULT)  Altaircam_DfcExport(HAltaircam h, const char* filepath);
540 ALTAIRCAM_API(HRESULT)  Altaircam_DfcImport(HAltaircam h, const char* filepath);
541 #endif
542 
543 ALTAIRCAM_API(HRESULT)  Altaircam_put_Hue(HAltaircam h, int Hue);
544 ALTAIRCAM_API(HRESULT)  Altaircam_get_Hue(HAltaircam h, int* Hue);
545 ALTAIRCAM_API(HRESULT)  Altaircam_put_Saturation(HAltaircam h, int Saturation);
546 ALTAIRCAM_API(HRESULT)  Altaircam_get_Saturation(HAltaircam h, int* Saturation);
547 ALTAIRCAM_API(HRESULT)  Altaircam_put_Brightness(HAltaircam h, int Brightness);
548 ALTAIRCAM_API(HRESULT)  Altaircam_get_Brightness(HAltaircam h, int* Brightness);
549 ALTAIRCAM_API(HRESULT)  Altaircam_get_Contrast(HAltaircam h, int* Contrast);
550 ALTAIRCAM_API(HRESULT)  Altaircam_put_Contrast(HAltaircam h, int Contrast);
551 ALTAIRCAM_API(HRESULT)  Altaircam_get_Gamma(HAltaircam h, int* Gamma); /* percent */
552 ALTAIRCAM_API(HRESULT)  Altaircam_put_Gamma(HAltaircam h, int Gamma);  /* percent */
553 
554 ALTAIRCAM_API(HRESULT)  Altaircam_get_Chrome(HAltaircam h, int* bChrome);  /* monochromatic mode */
555 ALTAIRCAM_API(HRESULT)  Altaircam_put_Chrome(HAltaircam h, int bChrome);
556 
557 ALTAIRCAM_API(HRESULT)  Altaircam_get_VFlip(HAltaircam h, int* bVFlip);  /* vertical flip */
558 ALTAIRCAM_API(HRESULT)  Altaircam_put_VFlip(HAltaircam h, int bVFlip);
559 ALTAIRCAM_API(HRESULT)  Altaircam_get_HFlip(HAltaircam h, int* bHFlip);
560 ALTAIRCAM_API(HRESULT)  Altaircam_put_HFlip(HAltaircam h, int bHFlip); /* horizontal flip */
561 
562 ALTAIRCAM_API(HRESULT)  Altaircam_get_Negative(HAltaircam h, int* bNegative);  /* negative film */
563 ALTAIRCAM_API(HRESULT)  Altaircam_put_Negative(HAltaircam h, int bNegative);
564 
565 ALTAIRCAM_API(HRESULT)  Altaircam_put_Speed(HAltaircam h, unsigned short nSpeed);
566 ALTAIRCAM_API(HRESULT)  Altaircam_get_Speed(HAltaircam h, unsigned short* pSpeed);
567 ALTAIRCAM_API(HRESULT)  Altaircam_get_MaxSpeed(HAltaircam h); /* get the maximum speed, see "Frame Speed Level", the speed range = [0, max], closed interval */
568 
569 ALTAIRCAM_API(HRESULT)  Altaircam_get_FanMaxSpeed(HAltaircam h); /* get the maximum fan speed, the fan speed range = [0, max], closed interval */
570 
571 ALTAIRCAM_API(HRESULT)  Altaircam_get_MaxBitDepth(HAltaircam h); /* get the max bit depth of this camera, such as 8, 10, 12, 14, 16 */
572 
573 /* power supply of lighting:
574         0 -> 60HZ AC
575         1 -> 50Hz AC
576         2 -> DC
577 */
578 ALTAIRCAM_API(HRESULT)  Altaircam_put_HZ(HAltaircam h, int nHZ);
579 ALTAIRCAM_API(HRESULT)  Altaircam_get_HZ(HAltaircam h, int* nHZ);
580 
581 ALTAIRCAM_API(HRESULT)  Altaircam_put_Mode(HAltaircam h, int bSkip); /* skip or bin */
582 ALTAIRCAM_API(HRESULT)  Altaircam_get_Mode(HAltaircam h, int* bSkip); /* If the model don't support bin/skip mode, return E_NOTIMPL */
583 
584 ALTAIRCAM_API(HRESULT)  Altaircam_put_AWBAuxRect(HAltaircam h, const RECT* pAuxRect); /* auto white balance ROI */
585 ALTAIRCAM_API(HRESULT)  Altaircam_get_AWBAuxRect(HAltaircam h, RECT* pAuxRect);
586 ALTAIRCAM_API(HRESULT)  Altaircam_put_AEAuxRect(HAltaircam h, const RECT* pAuxRect);  /* auto exposure ROI */
587 ALTAIRCAM_API(HRESULT)  Altaircam_get_AEAuxRect(HAltaircam h, RECT* pAuxRect);
588 
589 ALTAIRCAM_API(HRESULT)  Altaircam_put_ABBAuxRect(HAltaircam h, const RECT* pAuxRect); /* auto black balance ROI */
590 ALTAIRCAM_API(HRESULT)  Altaircam_get_ABBAuxRect(HAltaircam h, RECT* pAuxRect);
591 
592 /*
593     S_FALSE:    color mode
594     S_OK:       mono mode, such as EXCCD00300KMA and UHCCD01400KMA
595 */
596 ALTAIRCAM_API(HRESULT)  Altaircam_get_MonoMode(HAltaircam h);
597 
598 ALTAIRCAM_API(HRESULT)  Altaircam_get_StillResolutionNumber(HAltaircam h);
599 ALTAIRCAM_API(HRESULT)  Altaircam_get_StillResolution(HAltaircam h, unsigned nResolutionIndex, int* pWidth, int* pHeight);
600 
601 /*  0: stop grab frame when frame buffer deque is full, until the frames in the queue are pulled away and the queue is not full
602     1: realtime
603           use minimum frame buffer. When new frame arrive, drop all the pending frame regardless of whether the frame buffer is full.
604           If DDR present, also limit the DDR frame buffer to only one frame.
605     2: soft realtime
606           Drop the oldest frame when the queue is full and then enqueue the new frame
607     default: 0
608 */
609 ALTAIRCAM_API(HRESULT)  Altaircam_put_RealTime(HAltaircam h, int val);
610 ALTAIRCAM_API(HRESULT)  Altaircam_get_RealTime(HAltaircam h, int* val);
611 
612 /* discard the current internal frame cache.
613     If DDR present, also discard the frames in the DDR.
614 */
615 ALTAIRCAM_API(HRESULT)  Altaircam_Flush(HAltaircam h);
616 
617 /* get the temperature of the sensor, in 0.1 degrees Celsius (32 means 3.2 degrees Celsius, -35 means -3.5 degree Celsius)
618     return E_NOTIMPL if not supported
619 */
620 ALTAIRCAM_API(HRESULT)  Altaircam_get_Temperature(HAltaircam h, short* pTemperature);
621 
622 /* set the target temperature of the sensor or TEC, in 0.1 degrees Celsius (32 means 3.2 degrees Celsius, -35 means -3.5 degree Celsius)
623     return E_NOTIMPL if not supported
624 */
625 ALTAIRCAM_API(HRESULT)  Altaircam_put_Temperature(HAltaircam h, short nTemperature);
626 
627 /*
628     get the revision
629 */
630 ALTAIRCAM_API(HRESULT)  Altaircam_get_Revision(HAltaircam h, unsigned short* pRevision);
631 
632 /*
633     get the serial number which is always 32 chars which is zero-terminated such as "TP110826145730ABCD1234FEDC56787"
634 */
635 ALTAIRCAM_API(HRESULT)  Altaircam_get_SerialNumber(HAltaircam h, char sn[32]);
636 
637 /*
638     get the camera firmware version, such as: 3.2.1.20140922
639 */
640 ALTAIRCAM_API(HRESULT)  Altaircam_get_FwVersion(HAltaircam h, char fwver[16]);
641 
642 /*
643     get the camera hardware version, such as: 3.12
644 */
645 ALTAIRCAM_API(HRESULT)  Altaircam_get_HwVersion(HAltaircam h, char hwver[16]);
646 
647 /*
648     get the production date, such as: 20150327, YYYYMMDD, (YYYY: year, MM: month, DD: day)
649 */
650 ALTAIRCAM_API(HRESULT)  Altaircam_get_ProductionDate(HAltaircam h, char pdate[10]);
651 
652 /*
653     get the FPGA version, such as: 1.13
654 */
655 ALTAIRCAM_API(HRESULT)  Altaircam_get_FpgaVersion(HAltaircam h, char fpgaver[16]);
656 
657 /*
658     get the sensor pixel size, such as: 2.4um
659 */
660 ALTAIRCAM_API(HRESULT)  Altaircam_get_PixelSize(HAltaircam h, unsigned nResolutionIndex, float* x, float* y);
661 
662 /* software level range */
663 ALTAIRCAM_API(HRESULT)  Altaircam_put_LevelRange(HAltaircam h, unsigned short aLow[4], unsigned short aHigh[4]);
664 ALTAIRCAM_API(HRESULT)  Altaircam_get_LevelRange(HAltaircam h, unsigned short aLow[4], unsigned short aHigh[4]);
665 
666 /* hardware level range mode */
667 #define ALTAIRCAM_LEVELRANGE_MANUAL       0x0000  /* manual */
668 #define ALTAIRCAM_LEVELRANGE_ONCE         0x0001  /* once */
669 #define ALTAIRCAM_LEVELRANGE_CONTINUE     0x0002  /* continue */
670 #define ALTAIRCAM_LEVELRANGE_ROI          0xffff  /* update roi rect only */
671 ALTAIRCAM_API(HRESULT)  Altaircam_put_LevelRangeV2(HAltaircam h, unsigned short mode, const RECT* pRoiRect, unsigned short aLow[4], unsigned short aHigh[4]);
672 ALTAIRCAM_API(HRESULT)  Altaircam_get_LevelRangeV2(HAltaircam h, unsigned short* pMode, RECT* pRoiRect, unsigned short aLow[4], unsigned short aHigh[4]);
673 
674 /*
675     The following functions must be called AFTER Altaircam_StartPushMode or Altaircam_StartPullModeWithWndMsg or Altaircam_StartPullModeWithCallback
676 */
677 ALTAIRCAM_API(HRESULT)  Altaircam_LevelRangeAuto(HAltaircam h);  /* software level range */
678 ALTAIRCAM_API(HRESULT)  Altaircam_GetHistogram(HAltaircam h, PIALTAIRCAM_HISTOGRAM_CALLBACK fnHistogramProc, void* pHistogramCtx);
679 
680 /* led state:
681     iLed: Led index, (0, 1, 2, ...)
682     iState: 1 -> Ever bright; 2 -> Flashing; other -> Off
683     iPeriod: Flashing Period (>= 500ms)
684 */
685 ALTAIRCAM_API(HRESULT)  Altaircam_put_LEDState(HAltaircam h, unsigned short iLed, unsigned short iState, unsigned short iPeriod);
686 
687 ALTAIRCAM_API(HRESULT)  Altaircam_write_EEPROM(HAltaircam h, unsigned addr, const unsigned char* pBuffer, unsigned nBufferLen);
688 ALTAIRCAM_API(HRESULT)  Altaircam_read_EEPROM(HAltaircam h, unsigned addr, unsigned char* pBuffer, unsigned nBufferLen);
689 
690 ALTAIRCAM_API(HRESULT)  Altaircam_read_Pipe(HAltaircam h, unsigned pipeNum, void* pBuffer, unsigned nBufferLen);
691 ALTAIRCAM_API(HRESULT)  Altaircam_write_Pipe(HAltaircam h, unsigned pipeNum, const void* pBuffer, unsigned nBufferLen);
692 ALTAIRCAM_API(HRESULT)  Altaircam_feed_Pipe(HAltaircam h, unsigned pipeNum);
693 
694 #define ALTAIRCAM_TEC_TARGET_MIN               (-300)     /* -30.0 degrees Celsius */
695 #define ALTAIRCAM_TEC_TARGET_DEF               0          /* 0.0 degrees Celsius */
696 #define ALTAIRCAM_TEC_TARGET_MAX               300        /* 30.0 degrees Celsius */
697 
698 #define ALTAIRCAM_OPTION_NOFRAME_TIMEOUT       0x01       /* no frame timeout: 1 = enable; 0 = disable. default: disable */
699 #define ALTAIRCAM_OPTION_THREAD_PRIORITY       0x02       /* set the priority of the internal thread which grab data from the usb device. iValue: 0 = THREAD_PRIORITY_NORMAL; 1 = THREAD_PRIORITY_ABOVE_NORMAL; 2 = THREAD_PRIORITY_HIGHEST; default: 0; see: msdn SetThreadPriority */
700 #define ALTAIRCAM_OPTION_PROCESSMODE           0x03       /* 0 = better image quality, more cpu usage. this is the default value
701                                                            1 = lower image quality, less cpu usage
702                                                         */
703 #define ALTAIRCAM_OPTION_RAW                   0x04       /* raw data mode, read the sensor "raw" data. This can be set only BEFORE Altaircam_StartXXX(). 0 = rgb, 1 = raw, default value: 0 */
704 #define ALTAIRCAM_OPTION_HISTOGRAM             0x05       /* 0 = only one, 1 = continue mode */
705 #define ALTAIRCAM_OPTION_BITDEPTH              0x06       /* 0 = 8 bits mode, 1 = 16 bits mode, subset of ALTAIRCAM_OPTION_PIXEL_FORMAT */
706 #define ALTAIRCAM_OPTION_FAN                   0x07       /* 0 = turn off the cooling fan, [1, max] = fan speed */
707 #define ALTAIRCAM_OPTION_TEC                   0x08       /* 0 = turn off the thermoelectric cooler, 1 = turn on the thermoelectric cooler */
708 #define ALTAIRCAM_OPTION_LINEAR                0x09       /* 0 = turn off the builtin linear tone mapping, 1 = turn on the builtin linear tone mapping, default value: 1 */
709 #define ALTAIRCAM_OPTION_CURVE                 0x0a       /* 0 = turn off the builtin curve tone mapping, 1 = turn on the builtin polynomial curve tone mapping, 2 = logarithmic curve tone mapping, default value: 2 */
710 #define ALTAIRCAM_OPTION_TRIGGER               0x0b       /* 0 = video mode, 1 = software or simulated trigger mode, 2 = external trigger mode, 3 = external + software trigger, default value = 0 */
711 #define ALTAIRCAM_OPTION_RGB                   0x0c       /* 0 => RGB24; 1 => enable RGB48 format when bitdepth > 8; 2 => RGB32; 3 => 8 Bits Gray (only for mono camera); 4 => 16 Bits Gray (only for mono camera when bitdepth > 8) */
712 #define ALTAIRCAM_OPTION_COLORMATIX            0x0d       /* enable or disable the builtin color matrix, default value: 1 */
713 #define ALTAIRCAM_OPTION_WBGAIN                0x0e       /* enable or disable the builtin white balance gain, default value: 1 */
714 #define ALTAIRCAM_OPTION_TECTARGET             0x0f       /* get or set the target temperature of the thermoelectric cooler, in 0.1 degree Celsius. For example, 125 means 12.5 degree Celsius, -35 means -3.5 degree Celsius */
715 #define ALTAIRCAM_OPTION_AUTOEXP_POLICY        0x10       /* auto exposure policy:
716                                                             0: Exposure Only
717                                                             1: Exposure Preferred
718                                                             2: Gain Only
719                                                             3: Gain Preferred
720                                                             default value: 1
721                                                         */
722 #define ALTAIRCAM_OPTION_FRAMERATE             0x11       /* limit the frame rate, range=[0, 63], the default value 0 means no limit */
723 #define ALTAIRCAM_OPTION_DEMOSAIC              0x12       /* demosaic method for both video and still image: BILINEAR = 0, VNG(Variable Number of Gradients interpolation) = 1, PPG(Patterned Pixel Grouping interpolation) = 2, AHD(Adaptive Homogeneity-Directed interpolation) = 3, see https://en.wikipedia.org/wiki/Demosaicing, default value: 0 */
724 #define ALTAIRCAM_OPTION_DEMOSAIC_VIDEO        0x13       /* demosaic method for video */
725 #define ALTAIRCAM_OPTION_DEMOSAIC_STILL        0x14       /* demosaic method for still image */
726 #define ALTAIRCAM_OPTION_BLACKLEVEL            0x15       /* black level */
727 #define ALTAIRCAM_OPTION_MULTITHREAD           0x16       /* multithread image processing */
728 #define ALTAIRCAM_OPTION_BINNING               0x17       /* binning, 0x01 (no binning), 0x02 (add, 2*2), 0x03 (add, 3*3), 0x04 (add, 4*4), 0x05 (add, 5*5), 0x06 (add, 6*6), 0x07 (add, 7*7), 0x08 (add, 8*8), 0x82 (average, 2*2), 0x83 (average, 3*3), 0x84 (average, 4*4), 0x85 (average, 5*5), 0x86 (average, 6*6), 0x87 (average, 7*7), 0x88 (average, 8*8). The final image size is rounded down to an even number, such as 640/3 to get 212 */
729 #define ALTAIRCAM_OPTION_ROTATE                0x18       /* rotate clockwise: 0, 90, 180, 270 */
730 #define ALTAIRCAM_OPTION_CG                    0x19       /* Conversion Gain: 0 = LCG, 1 = HCG, 2 = HDR */
731 #define ALTAIRCAM_OPTION_PIXEL_FORMAT          0x1a       /* pixel format, ALTAIRCAM_PIXELFORMAT_xxxx */
732 #define ALTAIRCAM_OPTION_FFC                   0x1b       /* flat field correction
733                                                             set:
734                                                                  0: disable
735                                                                  1: enable
736                                                                 -1: reset
737                                                                 (0xff000000 | n): set the average number to n, [1~255]
738                                                             get:
739                                                                  (val & 0xff): 0 -> disable, 1 -> enable, 2 -> inited
740                                                                  ((val & 0xff00) >> 8): sequence
741                                                                  ((val & 0xff0000) >> 8): average number
742                                                         */
743 #define ALTAIRCAM_OPTION_DDR_DEPTH             0x1c       /* the number of the frames that DDR can cache
744                                                                 1: DDR cache only one frame
745                                                                 0: Auto:
746                                                                         ->one for video mode when auto exposure is enabled
747                                                                         ->full capacity for others
748                                                                -1: DDR can cache frames to full capacity
749                                                         */
750 #define ALTAIRCAM_OPTION_DFC                   0x1d       /* dark field correction
751                                                             set:
752                                                                 0: disable
753                                                                 1: enable
754                                                                -1: reset
755                                                                 (0xff000000 | n): set the average number to n, [1~255]
756                                                             get:
757                                                                 (val & 0xff): 0 -> disable, 1 -> enable, 2 -> inited
758                                                                 ((val & 0xff00) >> 8): sequence
759                                                                 ((val & 0xff0000) >> 8): average number
760                                                         */
761 #define ALTAIRCAM_OPTION_SHARPENING            0x1e       /* Sharpening: (threshold << 24) | (radius << 16) | strength)
762                                                             strength: [0, 500], default: 0 (disable)
763                                                             radius: [1, 10]
764                                                             threshold: [0, 255]
765                                                         */
766 #define ALTAIRCAM_OPTION_FACTORY               0x1f       /* restore the factory settings */
767 #define ALTAIRCAM_OPTION_TEC_VOLTAGE           0x20       /* get the current TEC voltage in 0.1V, 59 mean 5.9V; readonly */
768 #define ALTAIRCAM_OPTION_TEC_VOLTAGE_MAX       0x21       /* get the TEC maximum voltage in 0.1V; readonly */
769 #define ALTAIRCAM_OPTION_DEVICE_RESET          0x22       /* reset usb device, simulate a replug */
770 #define ALTAIRCAM_OPTION_UPSIDE_DOWN           0x23       /* upsize down:
771                                                             1: yes
772                                                             0: no
773                                                             default: 1 (win), 0 (linux/macos)
774                                                         */
775 #define ALTAIRCAM_OPTION_AFPOSITION            0x24       /* auto focus sensor board positon */
776 #define ALTAIRCAM_OPTION_AFMODE                0x25       /* auto focus mode (0:manul focus; 1:auto focus; 2:once focus; 3:conjugate calibration) */
777 #define ALTAIRCAM_OPTION_AFZONE                0x26       /* auto focus zone */
778 #define ALTAIRCAM_OPTION_AFFEEDBACK            0x27       /* auto focus information feedback; 0:unknown; 1:focused; 2:focusing; 3:defocus; 4:up; 5:down */
779 #define ALTAIRCAM_OPTION_TESTPATTERN           0x28       /* test pattern:
780                                                            0: TestPattern Off
781                                                            3: monochrome diagonal stripes
782                                                            5: monochrome vertical stripes
783                                                            7: monochrome horizontal stripes
784                                                            9: chromatic diagonal stripes
785                                                         */
786 #define ALTAIRCAM_OPTION_AUTOEXP_THRESHOLD     0x29       /* threshold of auto exposure, default value: 5, range = [2, 15] */
787 #define ALTAIRCAM_OPTION_BYTEORDER             0x2a       /* Byte order, BGR or RGB: 0->RGB, 1->BGR, default value: 1(Win), 0(macOS, Linux, Android) */
788 #define ALTAIRCAM_OPTION_NOPACKET_TIMEOUT      0x2b       /* no packet timeout: 0 = disable, positive value = timeout milliseconds. default: disable */
789 #define ALTAIRCAM_OPTION_MAX_PRECISE_FRAMERATE 0x2c       /* precise frame rate maximum value in 0.1 fps, such as 115 means 11.5 fps */
790 #define ALTAIRCAM_OPTION_PRECISE_FRAMERATE     0x2d       /* precise frame rate current value in 0.1 fps */
791 #define ALTAIRCAM_OPTION_BANDWIDTH             0x2e       /* bandwidth, [1-100]% */
792 #define ALTAIRCAM_OPTION_RELOAD                0x2f       /* reload the last frame in trigger mode */
793 #define ALTAIRCAM_OPTION_CALLBACK_THREAD       0x30       /* dedicated thread for callback */
794 #define ALTAIRCAM_OPTION_FRAME_DEQUE_LENGTH    0x31       /* frame buffer deque length, range: [2, 1024], default: 3 */
795 #define ALTAIRCAM_OPTION_MIN_PRECISE_FRAMERATE 0x32       /* precise frame rate minimum value in 0.1 fps, such as 15 means 1.5 fps */
796 #define ALTAIRCAM_OPTION_SEQUENCER_ONOFF       0x33       /* sequencer trigger: on/off */
797 #define ALTAIRCAM_OPTION_SEQUENCER_NUMBER      0x34       /* sequencer trigger: number, range = [1, 255] */
798 #define ALTAIRCAM_OPTION_SEQUENCER_EXPOTIME    0x01000000 /* sequencer trigger: exposure time, iOption = ALTAIRCAM_OPTION_SEQUENCER_EXPOTIME | index, iValue = exposure time
799                                                              For example, to set the exposure time of the third group to 50ms, call:
800                                                                 Altaircam_put_Option(ALTAIRCAM_OPTION_SEQUENCER_EXPOTIME | 3, 50000)
801                                                         */
802 #define ALTAIRCAM_OPTION_SEQUENCER_EXPOGAIN    0x02000000 /* sequencer trigger: exposure gain, iOption = ALTAIRCAM_OPTION_SEQUENCER_EXPOGAIN | index, iValue = gain */
803 #define ALTAIRCAM_OPTION_DENOISE               0x35       /* denoise, strength range: [0, 100], 0 means disable */
804 #define ALTAIRCAM_OPTION_HEAT_MAX              0x36       /* maximum level: heat to prevent fogging up */
805 #define ALTAIRCAM_OPTION_HEAT                  0x37       /* heat to prevent fogging up */
806 #define ALTAIRCAM_OPTION_LOW_NOISE             0x38       /* low noise mode: 1 => enable */
807 #define ALTAIRCAM_OPTION_POWER                 0x39       /* get power consumption, unit: milliwatt */
808 #define ALTAIRCAM_OPTION_GLOBAL_RESET_MODE     0x3a       /* global reset mode */
809 #define ALTAIRCAM_OPTION_OPEN_USB_ERRORCODE    0x3b       /* open usb error code */
810 
811 /* pixel format */
812 #define ALTAIRCAM_PIXELFORMAT_RAW8             0x00
813 #define ALTAIRCAM_PIXELFORMAT_RAW10            0x01
814 #define ALTAIRCAM_PIXELFORMAT_RAW12            0x02
815 #define ALTAIRCAM_PIXELFORMAT_RAW14            0x03
816 #define ALTAIRCAM_PIXELFORMAT_RAW16            0x04
817 #define ALTAIRCAM_PIXELFORMAT_YUV411           0x05
818 #define ALTAIRCAM_PIXELFORMAT_VUYY             0x06
819 #define ALTAIRCAM_PIXELFORMAT_YUV444           0x07
820 #define ALTAIRCAM_PIXELFORMAT_RGB888           0x08
821 #define ALTAIRCAM_PIXELFORMAT_GMCY8            0x09   /* map to RGGB 8 bits */
822 #define ALTAIRCAM_PIXELFORMAT_GMCY12           0x0a   /* map to RGGB 12 bits */
823 #define ALTAIRCAM_PIXELFORMAT_UYVY             0x0b
824 
825 ALTAIRCAM_API(HRESULT)  Altaircam_put_Option(HAltaircam h, unsigned iOption, int iValue);
826 ALTAIRCAM_API(HRESULT)  Altaircam_get_Option(HAltaircam h, unsigned iOption, int* piValue);
827 
828 /*
829     xOffset, yOffset, xWidth, yHeight: must be even numbers
830 */
831 ALTAIRCAM_API(HRESULT)  Altaircam_put_Roi(HAltaircam h, unsigned xOffset, unsigned yOffset, unsigned xWidth, unsigned yHeight);
832 ALTAIRCAM_API(HRESULT)  Altaircam_get_Roi(HAltaircam h, unsigned* pxOffset, unsigned* pyOffset, unsigned* pxWidth, unsigned* pyHeight);
833 
834 /*  simulate replug:
835     return > 0, the number of device has been replug
836     return = 0, no device found
837     return E_ACCESSDENIED if without UAC Administrator privileges
838     for each device found, it will take about 3 seconds
839 */
840 #ifdef _WIN32
841 ALTAIRCAM_API(HRESULT) Altaircam_Replug(const wchar_t* id);
842 #else
843 ALTAIRCAM_API(HRESULT) Altaircam_Replug(const char* id);
844 #endif
845 
846 #ifndef __ALTAIRCAMAFPARAM_DEFINED__
847 #define __ALTAIRCAMAFPARAM_DEFINED__
848 typedef struct {
849     int imax;    /* maximum auto focus sensor board positon */
850     int imin;    /* minimum auto focus sensor board positon */
851     int idef;    /* conjugate calibration positon */
852     int imaxabs; /* maximum absolute auto focus sensor board positon, micrometer */
853     int iminabs; /* maximum absolute auto focus sensor board positon, micrometer */
854     int zoneh;   /* zone horizontal */
855     int zonev;   /* zone vertical */
856 }AltaircamAfParam;
857 #endif
858 
859 ALTAIRCAM_API(HRESULT)  Altaircam_get_AfParam(HAltaircam h, AltaircamAfParam* pAfParam);
860 
861 #define ALTAIRCAM_IOCONTROLTYPE_GET_SUPPORTEDMODE           0x01 /* 0x01->Input, 0x02->Output, (0x01 | 0x02)->support both Input and Output */
862 #define ALTAIRCAM_IOCONTROLTYPE_GET_GPIODIR                 0x03 /* 0x00->Input, 0x01->Output */
863 #define ALTAIRCAM_IOCONTROLTYPE_SET_GPIODIR                 0x04
864 #define ALTAIRCAM_IOCONTROLTYPE_GET_FORMAT                  0x05 /*
865                                                                    0x00-> not connected
866                                                                    0x01-> Tri-state: Tri-state mode (Not driven)
867                                                                    0x02-> TTL: TTL level signals
868                                                                    0x03-> LVDS: LVDS level signals
869                                                                    0x04-> RS422: RS422 level signals
870                                                                    0x05-> Opto-coupled
871                                                                */
872 #define ALTAIRCAM_IOCONTROLTYPE_SET_FORMAT                  0x06
873 #define ALTAIRCAM_IOCONTROLTYPE_GET_OUTPUTINVERTER          0x07 /* boolean, only support output signal */
874 #define ALTAIRCAM_IOCONTROLTYPE_SET_OUTPUTINVERTER          0x08
875 #define ALTAIRCAM_IOCONTROLTYPE_GET_INPUTACTIVATION         0x09 /* 0x00->Positive, 0x01->Negative */
876 #define ALTAIRCAM_IOCONTROLTYPE_SET_INPUTACTIVATION         0x0a
877 #define ALTAIRCAM_IOCONTROLTYPE_GET_DEBOUNCERTIME           0x0b /* debouncer time in microseconds, [0, 20000] */
878 #define ALTAIRCAM_IOCONTROLTYPE_SET_DEBOUNCERTIME           0x0c
879 #define ALTAIRCAM_IOCONTROLTYPE_GET_TRIGGERSOURCE           0x0d /*
880                                                                   0x00-> Opto-isolated input
881                                                                   0x01-> GPIO0
882                                                                   0x02-> GPIO1
883                                                                   0x03-> Counter
884                                                                   0x04-> PWM
885                                                                   0x05-> Software
886                                                                */
887 #define ALTAIRCAM_IOCONTROLTYPE_SET_TRIGGERSOURCE           0x0e
888 #define ALTAIRCAM_IOCONTROLTYPE_GET_TRIGGERDELAY            0x0f /* Trigger delay time in microseconds, [0, 5000000] */
889 #define ALTAIRCAM_IOCONTROLTYPE_SET_TRIGGERDELAY            0x10
890 #define ALTAIRCAM_IOCONTROLTYPE_GET_BURSTCOUNTER            0x11 /* Burst Counter: 1, 2, 3 ... 1023 */
891 #define ALTAIRCAM_IOCONTROLTYPE_SET_BURSTCOUNTER            0x12
892 #define ALTAIRCAM_IOCONTROLTYPE_GET_COUNTERSOURCE           0x13 /* 0x00-> Opto-isolated input, 0x01-> GPIO0, 0x02-> GPIO1 */
893 #define ALTAIRCAM_IOCONTROLTYPE_SET_COUNTERSOURCE           0x14
894 #define ALTAIRCAM_IOCONTROLTYPE_GET_COUNTERVALUE            0x15 /* Counter Value: 1, 2, 3 ... 1023 */
895 #define ALTAIRCAM_IOCONTROLTYPE_SET_COUNTERVALUE            0x16
896 #define ALTAIRCAM_IOCONTROLTYPE_SET_RESETCOUNTER            0x18
897 #define ALTAIRCAM_IOCONTROLTYPE_GET_PWM_FREQ                0x19
898 #define ALTAIRCAM_IOCONTROLTYPE_SET_PWM_FREQ                0x1a
899 #define ALTAIRCAM_IOCONTROLTYPE_GET_PWM_DUTYRATIO           0x1b
900 #define ALTAIRCAM_IOCONTROLTYPE_SET_PWM_DUTYRATIO           0x1c
901 #define ALTAIRCAM_IOCONTROLTYPE_GET_PWMSOURCE               0x1d /* 0x00-> Opto-isolated input, 0x01-> GPIO0, 0x02-> GPIO1 */
902 #define ALTAIRCAM_IOCONTROLTYPE_SET_PWMSOURCE               0x1e
903 #define ALTAIRCAM_IOCONTROLTYPE_GET_OUTPUTMODE              0x1f /*
904                                                                   0x00-> Frame Trigger Wait
905                                                                   0x01-> Exposure Active
906                                                                   0x02-> Strobe
907                                                                   0x03-> User output
908                                                                */
909 #define ALTAIRCAM_IOCONTROLTYPE_SET_OUTPUTMODE              0x20
910 #define ALTAIRCAM_IOCONTROLTYPE_GET_STROBEDELAYMODE         0x21 /* boolean, 0-> pre-delay, 1-> delay; compared to exposure active signal */
911 #define ALTAIRCAM_IOCONTROLTYPE_SET_STROBEDELAYMODE         0x22
912 #define ALTAIRCAM_IOCONTROLTYPE_GET_STROBEDELAYTIME         0x23 /* Strobe delay or pre-delay time in microseconds, [0, 5000000] */
913 #define ALTAIRCAM_IOCONTROLTYPE_SET_STROBEDELAYTIME         0x24
914 #define ALTAIRCAM_IOCONTROLTYPE_GET_STROBEDURATION          0x25 /* Strobe duration time in microseconds, [0, 5000000] */
915 #define ALTAIRCAM_IOCONTROLTYPE_SET_STROBEDURATION          0x26
916 #define ALTAIRCAM_IOCONTROLTYPE_GET_USERVALUE               0x27 /*
917                                                                   bit0-> Opto-isolated output
918                                                                   bit1-> GPIO0 output
919                                                                   bit2-> GPIO1 output
920                                                                */
921 #define ALTAIRCAM_IOCONTROLTYPE_SET_USERVALUE               0x28
922 #define ALTAIRCAM_IOCONTROLTYPE_GET_UART_ENABLE             0x29 /* enable: 1-> on; 0-> off */
923 #define ALTAIRCAM_IOCONTROLTYPE_SET_UART_ENABLE             0x2a
924 #define ALTAIRCAM_IOCONTROLTYPE_GET_UART_BAUDRATE           0x2b /* baud rate: 0-> 9600; 1-> 19200; 2-> 38400; 3-> 57600; 4-> 115200 */
925 #define ALTAIRCAM_IOCONTROLTYPE_SET_UART_BAUDRATE           0x2c
926 #define ALTAIRCAM_IOCONTROLTYPE_GET_UART_LINEMODE           0x2d /* line mode: 0-> TX(GPIO_0)/RX(GPIO_1); 1-> TX(GPIO_1)/RX(GPIO_0) */
927 #define ALTAIRCAM_IOCONTROLTYPE_SET_UART_LINEMODE           0x2e
928 
929 ALTAIRCAM_API(HRESULT)  Altaircam_IoControl(HAltaircam h, unsigned index, unsigned nType, int outVal, int* inVal);
930 
931 ALTAIRCAM_API(HRESULT)  Altaircam_write_UART(HAltaircam h, const unsigned char* pData, unsigned nDataLen);
932 ALTAIRCAM_API(HRESULT)  Altaircam_read_UART(HAltaircam h, unsigned char* pBuffer, unsigned nBufferLen);
933 
934 ALTAIRCAM_API(HRESULT)  Altaircam_put_Linear(HAltaircam h, const unsigned char* v8, const unsigned short* v16);
935 ALTAIRCAM_API(HRESULT)  Altaircam_put_Curve(HAltaircam h, const unsigned char* v8, const unsigned short* v16);
936 ALTAIRCAM_API(HRESULT)  Altaircam_put_ColorMatrix(HAltaircam h, const double v[9]);
937 ALTAIRCAM_API(HRESULT)  Altaircam_put_InitWBGain(HAltaircam h, const unsigned short v[3]);
938 
939 /*
940     get the frame rate: framerate (fps) = Frame * 1000.0 / nTime
941 */
942 ALTAIRCAM_API(HRESULT)  Altaircam_get_FrameRate(HAltaircam h, unsigned* nFrame, unsigned* nTime, unsigned* nTotalFrame);
943 
944 /* astronomy: for ST4 guide, please see: ASCOM Platform Help ICameraV2.
945     nDirect: 0 = North, 1 = South, 2 = East, 3 = West, 4 = Stop
946     nDuration: in milliseconds
947 */
948 ALTAIRCAM_API(HRESULT)  Altaircam_ST4PlusGuide(HAltaircam h, unsigned nDirect, unsigned nDuration);
949 
950 /* S_OK: ST4 pulse guiding
951    S_FALSE: ST4 not pulse guiding
952 */
953 ALTAIRCAM_API(HRESULT)  Altaircam_ST4PlusGuideState(HAltaircam h);
954 
955 /*
956     calculate the clarity factor:
957     pImageData: pointer to the image data
958     bits: 8(Grey), 24 (RGB24), 32(RGB32)
959     nImgWidth, nImgHeight: the image width and height
960 */
961 ALTAIRCAM_API(double)   Altaircam_calc_ClarityFactor(const void* pImageData, int bits, unsigned nImgWidth, unsigned nImgHeight);
962 
963 /*
964     nBitCount: output bitmap bit count
965     when nBitDepth == 8:
966         nBitCount must be 24 or 32
967     when nBitDepth > 8
968         nBitCount:  24 -> RGB24
969                     32 -> RGB32
970                     48 -> RGB48
971                     64 -> RGB64
972 */
973 ALTAIRCAM_API(void)     Altaircam_deBayerV2(unsigned nBayer, int nW, int nH, const void* input, void* output, unsigned char nBitDepth, unsigned char nBitCount);
974 
975 /*
976     obsolete, please use Altaircam_deBayerV2
977 */
978 ALTAIRCAM_DEPRECATED
979 ALTAIRCAM_API(void)     Altaircam_deBayer(unsigned nBayer, int nW, int nH, const void* input, void* output, unsigned char nBitDepth);
980 
981 typedef void (__stdcall* PALTAIRCAM_DEMOSAIC_CALLBACK)(unsigned nBayer, int nW, int nH, const void* input, void* output, unsigned char nBitDepth, void* pCallbackCtx);
982 ALTAIRCAM_API(HRESULT)  Altaircam_put_Demosaic(HAltaircam h, PALTAIRCAM_DEMOSAIC_CALLBACK pCallback, void* pCallbackCtx);
983 
984 /*
985     obsolete, please use AltaircamModelV2
986 */
987 typedef struct {
988 #ifdef _WIN32
989     const wchar_t*      name;       /* model name, in Windows, we use unicode */
990 #else
991     const char*         name;       /* model name */
992 #endif
993     unsigned            flag;       /* ALTAIRCAM_FLAG_xxx */
994     unsigned            maxspeed;   /* number of speed level, same as Altaircam_get_MaxSpeed(), the speed range = [0, maxspeed], closed interval */
995     unsigned            preview;    /* number of preview resolution, same as Altaircam_get_ResolutionNumber() */
996     unsigned            still;      /* number of still resolution, same as Altaircam_get_StillResolutionNumber() */
997     AltaircamResolution   res[ALTAIRCAM_MAX];
998 }AltaircamModel; /* camera model */
999 
1000 /*
1001     obsolete, please use AltaircamDeviceV2
1002 */
1003 typedef struct {
1004 #ifdef _WIN32
1005     wchar_t             displayname[64];    /* display name */
1006     wchar_t             id[64];             /* unique and opaque id of a connected camera, for Altaircam_Open */
1007 #else
1008     char                displayname[64];    /* display name */
1009     char                id[64];             /* unique and opaque id of a connected camera, for Altaircam_Open */
1010 #endif
1011     const AltaircamModel* model;
1012 }AltaircamDevice; /* camera instance for enumerating */
1013 
1014 /*
1015     obsolete, please use Altaircam_EnumV2
1016 */
1017 ALTAIRCAM_DEPRECATED
1018 ALTAIRCAM_API(unsigned) Altaircam_Enum(AltaircamDevice pti[ALTAIRCAM_MAX]);
1019 
1020 typedef PALTAIRCAM_DATA_CALLBACK_V3 PALTAIRCAM_DATA_CALLBACK_V2;
1021 ALTAIRCAM_DEPRECATED
1022 ALTAIRCAM_API(HRESULT)  Altaircam_StartPushModeV2(HAltaircam h, PALTAIRCAM_DATA_CALLBACK_V2 pDataCallback, void* pCallbackCtx);
1023 
1024 typedef void (__stdcall* PALTAIRCAM_DATA_CALLBACK)(const void* pData, const BITMAPINFOHEADER* pHeader, int bSnap, void* pCallbackCtx);
1025 ALTAIRCAM_DEPRECATED
1026 ALTAIRCAM_API(HRESULT)  Altaircam_StartPushMode(HAltaircam h, PALTAIRCAM_DATA_CALLBACK pDataCallback, void* pCallbackCtx);
1027 
1028 ALTAIRCAM_DEPRECATED
1029 ALTAIRCAM_API(HRESULT)  Altaircam_put_ExpoCallback(HAltaircam h, PIALTAIRCAM_EXPOSURE_CALLBACK fnExpoProc, void* pExpoCtx);
1030 ALTAIRCAM_DEPRECATED
1031 ALTAIRCAM_API(HRESULT)  Altaircam_put_ChromeCallback(HAltaircam h, PIALTAIRCAM_CHROME_CALLBACK fnChromeProc, void* pChromeCtx);
1032 
1033 /* Altaircam_FfcOnePush is obsolete, it's a synonyms for Altaircam_FfcOnce. */
1034 ALTAIRCAM_DEPRECATED
1035 ALTAIRCAM_API(HRESULT)  Altaircam_FfcOnePush(HAltaircam h);
1036 
1037 /* Altaircam_DfcOnePush is obsolete, it's a synonyms for Altaircam_DfcOnce. */
1038 ALTAIRCAM_DEPRECATED
1039 ALTAIRCAM_API(HRESULT)  Altaircam_DfcOnePush(HAltaircam h);
1040 
1041 /* Altaircam_AwbOnePush is obsolete, it's a synonyms for Altaircam_AwbOnce. */
1042 ALTAIRCAM_DEPRECATED
1043 ALTAIRCAM_API(HRESULT)  Altaircam_AwbOnePush(HAltaircam h, PIALTAIRCAM_TEMPTINT_CALLBACK fnTTProc, void* pTTCtx);
1044 
1045 /* Altaircam_AbbOnePush is obsolete, it's a synonyms for Altaircam_AbbOnce. */
1046 ALTAIRCAM_DEPRECATED
1047 ALTAIRCAM_API(HRESULT)  Altaircam_AbbOnePush(HAltaircam h, PIALTAIRCAM_BLACKBALANCE_CALLBACK fnBBProc, void* pBBCtx);
1048 
1049 #ifndef _WIN32
1050 
1051 /*
1052 This function is only available on macOS and Linux, it's unnecessary on Windows.
1053   (1) To process the device plug in / pull out in Windows, please refer to the MSDN
1054        (a) Device Management, http://msdn.microsoft.com/en-us/library/windows/desktop/aa363224(v=vs.85).aspx
1055        (b) Detecting Media Insertion or Removal, http://msdn.microsoft.com/en-us/library/windows/desktop/aa363215(v=vs.85).aspx
1056   (2) To process the device plug in / pull out in Linux / macOS, please call this function to register the callback function.
1057       When the device is inserted or pulled out, you will be notified by the callback funcion, and then call Altaircam_EnumV2(...) again to enum the cameras.
1058 Recommendation: for better rubustness, when notify of device insertion arrives, don't open handle of this device immediately, but open it after delaying a short time (e.g., 200 milliseconds).
1059 */
1060 typedef void (*PALTAIRCAM_HOTPLUG)(void* pCallbackCtx);
1061 ALTAIRCAM_API(void)   Altaircam_HotPlug(PALTAIRCAM_HOTPLUG pHotPlugCallback, void* pCallbackCtx);
1062 
1063 #else
1064 
1065 /* Altaircam_Start is obsolete, it's a synonyms for Altaircam_StartPushMode. */
1066 ALTAIRCAM_DEPRECATED
1067 ALTAIRCAM_API(HRESULT)  Altaircam_Start(HAltaircam h, PALTAIRCAM_DATA_CALLBACK pDataCallback, void* pCallbackCtx);
1068 
1069 /* Altaircam_put_TempTintInit is obsolete, it's a synonyms for Altaircam_AwbOnce. */
1070 ALTAIRCAM_DEPRECATED
1071 ALTAIRCAM_API(HRESULT)  Altaircam_put_TempTintInit(HAltaircam h, PIALTAIRCAM_TEMPTINT_CALLBACK fnTTProc, void* pTTCtx);
1072 
1073 /*
1074     obsolete, please use Altaircam_put_Option or Altaircam_get_Option to set or get the process mode: ALTAIRCAM_PROCESSMODE_FULL or ALTAIRCAM_PROCESSMODE_FAST.
1075     default is ALTAIRCAM_PROCESSMODE_FULL.
1076 */
1077 #ifndef __ALTAIRCAM_PROCESSMODE_DEFINED__
1078 #define __ALTAIRCAM_PROCESSMODE_DEFINED__
1079 #define ALTAIRCAM_PROCESSMODE_FULL        0x00    /* better image quality, more cpu usage. this is the default value */
1080 #define ALTAIRCAM_PROCESSMODE_FAST        0x01    /* lower image quality, less cpu usage */
1081 #endif
1082 
1083 ALTAIRCAM_DEPRECATED
1084 ALTAIRCAM_API(HRESULT)  Altaircam_put_ProcessMode(HAltaircam h, unsigned nProcessMode);
1085 ALTAIRCAM_DEPRECATED
1086 ALTAIRCAM_API(HRESULT)  Altaircam_get_ProcessMode(HAltaircam h, unsigned* pnProcessMode);
1087 
1088 #endif
1089 
1090 /* obsolete, please use Altaircam_put_Roi and Altaircam_get_Roi */
1091 ALTAIRCAM_DEPRECATED
1092 ALTAIRCAM_API(HRESULT)  Altaircam_put_RoiMode(HAltaircam h, int bRoiMode, int xOffset, int yOffset);
1093 ALTAIRCAM_DEPRECATED
1094 ALTAIRCAM_API(HRESULT)  Altaircam_get_RoiMode(HAltaircam h, int* pbRoiMode, int* pxOffset, int* pyOffset);
1095 
1096 /* obsolete:
1097      ------------------------------------------------------------|
1098      | Parameter         |   Range       |   Default             |
1099      |-----------------------------------------------------------|
1100      | VidgetAmount      |   -100~100    |   0                   |
1101      | VignetMidPoint    |   0~100       |   50                  |
1102      -------------------------------------------------------------
1103 */
1104 ALTAIRCAM_API(HRESULT)  Altaircam_put_VignetEnable(HAltaircam h, int bEnable);
1105 ALTAIRCAM_API(HRESULT)  Altaircam_get_VignetEnable(HAltaircam h, int* bEnable);
1106 ALTAIRCAM_API(HRESULT)  Altaircam_put_VignetAmountInt(HAltaircam h, int nAmount);
1107 ALTAIRCAM_API(HRESULT)  Altaircam_get_VignetAmountInt(HAltaircam h, int* nAmount);
1108 ALTAIRCAM_API(HRESULT)  Altaircam_put_VignetMidPointInt(HAltaircam h, int nMidPoint);
1109 ALTAIRCAM_API(HRESULT)  Altaircam_get_VignetMidPointInt(HAltaircam h, int* nMidPoint);
1110 
1111 /* obsolete flags */
1112 #define ALTAIRCAM_FLAG_BITDEPTH10    ALTAIRCAM_FLAG_RAW10  /* pixel format, RAW 10bits */
1113 #define ALTAIRCAM_FLAG_BITDEPTH12    ALTAIRCAM_FLAG_RAW12  /* pixel format, RAW 12bits */
1114 #define ALTAIRCAM_FLAG_BITDEPTH14    ALTAIRCAM_FLAG_RAW14  /* pixel format, RAW 14bits */
1115 #define ALTAIRCAM_FLAG_BITDEPTH16    ALTAIRCAM_FLAG_RAW16  /* pixel format, RAW 16bits */
1116 
1117 #ifdef _WIN32
1118 ALTAIRCAM_API(HRESULT)  Altaircam_put_Name(const wchar_t* id, const char* name);
1119 ALTAIRCAM_API(HRESULT)  Altaircam_get_Name(const wchar_t* id, char name[64]);
1120 #else
1121 ALTAIRCAM_API(HRESULT)  Altaircam_put_Name(const char* id, const char* name);
1122 ALTAIRCAM_API(HRESULT)  Altaircam_get_Name(const char* id, char name[64]);
1123 #endif
1124 ALTAIRCAM_API(unsigned) Altaircam_EnumWithName(AltaircamDeviceV2 pti[ALTAIRCAM_MAX]);
1125 
1126 #ifdef _WIN32
1127 #pragma pack(pop)
1128 #endif
1129 
1130 #ifdef __cplusplus
1131 }
1132 #endif
1133 
1134 #endif
1135