1 #ifndef __toupcam_h__ 2 #define __toupcam_h__ 3 4 /* Version: 11.8190.20161201 */ 5 6 #ifdef _WIN32 7 #ifndef _INC_WINDOWS 8 #include <windows.h> 9 #endif 10 #endif 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 #ifdef _WIN32 /* Windows */ 17 18 #pragma pack(push, 8) 19 #ifdef TOUPCAM_EXPORTS 20 #define toupcam_ports(x) __declspec(dllexport) x __stdcall 21 #elif !defined(TOUPCAM_NOIMPORTS) 22 #define toupcam_ports(x) __declspec(dllimport) x __stdcall 23 #else 24 #define toupcam_ports(x) x __stdcall 25 #endif 26 27 #else /* Linux or macOS */ 28 29 #define toupcam_ports(x) x 30 31 #ifndef HRESULT 32 #define HRESULT int 33 #endif 34 35 #ifndef __stdcall 36 #define __stdcall 37 #endif 38 39 #ifndef BOOL 40 #define BOOL int 41 #endif 42 43 #ifndef __BITMAPINFOHEADER_DEFINED__ 44 #define __BITMAPINFOHEADER_DEFINED__ 45 typedef struct { 46 unsigned biSize; 47 int biWidth; 48 int biHeight; 49 unsigned short biPlanes; 50 unsigned short biBitCount; 51 unsigned biCompression; 52 unsigned biSizeImage; 53 int biXPelsPerMeter; 54 int biYPelsPerMeter; 55 unsigned biClrUsed; 56 unsigned biClrImportant; 57 } BITMAPINFOHEADER; 58 #endif 59 60 #ifndef __RECT_DEFINED__ 61 #define __RECT_DEFINED__ 62 typedef struct { 63 int left; 64 int top; 65 int right; 66 int bottom; 67 } RECT, *PRECT; 68 #endif 69 70 #endif 71 72 #ifndef TDIBWIDTHBYTES 73 #define TDIBWIDTHBYTES(bits) ((unsigned)(((bits) + 31) & (~31)) / 8) 74 #endif 75 76 /*******************************************************************************/ 77 /* HRESULT */ 78 /* |---------------|---------------------------------------|------------| */ 79 /* | S_OK | Operation successful | 0x00000000 | */ 80 /* | S_FALSE | Operation successful | 0x00000001 | */ 81 /* | E_FAIL | Unspecified failure | 0x80004005 | */ 82 /* | E_INVALIDARG | One or more arguments are not valid | 0x80070057 | */ 83 /* | E_NOTIMPL | Not supported or not implemented | 0x80004001 | */ 84 /* | E_POINTER | Pointer that is not valid | 0x80004003 | */ 85 /* | E_UNEXPECTED | Unexpected failure | 0x8000FFFF | */ 86 /* |---------------|---------------------------------------|------------| */ 87 /*******************************************************************************/ 88 89 /* handle */ 90 typedef struct ToupcamT { int unused; } *HToupCam; 91 92 #define TOUPCAM_MAX 16 93 94 #define TOUPCAM_FLAG_CMOS 0x00000001 /* cmos sensor */ 95 #define TOUPCAM_FLAG_CCD_PROGRESSIVE 0x00000002 /* progressive ccd sensor */ 96 #define TOUPCAM_FLAG_CCD_INTERLACED 0x00000004 /* interlaced ccd sensor */ 97 #define TOUPCAM_FLAG_ROI_HARDWARE 0x00000008 /* support hardware ROI */ 98 #define TOUPCAM_FLAG_MONO 0x00000010 /* monochromatic */ 99 #define TOUPCAM_FLAG_BINSKIP_SUPPORTED 0x00000020 /* support bin/skip mode, see Toupcam_put_Mode and Toupcam_get_Mode */ 100 #define TOUPCAM_FLAG_USB30 0x00000040 /* USB 3.0 */ 101 #define TOUPCAM_FLAG_TEC 0x00000080 /* Thermoelectric Cooler */ 102 #define TOUPCAM_FLAG_USB30_OVER_USB20 0x00000100 /* usb3.0 camera connected to usb2.0 port */ 103 #define TOUPCAM_FLAG_ST4 0x00000200 /* ST4 */ 104 #define TOUPCAM_FLAG_GETTEMPERATURE 0x00000400 /* support to get the temperature of sensor */ 105 #define TOUPCAM_FLAG_PUTTEMPERATURE 0x00000800 /* support to put the temperature of sensor */ 106 #define TOUPCAM_FLAG_BITDEPTH10 0x00001000 /* Maximum Bit Depth = 10 */ 107 #define TOUPCAM_FLAG_BITDEPTH12 0x00002000 /* Maximum Bit Depth = 12 */ 108 #define TOUPCAM_FLAG_BITDEPTH14 0x00004000 /* Maximum Bit Depth = 14 */ 109 #define TOUPCAM_FLAG_BITDEPTH16 0x00008000 /* Maximum Bit Depth = 16 */ 110 #define TOUPCAM_FLAG_FAN 0x00010000 /* cooling fan */ 111 #define TOUPCAM_FLAG_TEC_ONOFF 0x00020000 /* Thermoelectric Cooler can be turn on or off */ 112 #define TOUPCAM_FLAG_ISP 0x00040000 /* Image Signal Processing supported */ 113 #define TOUPCAM_FLAG_TRIGGER_SOFTWARE 0x00080000 /* support software trigger */ 114 #define TOUPCAM_FLAG_TRIGGER_EXTERNAL 0x00100000 /* support external trigger */ 115 #define TOUPCAM_FLAG_TRIGGER_SINGLE 0x00200000 /* only support trigger single: one trigger, one image */ 116 #define TOUPCAM_FLAG_BLACKLEVEL 0x00400000 /* support set and get the black level */ 117 118 #define TOUPCAM_TEMP_DEF 6503 119 #define TOUPCAM_TEMP_MIN 2000 120 #define TOUPCAM_TEMP_MAX 15000 121 #define TOUPCAM_TINT_DEF 1000 122 #define TOUPCAM_TINT_MIN 200 123 #define TOUPCAM_TINT_MAX 2500 124 #define TOUPCAM_HUE_DEF 0 125 #define TOUPCAM_HUE_MIN (-180) 126 #define TOUPCAM_HUE_MAX 180 127 #define TOUPCAM_SATURATION_DEF 128 128 #define TOUPCAM_SATURATION_MIN 0 129 #define TOUPCAM_SATURATION_MAX 255 130 #define TOUPCAM_BRIGHTNESS_DEF 0 131 #define TOUPCAM_BRIGHTNESS_MIN (-64) 132 #define TOUPCAM_BRIGHTNESS_MAX 64 133 #define TOUPCAM_CONTRAST_DEF 0 134 #define TOUPCAM_CONTRAST_MIN (-100) 135 #define TOUPCAM_CONTRAST_MAX 100 136 #define TOUPCAM_GAMMA_DEF 100 137 #define TOUPCAM_GAMMA_MIN 20 138 #define TOUPCAM_GAMMA_MAX 180 139 #define TOUPCAM_AETARGET_DEF 120 140 #define TOUPCAM_AETARGET_MIN 16 141 #define TOUPCAM_AETARGET_MAX 220 142 #define TOUPCAM_WBGAIN_DEF 0 143 #define TOUPCAM_WBGAIN_MIN (-127) 144 #define TOUPCAM_WBGAIN_MAX 127 145 #define TOUPCAM_BLACKLEVEL_MIN 0 146 #define TOUPCAM_BLACKLEVEL8_MAX 31 /* maximum black level for bit depth = 8 */ 147 #define TOUPCAM_BLACKLEVEL10_MAX (31 * 4) /* maximum black level for bit depth = 10 */ 148 #define TOUPCAM_BLACKLEVEL12_MAX (31 * 16) /* maximum black level for bit depth = 12 */ 149 #define TOUPCAM_BLACKLEVEL14_MAX (31 * 64) /* maximum black level for bit depth = 14 */ 150 #define TOUPCAM_BLACKLEVEL16_MAX (31 * 256) /* maximum black level for bit depth = 16 */ 151 152 typedef struct{ 153 unsigned width; 154 unsigned height; 155 }ToupcamResolution; 156 157 /* In Windows platform, we always use UNICODE wchar_t */ 158 /* In Linux or macOS, we use char */ 159 typedef struct{ 160 #ifdef _WIN32 161 const wchar_t* name; /* model name, in Windows, we use unicode */ 162 #else 163 const char* name; /* model name */ 164 #endif 165 unsigned flag; /* TOUPCAM_FLAG_xxx */ 166 unsigned maxspeed; /* number of speed level, same as Toupcam_get_MaxSpeed(), the speed range = [0, maxspeed], closed interval */ 167 unsigned preview; /* number of preview resolution, same as Toupcam_get_ResolutionNumber() */ 168 unsigned still; /* number of still resolution, same as Toupcam_get_StillResolutionNumber() */ 169 ToupcamResolution res[TOUPCAM_MAX]; 170 }ToupcamModel; 171 172 typedef struct{ 173 #ifdef _WIN32 174 wchar_t displayname[64]; /* display name */ 175 wchar_t id[64]; /* unique and opaque id of a connected camera, for Toupcam_Open */ 176 #else 177 char displayname[64]; /* display name */ 178 char id[64]; /* unique and opaque id of a connected camera, for Toupcam_Open */ 179 #endif 180 const ToupcamModel* model; 181 }ToupcamInst; 182 183 /* 184 get the version of this dll, which is: 11.8190.20161201 185 */ 186 #ifdef _WIN32 187 toupcam_ports(const wchar_t*) Toupcam_Version(); 188 #else 189 toupcam_ports(const char*) Toupcam_Version(); 190 #endif 191 192 /* 193 enumerate the cameras connected to the computer, return the number of enumerated. 194 195 ToupcamInst arr[TOUPCAM_MAX]; 196 unsigned cnt = Toupcam_Enum(arr); 197 for (unsigned i = 0; i < cnt; ++i) 198 ... 199 200 if pti == NULL, then, only the number is returned. 201 */ 202 toupcam_ports(unsigned) Toupcam_Enum(ToupcamInst pti[TOUPCAM_MAX]); 203 204 /* use the id of ToupcamInst, which is enumerated by Toupcam_Enum. 205 if id is NULL, Toupcam_Open will open the first camera. 206 */ 207 #ifdef _WIN32 208 toupcam_ports(HToupCam) Toupcam_Open(const wchar_t* id); 209 #else 210 toupcam_ports(HToupCam) Toupcam_Open(const char* id); 211 #endif 212 213 /* 214 the same with Toupcam_Open, but use the index as the parameter. such as: 215 index == 0, open the first camera, 216 index == 1, open the second camera, 217 etc 218 */ 219 toupcam_ports(HToupCam) Toupcam_OpenByIndex(unsigned index); 220 221 toupcam_ports(void) Toupcam_Close(HToupCam h); /* close the handle */ 222 223 #define TOUPCAM_EVENT_EXPOSURE 0x0001 /* exposure time changed */ 224 #define TOUPCAM_EVENT_TEMPTINT 0x0002 /* white balance changed, Temp/Tint mode */ 225 #define TOUPCAM_EVENT_CHROME 0x0003 /* reversed, do not use it */ 226 #define TOUPCAM_EVENT_IMAGE 0x0004 /* live image arrived, use Toupcam_PullImage to get this image */ 227 #define TOUPCAM_EVENT_STILLIMAGE 0x0005 /* snap (still) frame arrived, use Toupcam_PullStillImage to get this frame */ 228 #define TOUPCAM_EVENT_WBGAIN 0x0006 /* white balance changed, RGB Gain mode */ 229 #define TOUPCAM_EVENT_ERROR 0x0080 /* generic error */ 230 #define TOUPCAM_EVENT_DISCONNECTED 0x0081 /* camera disconnected */ 231 #define TOUPCAM_EVENT_TIMEOUT 0x0082 /* timeout error */ 232 233 #ifdef _WIN32 234 toupcam_ports(HRESULT) Toupcam_StartPullModeWithWndMsg(HToupCam h, HWND hWnd, UINT nMsg); 235 #endif 236 237 typedef void (__stdcall* PTOUPCAM_EVENT_CALLBACK)(unsigned nEvent, void* pCallbackCtx); 238 toupcam_ports(HRESULT) Toupcam_StartPullModeWithCallback(HToupCam h, PTOUPCAM_EVENT_CALLBACK pEventCallback, void* pCallbackContext); 239 240 /* 241 bits: 24 (RGB24), 32 (RGB32), or 8 (Grey). Int RAW mode, this parameter is ignored. 242 pnWidth, pnHeight: OUT parameter 243 */ 244 toupcam_ports(HRESULT) Toupcam_PullImage(HToupCam h, void* pImageData, int bits, unsigned* pnWidth, unsigned* pnHeight); 245 toupcam_ports(HRESULT) Toupcam_PullStillImage(HToupCam h, void* pImageData, int bits, unsigned* pnWidth, unsigned* pnHeight); 246 247 /* 248 (NULL == pData) means that something is error 249 pCallbackCtx is the callback context which is passed by Toupcam_Start 250 bSnap: TRUE if Toupcam_Snap 251 252 pDataCallback is callbacked by an internal thread of toupcam.dll, so please pay attention to multithread problem 253 */ 254 typedef void (__stdcall* PTOUPCAM_DATA_CALLBACK)(const void* pData, const BITMAPINFOHEADER* pHeader, BOOL bSnap, void* pCallbackCtx); 255 toupcam_ports(HRESULT) Toupcam_StartPushMode(HToupCam h, PTOUPCAM_DATA_CALLBACK pDataCallback, void* pCallbackCtx); 256 257 toupcam_ports(HRESULT) Toupcam_Stop(HToupCam h); 258 toupcam_ports(HRESULT) Toupcam_Pause(HToupCam h, BOOL bPause); 259 260 /* for pull mode: TOUPCAM_EVENT_STILLIMAGE, and then Toupcam_PullStillImage 261 for push mode: the snapped image will be return by PTOUPCAM_DATA_CALLBACK, with the parameter 'bSnap' set to 'TRUE' */ 262 toupcam_ports(HRESULT) Toupcam_Snap(HToupCam h, unsigned nResolutionIndex); /* still image snap */ 263 264 /* 265 soft trigger: 266 nNumber: 0xffff: trigger continuously 267 0: cancel trigger 268 others: number of images to be triggered 269 */ 270 toupcam_ports(HRESULT) Toupcam_Trigger(HToupCam h, unsigned short nNumber); 271 /* 272 put_Size, put_eSize, can be used to set the video output resolution BEFORE ToupCam_Start. 273 put_Size use width and height parameters, put_eSize use the index parameter. 274 for example, UCMOS03100KPA support the following resolutions: 275 index 0: 2048, 1536 276 index 1: 1024, 768 277 index 2: 680, 510 278 so, we can use put_Size(h, 1024, 768) or put_eSize(h, 1). Both have the same effect. 279 */ 280 toupcam_ports(HRESULT) Toupcam_put_Size(HToupCam h, int nWidth, int nHeight); 281 toupcam_ports(HRESULT) Toupcam_get_Size(HToupCam h, int* pWidth, int* pHeight); 282 toupcam_ports(HRESULT) Toupcam_put_eSize(HToupCam h, unsigned nResolutionIndex); 283 toupcam_ports(HRESULT) Toupcam_get_eSize(HToupCam h, unsigned* pnResolutionIndex); 284 285 toupcam_ports(HRESULT) Toupcam_get_ResolutionNumber(HToupCam h); 286 toupcam_ports(HRESULT) Toupcam_get_Resolution(HToupCam h, unsigned nResolutionIndex, int* pWidth, int* pHeight); 287 toupcam_ports(HRESULT) Toupcam_get_ResolutionRatio(HToupCam h, unsigned nResolutionIndex, int* pNumerator, int* pDenominator); 288 toupcam_ports(HRESULT) Toupcam_get_Field(HToupCam h); 289 290 /* 291 FourCC: 292 MAKEFOURCC('G', 'B', 'R', 'G') 293 MAKEFOURCC('R', 'G', 'G', 'B') 294 MAKEFOURCC('B', 'G', 'G', 'R') 295 MAKEFOURCC('G', 'R', 'B', 'G') 296 MAKEFOURCC('Y', 'U', 'Y', 'V') 297 MAKEFOURCC('Y', 'Y', 'Y', 'Y') 298 */ 299 toupcam_ports(HRESULT) Toupcam_get_RawFormat(HToupCam h, unsigned* nFourCC, unsigned* bitdepth); 300 301 /* 302 ------------------------------------------------------------------| 303 | Parameter | Range | Default | 304 |-----------------------------------------------------------------| 305 | Auto Exposure Target | 10~230 | 120 | 306 | Temp | 2000~15000 | 6503 | 307 | Tint | 200~2500 | 1000 | 308 | LevelRange | 0~255 | Low = 0, High = 255 | 309 | Contrast | -100~100 | 0 | 310 | Hue | -180~180 | 0 | 311 | Saturation | 0~255 | 128 | 312 | Brightness | -64~64 | 0 | 313 | Gamma | 20~180 | 100 | 314 | WBGain | -127~127 | 0 | 315 ------------------------------------------------------------------| 316 */ 317 318 #ifndef __TOUPCAM_CALLBACK_DEFINED__ 319 #define __TOUPCAM_CALLBACK_DEFINED__ 320 typedef void (__stdcall* PITOUPCAM_EXPOSURE_CALLBACK)(void* pCtx); 321 typedef void (__stdcall* PITOUPCAM_WHITEBALANCE_CALLBACK)(const int aGain[3], void* pCtx); 322 typedef void (__stdcall* PITOUPCAM_TEMPTINT_CALLBACK)(const int nTemp, const int nTint, void* pCtx); 323 typedef void (__stdcall* PITOUPCAM_HISTOGRAM_CALLBACK)(const float aHistY[256], const float aHistR[256], const float aHistG[256], const float aHistB[256], void* pCtx); 324 typedef void (__stdcall* PITOUPCAM_CHROME_CALLBACK)(void* pCtx); 325 #endif 326 327 toupcam_ports(HRESULT) Toupcam_get_AutoExpoEnable(HToupCam h, BOOL* bAutoExposure); 328 toupcam_ports(HRESULT) Toupcam_put_AutoExpoEnable(HToupCam h, BOOL bAutoExposure); 329 toupcam_ports(HRESULT) Toupcam_get_AutoExpoTarget(HToupCam h, unsigned short* Target); 330 toupcam_ports(HRESULT) Toupcam_put_AutoExpoTarget(HToupCam h, unsigned short Target); 331 332 /*set the maximum auto exposure time and analog agin. The default maximum auto exposure time is 350ms */ 333 toupcam_ports(HRESULT) Toupcam_put_MaxAutoExpoTimeAGain(HToupCam h, unsigned maxTime, unsigned short maxAGain); 334 335 toupcam_ports(HRESULT) Toupcam_get_ExpoTime(HToupCam h, unsigned* Time); /* in microseconds */ 336 toupcam_ports(HRESULT) Toupcam_put_ExpoTime(HToupCam h, unsigned Time); /* in microseconds */ 337 toupcam_ports(HRESULT) Toupcam_get_ExpTimeRange(HToupCam h, unsigned* nMin, unsigned* nMax, unsigned* nDef); 338 339 toupcam_ports(HRESULT) Toupcam_get_ExpoAGain(HToupCam h, unsigned short* AGain); /* percent, such as 300 */ 340 toupcam_ports(HRESULT) Toupcam_put_ExpoAGain(HToupCam h, unsigned short AGain); /* percent */ 341 toupcam_ports(HRESULT) Toupcam_get_ExpoAGainRange(HToupCam h, unsigned short* nMin, unsigned short* nMax, unsigned short* nDef); 342 343 /* Auto White Balance, Temp/Tint Mode */ 344 toupcam_ports(HRESULT) Toupcam_AwbOnePush(HToupCam h, PITOUPCAM_TEMPTINT_CALLBACK fnTTProc, void* pTTCtx); /* auto white balance "one push". The function must be called AFTER Toupcam_StartXXXX */ 345 346 /* Auto White Balance, RGB Gain Mode */ 347 toupcam_ports(HRESULT) Toupcam_AwbInit(HToupCam h, PITOUPCAM_WHITEBALANCE_CALLBACK fnWBProc, void* pWBCtx); 348 349 /* White Balance, Temp/Tint mode */ 350 toupcam_ports(HRESULT) Toupcam_put_TempTint(HToupCam h, int nTemp, int nTint); 351 toupcam_ports(HRESULT) Toupcam_get_TempTint(HToupCam h, int* nTemp, int* nTint); 352 353 /* White Balance, RGB Gain mode */ 354 toupcam_ports(HRESULT) Toupcam_put_WhiteBalanceGain(HToupCam h, int aGain[3]); 355 toupcam_ports(HRESULT) Toupcam_get_WhiteBalanceGain(HToupCam h, int aGain[3]); 356 357 toupcam_ports(HRESULT) Toupcam_put_Hue(HToupCam h, int Hue); 358 toupcam_ports(HRESULT) Toupcam_get_Hue(HToupCam h, int* Hue); 359 toupcam_ports(HRESULT) Toupcam_put_Saturation(HToupCam h, int Saturation); 360 toupcam_ports(HRESULT) Toupcam_get_Saturation(HToupCam h, int* Saturation); 361 toupcam_ports(HRESULT) Toupcam_put_Brightness(HToupCam h, int Brightness); 362 toupcam_ports(HRESULT) Toupcam_get_Brightness(HToupCam h, int* Brightness); 363 toupcam_ports(HRESULT) Toupcam_get_Contrast(HToupCam h, int* Contrast); 364 toupcam_ports(HRESULT) Toupcam_put_Contrast(HToupCam h, int Contrast); 365 toupcam_ports(HRESULT) Toupcam_get_Gamma(HToupCam h, int* Gamma); /* percent */ 366 toupcam_ports(HRESULT) Toupcam_put_Gamma(HToupCam h, int Gamma); /* percent */ 367 368 toupcam_ports(HRESULT) Toupcam_get_Chrome(HToupCam h, BOOL* bChrome); /* monochromatic mode */ 369 toupcam_ports(HRESULT) Toupcam_put_Chrome(HToupCam h, BOOL bChrome); 370 371 toupcam_ports(HRESULT) Toupcam_get_VFlip(HToupCam h, BOOL* bVFlip); /* vertical flip */ 372 toupcam_ports(HRESULT) Toupcam_put_VFlip(HToupCam h, BOOL bVFlip); 373 toupcam_ports(HRESULT) Toupcam_get_HFlip(HToupCam h, BOOL* bHFlip); 374 toupcam_ports(HRESULT) Toupcam_put_HFlip(HToupCam h, BOOL bHFlip); /* horizontal flip */ 375 376 toupcam_ports(HRESULT) Toupcam_get_Negative(HToupCam h, BOOL* bNegative); /* negative film */ 377 toupcam_ports(HRESULT) Toupcam_put_Negative(HToupCam h, BOOL bNegative); 378 379 toupcam_ports(HRESULT) Toupcam_put_Speed(HToupCam h, unsigned short nSpeed); 380 toupcam_ports(HRESULT) Toupcam_get_Speed(HToupCam h, unsigned short* pSpeed); 381 toupcam_ports(HRESULT) Toupcam_get_MaxSpeed(HToupCam h); /* get the maximum speed, see "Frame Speed Level", the speed range = [0, max], closed interval */ 382 383 toupcam_ports(HRESULT) Toupcam_get_FanMaxSpeed(HToupCam h); /* get the maximum fan speed, the fan speed range = [0, max], closed interval */ 384 385 toupcam_ports(HRESULT) Toupcam_get_MaxBitDepth(HToupCam h); /* get the max bit depth of this camera, such as 8, 10, 12, 14, 16 */ 386 387 /* power supply: 388 0 -> 60HZ AC 389 1 -> 50Hz AC 390 2 -> DC 391 */ 392 toupcam_ports(HRESULT) Toupcam_put_HZ(HToupCam h, int nHZ); 393 toupcam_ports(HRESULT) Toupcam_get_HZ(HToupCam h, int* nHZ); 394 395 toupcam_ports(HRESULT) Toupcam_put_Mode(HToupCam h, BOOL bSkip); /* skip or bin */ 396 toupcam_ports(HRESULT) Toupcam_get_Mode(HToupCam h, BOOL* bSkip); /* If the model don't support bin/skip mode, return E_NOTIMPL */ 397 398 toupcam_ports(HRESULT) Toupcam_put_AWBAuxRect(HToupCam h, const RECT* pAuxRect); /* auto white balance ROI */ 399 toupcam_ports(HRESULT) Toupcam_get_AWBAuxRect(HToupCam h, RECT* pAuxRect); 400 toupcam_ports(HRESULT) Toupcam_put_AEAuxRect(HToupCam h, const RECT* pAuxRect); /* auto exposure ROI */ 401 toupcam_ports(HRESULT) Toupcam_get_AEAuxRect(HToupCam h, RECT* pAuxRect); 402 403 /* 404 S_FALSE: color mode 405 S_OK: mono mode, such as EXCCD00300KMA and UHCCD01400KMA 406 */ 407 toupcam_ports(HRESULT) Toupcam_get_MonoMode(HToupCam h); 408 409 toupcam_ports(HRESULT) Toupcam_get_StillResolutionNumber(HToupCam h); 410 toupcam_ports(HRESULT) Toupcam_get_StillResolution(HToupCam h, unsigned nResolutionIndex, int* pWidth, int* pHeight); 411 412 /* default: FALSE */ 413 toupcam_ports(HRESULT) Toupcam_put_RealTime(HToupCam h, BOOL bEnable); 414 toupcam_ports(HRESULT) Toupcam_get_RealTime(HToupCam h, BOOL* bEnable); 415 416 toupcam_ports(HRESULT) Toupcam_Flush(HToupCam h); /* discard the current internal frame cache */ 417 418 /* get the temperature of sensor, in 0.1 degrees Celsius (32 means 3.2 degrees Celsius, -35 means -3.5 degree Celsius) 419 return E_NOTIMPL if not supported 420 */ 421 toupcam_ports(HRESULT) Toupcam_get_Temperature(HToupCam h, short* pTemperature); 422 423 /* set the temperature of sensor, in 0.1 degrees Celsius (32 means 3.2 degrees Celsius, -35 means -3.5 degree Celsius) 424 return E_NOTIMPL if not supported 425 */ 426 toupcam_ports(HRESULT) Toupcam_put_Temperature(HToupCam h, short nTemperature); 427 428 /* 429 get the serial number which is always 32 chars which is zero-terminated such as "TP110826145730ABCD1234FEDC56787" 430 */ 431 toupcam_ports(HRESULT) Toupcam_get_SerialNumber(HToupCam h, char sn[32]); 432 433 /* 434 get the camera firmware version, such as: 3.2.1.20140922 435 */ 436 toupcam_ports(HRESULT) Toupcam_get_FwVersion(HToupCam h, char fwver[16]); 437 438 /* 439 get the camera hardware version, such as: 3.2.1.20140922 440 */ 441 toupcam_ports(HRESULT) Toupcam_get_HwVersion(HToupCam h, char hwver[16]); 442 443 /* 444 get the production date, such as: 20150327 445 */ 446 toupcam_ports(HRESULT) Toupcam_get_ProductionDate(HToupCam h, char pdate[10]); 447 448 /* 449 get the sensor pixel size, such as: 2.4um 450 */ 451 toupcam_ports(HRESULT) Toupcam_get_PixelSize(HToupCam h, unsigned nResolutionIndex, float* x, float* y); 452 453 toupcam_ports(HRESULT) Toupcam_put_LevelRange(HToupCam h, unsigned short aLow[4], unsigned short aHigh[4]); 454 toupcam_ports(HRESULT) Toupcam_get_LevelRange(HToupCam h, unsigned short aLow[4], unsigned short aHigh[4]); 455 456 toupcam_ports(HRESULT) Toupcam_put_ExpoCallback(HToupCam h, PITOUPCAM_EXPOSURE_CALLBACK fnExpoProc, void* pExpoCtx); 457 toupcam_ports(HRESULT) Toupcam_put_ChromeCallback(HToupCam h, PITOUPCAM_CHROME_CALLBACK fnChromeProc, void* pChromeCtx); 458 459 /* 460 The following functions must be called AFTER Toupcam_StartPushMode or Toupcam_StartPullModeWithWndMsg or Toupcam_StartPullModeWithCallback 461 */ 462 toupcam_ports(HRESULT) Toupcam_LevelRangeAuto(HToupCam h); 463 toupcam_ports(HRESULT) Toupcam_GetHistogram(HToupCam h, PITOUPCAM_HISTOGRAM_CALLBACK fnHistogramProc, void* pHistogramCtx); 464 465 /* led state: 466 iLed: Led index, (0, 1, 2, ...) 467 iState: 1 -> Ever bright; 2 -> Flashing; other -> Off 468 iPeriod: Flashing Period (>= 500ms) 469 */ 470 toupcam_ports(HRESULT) Toupcam_put_LEDState(HToupCam h, unsigned short iLed, unsigned short iState, unsigned short iPeriod); 471 472 toupcam_ports(HRESULT) Toupcam_write_EEPROM(HToupCam h, unsigned addr, const unsigned char* pBuffer, unsigned nBufferLen); 473 toupcam_ports(HRESULT) Toupcam_read_EEPROM(HToupCam h, unsigned addr, unsigned char* pBuffer, unsigned nBufferLen); 474 475 toupcam_ports(HRESULT) Toupcam_write_UART(HToupCam h, const unsigned char* pData, unsigned nDataLen); 476 toupcam_ports(HRESULT) Toupcam_read_UART(HToupCam h, unsigned char* pBuffer, unsigned nBufferLen); 477 478 #define TOUPCAM_TEC_TARGET_MIN -300 /* -30.0 degrees Celsius */ 479 #define TOUPCAM_TEC_TARGET_DEF 0 /* 0.0 degrees Celsius */ 480 #define TOUPCAM_TEC_TARGET_MAX 300 /* 30.0 degrees Celsius */ 481 482 #define TOUPCAM_OPTION_NOFRAME_TIMEOUT 0x01 /* iValue: 1 = enable; 0 = disable. default: enable */ 483 #define TOUPCAM_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 */ 484 #define TOUPCAM_OPTION_PROCESSMODE 0x03 /* 0 = better image quality, more cpu usage. this is the default value 485 1 = lower image quality, less cpu usage */ 486 #define TOUPCAM_OPTION_RAW 0x04 /* raw mode, read the sensor data. This can be set only BEFORE Toupcam_StartXXX() */ 487 #define TOUPCAM_OPTION_HISTOGRAM 0x05 /* 0 = only one, 1 = continue mode */ 488 #define TOUPCAM_OPTION_BITDEPTH 0x06 /* 0 = 8 bits mode, 1 = 16 bits mode */ 489 #define TOUPCAM_OPTION_FAN 0x07 /* 0 = turn off the cooling fan, [1, max] = fan speed */ 490 #define TOUPCAM_OPTION_TEC 0x08 /* 0 = turn off the thermoelectric cooler, 1 = turn on the thermoelectric cooler */ 491 #define TOUPCAM_OPTION_LINEAR 0x09 /* 0 = turn off the builtin linear tone mapping, 1 = turn on the builtin linear tone mapping, default value: 1 */ 492 #define TOUPCAM_OPTION_CURVE 0x0a /* 0 = turn off the builtin curve tone mapping, 1 = turn on the builtin curve tone mapping, default value: 1 */ 493 #define TOUPCAM_OPTION_TRIGGER 0x0b /* 0 = video mode, 1 = software or simulated trigger mode, 2 = external trigger mode, default value = 0 */ 494 #define TOUPCAM_OPTION_RGB48 0x0c /* enable RGB48 format when bitdepth > 8 */ 495 #define TOUPCAM_OPTION_COLORMATIX 0x0d /* enable or disable the builtin color matrix, default value: 1 */ 496 #define TOUPCAM_OPTION_WBGAIN 0x0e /* enable or disable the builtin white balance gain, default value: 1 */ 497 #define TOUPCAM_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 */ 498 #define TOUPCAM_OPTION_AGAIN 0x10 /* enable or disable adjusting the analog gain when auto exposure is enabled. default value: enable */ 499 #define TOUPCAM_OPTION_FRAMERATE 0x11 /* limit the frame rate, range=[0, 63], the default value 0 means no limit */ 500 #define TOUPCAM_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 */ 501 #define TOUPCAM_OPTION_DEMOSAIC_VIDEO 0x13 /* demosaic method for video */ 502 #define TOUPCAM_OPTION_DEMOSAIC_STILL 0x14 /* demosaic method for still image */ 503 #define TOUPCAM_OPTION_BLACKLEVEL 0x15 /* black level */ 504 505 toupcam_ports(HRESULT) Toupcam_put_Option(HToupCam h, unsigned iOption, int iValue); 506 toupcam_ports(HRESULT) Toupcam_get_Option(HToupCam h, unsigned iOption, int* piValue); 507 508 toupcam_ports(HRESULT) Toupcam_put_Roi(HToupCam h, unsigned xOffset, unsigned yOffset, unsigned xWidth, unsigned yHeight); 509 toupcam_ports(HRESULT) Toupcam_get_Roi(HToupCam h, unsigned* pxOffset, unsigned* pyOffset, unsigned* pxWidth, unsigned* pyHeight); 510 511 /* 512 get the frame rate: framerate (fps) = Frame * 1000.0 / nTime 513 */ 514 toupcam_ports(HRESULT) Toupcam_get_FrameRate(HToupCam h, unsigned* nFrame, unsigned* nTime, unsigned* nTotalFrame); 515 516 /* astronomy: for ST4 guide, please see: ASCOM Platform Help ICameraV2. 517 nDirect: 0 = North, 1 = South, 2 = East, 3 = West, 4 = Stop 518 nDuration: in milliseconds 519 */ 520 toupcam_ports(HRESULT) Toupcam_ST4PlusGuide(HToupCam h, unsigned nDirect, unsigned nDuration); 521 522 /* S_OK: pulse guiding 523 S_FALSE: not pulse guiding 524 */ 525 toupcam_ports(HRESULT) Toupcam_ST4PlusGuideState(HToupCam h); 526 527 /* 528 calculate the clarity factor: 529 pImageData: pointer to the image data 530 bits: 8(Grey), 24 (RGB24), 32(RGB32) 531 nImgWidth, nImgHeight: the image width and height 532 */ 533 toupcam_ports(double) Toupcam_calc_ClarityFactor(const void* pImageData, int bits, unsigned nImgWidth, unsigned nImgHeight); 534 535 toupcam_ports(void) Toupcam_deBayer(unsigned nBayer, int nW, int nH, const void* input, void* output, unsigned char nBitDepth); 536 537 typedef void (__stdcall* PTOUPCAM_DEMOSAIC_CALLBACK)(unsigned nBayer, int nW, int nH, const void* input, void* output, unsigned char nBitDepth, void* pCallbackCtx); 538 toupcam_ports(HRESULT) Toupcam_put_Demosaic(HToupCam h, PTOUPCAM_DEMOSAIC_CALLBACK pCallback, void* pCallbackCtx); 539 540 #ifndef _WIN32 541 542 typedef void (*PTOUPCAM_HOTPLUG)(void* pCallbackCtx); 543 toupcam_ports(void) Toupcam_HotPlug(PTOUPCAM_HOTPLUG pHotPlugCallback, void* pCallbackCtx); 544 545 #else 546 /* 547 strRegPath, such as: Software\xxxCompany\yyyApplication. 548 If we call this function to enable this feature, the camera parameters will be save in the Registry at HKEY_CURRENT_USER\Software\XxxCompany\yyyApplication\{CameraModelName} when we close the handle, 549 and then, the next time, we open the camera, the parameters will be loaded automatically. 550 */ 551 toupcam_ports(void) Toupcam_EnableReg(const wchar_t* strRegPath); 552 553 /* Toupcam_Start is obsolete, it's a synonyms for Toupcam_StartPushMode. */ 554 toupcam_ports(HRESULT) Toupcam_Start(HToupCam h, PTOUPCAM_DATA_CALLBACK pDataCallback, void* pCallbackCtx); 555 556 /* Toupcam_put_TempTintInit is obsolete, it's a synonyms for Toupcam_AwbOnePush. */ 557 toupcam_ports(HRESULT) Toupcam_put_TempTintInit(HToupCam h, PITOUPCAM_TEMPTINT_CALLBACK fnTTProc, void* pTTCtx); 558 559 /* 560 obsolete, please use Toupcam_put_Option or Toupcam_get_Option to set or get the process mode: TOUPCAM_PROCESSMODE_FULL or TOUPCAM_PROCESSMODE_FAST. 561 default is TOUPCAM_PROCESSMODE_FULL. 562 */ 563 #ifndef __TOUPCAM_PROCESSMODE_DEFINED__ 564 #define __TOUPCAM_PROCESSMODE_DEFINED__ 565 #define TOUPCAM_PROCESSMODE_FULL 0x00 /* better image quality, more cpu usage. this is the default value */ 566 #define TOUPCAM_PROCESSMODE_FAST 0x01 /* lower image quality, less cpu usage */ 567 #endif 568 569 toupcam_ports(HRESULT) Toupcam_put_ProcessMode(HToupCam h, unsigned nProcessMode); 570 toupcam_ports(HRESULT) Toupcam_get_ProcessMode(HToupCam h, unsigned* pnProcessMode); 571 572 #endif 573 574 /* obsolete, please use Toupcam_put_Roi and Toupcam_get_Roi */ 575 toupcam_ports(HRESULT) Toupcam_put_RoiMode(HToupCam h, BOOL bRoiMode, int xOffset, int yOffset); 576 toupcam_ports(HRESULT) Toupcam_get_RoiMode(HToupCam h, BOOL* pbRoiMode, int* pxOffset, int* pyOffset); 577 578 /* obsolete: 579 ------------------------------------------------------------| 580 | Parameter | Range | Default | 581 |-----------------------------------------------------------| 582 | VidgetAmount | -100~100 | 0 | 583 | VignetMidPoint | 0~100 | 50 | 584 ------------------------------------------------------------- 585 */ 586 toupcam_ports(HRESULT) Toupcam_put_VignetEnable(HToupCam h, BOOL bEnable); 587 toupcam_ports(HRESULT) Toupcam_get_VignetEnable(HToupCam h, BOOL* bEnable); 588 toupcam_ports(HRESULT) Toupcam_put_VignetAmountInt(HToupCam h, int nAmount); 589 toupcam_ports(HRESULT) Toupcam_get_VignetAmountInt(HToupCam h, int* nAmount); 590 toupcam_ports(HRESULT) Toupcam_put_VignetMidPointInt(HToupCam h, int nMidPoint); 591 toupcam_ports(HRESULT) Toupcam_get_VignetMidPointInt(HToupCam h, int* nMidPoint); 592 593 #ifdef _WIN32 594 #pragma pack(pop) 595 #endif 596 597 #ifdef __cplusplus 598 } 599 #endif 600 601 #endif 602