TUCamAPI.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace TUCAMAPI
  4. {
  5. // The correct state [0x00000000, 0x7FFFFFFF]
  6. // The error state [0x80000000, 0XFFFFFFFF]
  7. // typedef enum TUCAM status
  8. public enum TUCAMRET : uint
  9. {
  10. // success
  11. TUCAMRET_SUCCESS = 0x00000001, // no error, general success code, app should check the value is positive
  12. TUCAMRET_FAILURE = 0x80000000, // error
  13. // initialization error
  14. TUCAMRET_NO_MEMORY = 0x80000101, // not enough memory
  15. TUCAMRET_NO_RESOURCE = 0x80000102, // not enough resource except memory
  16. TUCAMRET_NO_MODULE = 0x80000103, // no sub module
  17. TUCAMRET_NO_DRIVER = 0x80000104, // no driver
  18. TUCAMRET_NO_CAMERA = 0x80000105, // no camera
  19. TUCAMRET_NO_GRABBER = 0x80000106, // no grabber
  20. TUCAMRET_NO_PROPERTY = 0x80000107, // there is no alternative or influence id, or no more property id
  21. TUCAMRET_FAILOPEN_CAMERA = 0x80000110, // fail open the camera
  22. TUCAMRET_FAILOPEN_BULKIN = 0x80000111, // fail open the bulk in endpoint
  23. TUCAMRET_FAILOPEN_BULKOUT = 0x80000112, // fail open the bulk out endpoint
  24. TUCAMRET_FAILOPEN_CONTROL = 0x80000113, // fail open the control endpoint
  25. TUCAMRET_FAILCLOSE_CAMERA = 0x80000114, // fail close the camera
  26. TUCAMRET_FAILOPEN_FILE = 0x80000115, // fail open the file
  27. TUCAMRET_FAILOPEN_CODEC = 0x80000116, // fail open the video codec
  28. TUCAMRET_FAILOPEN_CONTEXT = 0x80000117, // fail open the video context
  29. // status error
  30. TUCAMRET_INIT = 0x80000201, // API requires has not initialized state.
  31. TUCAMRET_BUSY = 0x80000202, // API cannot process in busy state.
  32. TUCAMRET_NOT_INIT = 0x80000203, // API requires has initialized state.
  33. TUCAMRET_EXCLUDED = 0x80000204, // some resource is exclusive and already used.
  34. TUCAMRET_NOT_BUSY = 0x80000205, // API requires busy state.
  35. TUCAMRET_NOT_READY = 0x80000206, // API requires ready state.
  36. // wait error
  37. TUCAMRET_ABORT = 0x80000207, // abort process
  38. TUCAMRET_TIMEOUT = 0x80000208, // timeout
  39. TUCAMRET_LOSTFRAME = 0x80000209, // frame data is lost
  40. TUCAMRET_MISSFRAME = 0x8000020A, // frame is lost but reason is low lever driver's bug
  41. TUCAMRET_USB_STATUS_ERROR = 0x8000020B, // the USB status error
  42. // calling error
  43. TUCAMRET_INVALID_CAMERA = 0x80000301, // invalid camera
  44. TUCAMRET_INVALID_HANDLE = 0x80000302, // invalid camera handle
  45. TUCAMRET_INVALID_OPTION = 0x80000303, // invalid the option value of structure
  46. TUCAMRET_INVALID_IDPROP = 0x80000304, // invalid property id
  47. TUCAMRET_INVALID_IDCAPA = 0x80000305, // invalid capability id
  48. TUCAMRET_INVALID_IDPARAM = 0x80000306, // invalid parameter id
  49. TUCAMRET_INVALID_PARAM = 0x80000307, // invalid parameter
  50. TUCAMRET_INVALID_FRAMEIDX = 0x80000308, // invalid frame index
  51. TUCAMRET_INVALID_VALUE = 0x80000309, // invalid property value
  52. TUCAMRET_INVALID_EQUAL = 0x8000030A, // invalid property value equal
  53. TUCAMRET_INVALID_CHANNEL = 0x8000030B, // the property id specifies channel but channel is invalid
  54. TUCAMRET_INVALID_SUBARRAY = 0x8000030C, // the combination of subarray values are invalid. e.g. TUCAM_IDPROP_SUBARRAYHPOS + TUCAM_IDPROP_SUBARRAYHSIZE is greater than the number of horizontal pixel of sensor.
  55. TUCAMRET_INVALID_VIEW = 0x8000030D, // invalid view window handle
  56. TUCAMRET_INVALID_PATH = 0x8000030E, // invalid file path
  57. TUCAMRET_INVALID_IDVPROP = 0x8000030F, // invalid vendor property id
  58. TUCAMRET_NO_VALUETEXT = 0x80000310, // the property does not have value text
  59. TUCAMRET_OUT_OF_RANGE = 0x80000311, // value is out of range
  60. TUCAMRET_NOT_SUPPORT = 0x80000312, // camera does not support the function or property with current settings
  61. TUCAMRET_NOT_WRITABLE = 0x80000313, // the property is not writable
  62. TUCAMRET_NOT_READABLE = 0x80000314, // the property is not readable
  63. TUCAMRET_WRONG_HANDSHAKE = 0x80000410, // this error happens TUCAM get error code from camera unexpectedly
  64. TUCAMRET_NEWAPI_REQUIRED = 0x80000411, // old API does not support the value because only new API supports the value
  65. TUCAMRET_ACCESSDENY = 0x80000412, // the property cannot access during this TUCAM status
  66. TUCAMRET_NO_CORRECTIONDATA = 0x80000501, // not take the dark and shading correction data yet.
  67. TUCAMRET_INVALID_PRFSETS = 0x80000601, // the profiles set name is invalid
  68. TUCAMRET_DECODE_FAILURE = 0x80000701, // the image decoding raw data to rgb data failure
  69. TUCAMRET_COPYDATA_FAILURE = 0x80000702, // the image data copying failure
  70. TUCAMRET_ENCODE_FAILURE = 0x80000703, // the image encoding data to video failure
  71. TUCAMRET_WRITE_FAILURE = 0x80000704, // the write the video frame failure
  72. // camera or bus trouble
  73. TUCAMRET_FAIL_READ_CAMERA = 0x83001001, // fail read from camera
  74. TUCAMRET_FAIL_WRITE_CAMERA = 0x83001002, // fail write to camera
  75. TUCAMRET_OPTICS_UNPLUGGED = 0x83001003, // optics part is unplugged so please check it.
  76. TUCAMRET_RECEIVE_FINISH = 0x00000002, // no error, vendor receive frame message
  77. TUCAMRET_EXTERNAL_TRIGGER = 0x00000003, // no error, receive the external trigger signal
  78. };
  79. // typedef enum information id
  80. public enum TUCAM_IDINFO
  81. {
  82. TUIDI_BUS = 0x01, // the bus type USB2.0/USB3.0
  83. TUIDI_VENDOR = 0x02, // the vendor id
  84. TUIDI_PRODUCT = 0x03, // the product id
  85. TUIDI_VERSION_API = 0x04, // the API version
  86. TUIDI_VERSION_FRMW = 0x05, // the firmware version
  87. TUIDI_VERSION_FPGA = 0x06, // the FPGA version
  88. TUIDI_VERSION_DRIVER = 0x07, // the driver version
  89. TUIDI_TRANSFER_RATE = 0x08, // the transfer rate
  90. TUIDI_CAMERA_MODEL = 0x09, // the camera model (string)
  91. TUIDI_CURRENT_WIDTH = 0x0A, // the camera image data current width(must use TUCAM_Dev_GetInfoEx and after calling TUCAM_Buf_Alloc)
  92. TUIDI_CURRENT_HEIGHT = 0x0B, // the camera image data current height(must use TUCAM_Dev_GetInfoEx and after calling TUCAM_Buf_Alloc)
  93. TUIDI_CAMERA_CHANNELS = 0x0C, // the camera image data channels
  94. TUIDI_BCDDEVICE = 0x0D, // the USB bcdDevice
  95. TUIDI_ENDINFO = 0x0E, // the string id end
  96. };
  97. // typedef enum capability id
  98. public enum TUCAM_IDCAPA
  99. {
  100. TUIDC_RESOLUTION = 0x00, // id capability resolution
  101. TUIDC_PIXELCLOCK = 0x01, // id capability pixel clock
  102. TUIDC_BITOFDEPTH = 0x02, // id capability bit of depth
  103. TUIDC_ATEXPOSURE = 0x03, // id capability automatic exposure time
  104. TUIDC_HORIZONTAL = 0x04, // id capability horizontal
  105. TUIDC_VERTICAL = 0x05, // id capability vertical
  106. TUIDC_ATWBALANCE = 0x06, // id capability automatic white balance
  107. TUIDC_FAN_GEAR = 0x07, // id capability fan gear
  108. TUIDC_ATLEVELS = 0x08, // id capability automatic levels
  109. TUIDC_SHIFT = 0x09, // (The reserved) id capability shift(15~8, 14~7, 13~6, 12~5, 11~4, 10~3, 9~2, 8~1, 7~0) [16bit]
  110. TUIDC_HISTC = 0x0A, // id capability histogram statistic
  111. TUIDC_CHANNELS = 0x0B, // id capability current channels(Only color camera support:0-RGB,1-Red,2-Green,3-Blue. Used in the property levels, see enum TUCHN_SELECT)
  112. TUIDC_ENHANCE = 0x0C, // id capability enhance
  113. TUIDC_DFTCORRECTION = 0x0D, // id capability defect correction (0-not correction, 1-calculate, 3-correction)
  114. TUIDC_ENABLEDENOISE = 0x0E, // id capability enable denoise (TUIDP_NOISELEVEL effective)
  115. TUIDC_FLTCORRECTION = 0x0F, // id capability flat field correction (0-not correction, 1-grab frame, 2-calculate, 3-correction)
  116. TUIDC_RESTARTLONGTM = 0x10, // id capability restart long exposure time (only CCD camera support)
  117. TUIDC_DATAFORMAT = 0x11, // id capability the data format(only YUV format data support 0-YUV 1-RAW)
  118. TUIDC_DRCORRECTION = 0x12, // (The reserved)id capability dynamic range of correction
  119. TUIDC_VERCORRECTION = 0x13, // id capability vertical correction(correction the image data show vertical, in windows os the default value is 1)
  120. TUIDC_MONOCHROME = 0x14, // id capability monochromatic
  121. TUIDC_BLACKBALANCE = 0x15, // id capability black balance
  122. TUIDC_IMGMODESELECT = 0x16, // id capability image mode select(CMS mode)
  123. TUIDC_CAM_MULTIPLE = 0x17, // id capability multiple cameras (how many cameras use at the same time, only SCMOS camera support)
  124. TUIDC_ENABLEPOWEEFREQUENCY = 0x18, // id capability enable power frequency (50HZ or 60HZ)
  125. TUIDC_ROTATE_R90 = 0x19, // id capability rotate 90 degree to right
  126. TUIDC_ROTATE_L90 = 0x1A, // id capability rotate 90 degree to left
  127. TUIDC_NEGATIVE = 0x1B, // id capability negative film enable
  128. TUIDC_HDR = 0x1C, // id capability HDR enable
  129. TUIDC_ENABLEIMGPRO = 0x1D, // id capability image process enable
  130. TUIDC_ENABLELED = 0x1E, // id capability USB led enable
  131. TUIDC_ENABLETIMESTAMP = 0x1F, // id capability time stamp enable
  132. TUIDC_ENABLEBLACKLEVEL = 0x20, // id capability black level offset enable
  133. TUIDC_ATFOCUS = 0x21, // id capability auto focus enable(0-manual 1-automatic focus 2-Once)
  134. TUIDC_ATFOCUS_STATUS = 0x22, // id capability auto focus status(0-stop 1-focusing 2-completed 3-defocus)
  135. TUIDC_PGAGAIN = 0x23, // id capability sensor pga gain
  136. TUIDC_ATEXPOSURE_MODE = 0x24, // id capability automatic exposure time mode
  137. TUIDC_BINNING_SUM = 0x25, // id capability the summation binning
  138. TUIDC_BINNING_AVG = 0x26, // id capability the average binning
  139. TUIDC_FOCUS_C_MOUNT = 0x27, // id capability the focus c-mount mode(0-normal 1-c-mount mode)
  140. TUIDC_ENDCAPABILITY = 0x28, // id capability end
  141. };
  142. // typedef enum property id
  143. public enum TUCAM_IDPROP
  144. {
  145. TUIDP_GLOBALGAIN = 0x00, // id property global gain
  146. TUIDP_EXPOSURETM = 0x01, // id property exposure time
  147. TUIDP_BRIGHTNESS = 0x02, // id property brightness (Effective automatic exposure condition)
  148. TUIDP_BLACKLEVEL = 0x03, // id property black level
  149. TUIDP_TEMPERATURE = 0x04, // id property temperature control
  150. TUIDP_SHARPNESS = 0x05, // id property sharpness
  151. TUIDP_NOISELEVEL = 0x06, // id property the noise level
  152. TUIDP_HDR_KVALUE = 0x07, // id property the HDR K value
  153. // image process property
  154. TUIDP_GAMMA = 0x08, // id property gamma
  155. TUIDP_CONTRAST = 0x09, // id property contrast
  156. TUIDP_LFTLEVELS = 0x0A, // id property left levels
  157. TUIDP_RGTLEVELS = 0x0B, // id property right levels
  158. TUIDP_CHNLGAIN = 0x0C, // id property channel gain
  159. TUIDP_SATURATION = 0x0D, // id property saturation
  160. TUIDP_CLRTEMPERATURE = 0x0E, // id property color temperature
  161. TUIDP_CLRMATRIX = 0x0F, // id property color matrix setting
  162. TUIDP_DPCLEVEL = 0x10, // id property defect points correction level
  163. TUIDP_BLACKLEVELHG = 0x11, // id property black level high gain
  164. TUIDP_BLACKLEVELLG = 0x12, // id property black level low gain
  165. TUIDP_POWEEFREQUENCY = 0x13, // id property power frequency (50HZ or 60HZ)
  166. TUIDP_HUE = 0x14, // id property hue
  167. TUIDP_LIGHT = 0x15, // id property light
  168. TUIDP_ENHANCE_STRENGTH = 0x16, // id property enhance strength
  169. TUIDP_NOISELEVEL_3D = 0x17, // id property the 3D noise level
  170. TUIDP_FOCUS_POSITION = 0x18, // id property focus position
  171. TUIDP_ENDPROPERTY = 0x19, // id property end
  172. };
  173. // typedef enum the capture mode
  174. public enum TUCAM_CAPTURE_MODES
  175. {
  176. TUCCM_SEQUENCE = 0x00, // capture start sequence mode
  177. TUCCM_TRIGGER_STANDARD = 0x01, // capture start trigger standard mode
  178. TUCCM_TRIGGER_SYNCHRONOUS = 0x02, // capture start trigger synchronous mode
  179. TUCCM_TRIGGER_GLOBAL = 0x03, // capture start trigger global
  180. TUCCM_TRIGGER_SOFTWARE = 0x04, // capture start trigger software
  181. };
  182. // typedef enum the image formats
  183. public enum TUIMG_FORMATS
  184. {
  185. TUFMT_RAW = 0x01, // The format RAW
  186. TUFMT_TIF = 0x02, // The format TIFF
  187. TUFMT_PNG = 0x04, // The format PNG
  188. TUFMT_JPG = 0x08, // The format JPEG
  189. TUFMT_BMP = 0x10, // The format BMP
  190. };
  191. // typedef enum the register types
  192. public enum TUREG_TYPE
  193. {
  194. TUREG_SN = 0x01, // The type register SN
  195. TUREG_DATA = 0x02, // The type register data
  196. };
  197. // trigger mode
  198. // typedef enum the trigger exposure time mode
  199. public enum TUCAM_TRIGGER_EXP
  200. {
  201. TUCTE_EXPTM = 0x00, // use exposure time
  202. TUCTE_WIDTH = 0x01, // use width level
  203. };
  204. // typedef enum the trigger edge mode
  205. public enum TUCAM_TRIGGER_EDGE
  206. {
  207. TUCTD_RISING = 0x01, // rising edge
  208. TUCTD_FAILING = 0x00, // failing edge
  209. };
  210. // typedef enum the frame formats
  211. public enum TUFRM_FORMATS
  212. {
  213. TUFRM_FMT_RAW = 0x10, // The raw data
  214. TUFRM_FMT_USUAl = 0x11, // The usually data
  215. TUFRM_FMT_RGB888 = 0x12, // The RGB888 data for drawing
  216. };
  217. // typedef enum the SCMOS gain mode
  218. public enum TUGAIN_MODE
  219. {
  220. TUGAIN_HDR = 0x00, // The HDR mode
  221. TUGAIN_HIGH = 0x01, // The High gain mode
  222. TUGAIN_LOW = 0x02, // The Low gain mode
  223. };
  224. /* **************************************************************** *
  225. struct defines
  226. * **************************************************************** */
  227. // the camera initialize struct
  228. public struct TUCAM_INIT
  229. {
  230. public UInt32 uiCamCount; // [out]
  231. public IntPtr pstrConfigPath; // [in] save the path of the camera parameters
  232. };
  233. // the camera open struct
  234. public struct TUCAM_OPEN
  235. {
  236. public UInt32 uiIdxOpen; // [in]
  237. public IntPtr hIdxTUCam; // [out] the handle of the opened camera device
  238. };
  239. // the image open struct
  240. public struct TUIMG_OPEN
  241. {
  242. public IntPtr pszfileName; // [in] the full path of the image file
  243. public IntPtr hIdxTUImg; // [out] the handle of the opened image file
  244. };
  245. // the camera value text struct
  246. public struct TUCAM_VALUE_INFO
  247. {
  248. public Int32 nID; // [in] TUCAM_IDINFO
  249. public Int32 nValue; // [in] value of information
  250. public IntPtr pText; // [in/out] text of the value
  251. public Int32 nTextSize; // [in] text buffer size
  252. };
  253. // the camera value text struct
  254. public struct TUCAM_VALUE_TEXT
  255. {
  256. public Int32 nID; // [in] TUCAM_IDPROP / TUCAM_IDCAPA
  257. public Double dbValue; // [in] value of property
  258. public IntPtr pText; // [in/out] text of the value
  259. public Int32 nTextSize; // [in] text buffer size
  260. };
  261. // the camera capability attribute
  262. public struct TUCAM_CAPA_ATTR
  263. {
  264. public Int32 idCapa; // [in] TUCAM_IDCAPA
  265. public Int32 nValMin; // [out] minimum value
  266. public Int32 nValMax; // [out] maximum value
  267. public Int32 nValDft; // [out] default value
  268. public Int32 nValStep; // [out] minimum stepping between a value and the next
  269. };
  270. // the camera property attribute
  271. public struct TUCAM_PROP_ATTR
  272. {
  273. public Int32 idProp; // [in] TUCAM_IDPROP
  274. public Int32 nIdxChn; // [in/out] the index of channel
  275. public Double dbValMin; // [out] minimum value
  276. public Double dbValMax; // [out] maximum value
  277. public Double dbValDft; // [out] default value
  278. public Double dbValStep; // [out] minimum stepping between a value and the next
  279. };
  280. // the camera ROI attribute
  281. public struct TUCAM_ROI_ATTR
  282. {
  283. public bool bEnable; // [in/out] The ROI enable
  284. public Int32 nHOffset; // [in/out] The horizontal offset
  285. public Int32 nVOffset; // [in/out] The vertical offset
  286. public Int32 nWidth; // [in/out] The ROI width
  287. public Int32 nHeight; // [in/out] The ROI height
  288. };
  289. // the camera ROI calculate attribute
  290. public struct TUCAM_CALC_ROI_ATTR
  291. {
  292. public bool bEnable; // [in/out] The ROI enable
  293. public Int32 idCalc; // [in] TUCAM_IDCROI
  294. public Int32 nHOffset; // [in/out] The horizontal offset
  295. public Int32 nVOffset; // [in/out] The vertical offset
  296. public Int32 nWidth; // [in/out] The ROI width
  297. public Int32 nHeight; // [in/out] The ROI height
  298. };
  299. // the camera trigger attribute
  300. public struct TUCAM_TRIGGER_ATTR
  301. {
  302. public Int32 nTgrMode; // [in/out] The mode of trigger
  303. public Int32 nExpMode; // [in/out] The mode of exposure [0, 1] 0:Exposure time 1:Width level
  304. public Int32 nEdgeMode; // [in/out] The mode of edge [0, 1] 0:Falling edge 1:Rising edge
  305. public Int32 nDelayTm; // [in/out] The time delay
  306. public Int32 nFrames; // [in/out] How many frames per trigger
  307. };
  308. // the camera trigger out attribute
  309. public struct TUCAM_TRGOUT_ATTR
  310. {
  311. public Int32 nTgrOutPort; // [in/out] The port of trigger out
  312. public Int32 nTgrOutMode; // [in/out] The mode of trigger out
  313. public Int32 nEdgeMode; // [in/out] The mode of edge [0, 1] 1:Falling edge 0:Rising edge
  314. public Int32 nDelayTm; // [in/out] The time delay
  315. public Int32 nWidth; // [in/out] The width of pulse
  316. };
  317. // the camera frame struct
  318. public struct TUCAM_FRAME
  319. {
  320. // TUCAM_Buf_WaitForFrame() use this structure. Some members have different direction.
  321. // [i:o] means, the member is input at TUCAM_Buf_WaitForFrame()
  322. // [i:i] and [o:o] means always input and output at both function.
  323. // "input" means application has to set the value before calling.
  324. // "output" means function fills a value at returning.
  325. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
  326. public byte[] szSignature; // [out]Copyright+Version: TU+1.0 ['T', 'U', '1', '\0']
  327. // The based information
  328. public ushort usHeader; // [out] The frame header size
  329. public ushort usOffset; // [out] The frame data offset
  330. public ushort usWidth; // [out] The frame width
  331. public ushort usHeight; // [out] The frame height
  332. public UInt32 uiWidthStep; // [out] The frame width step
  333. public byte ucDepth; // [out] The frame data depth
  334. public byte ucFormat; // [out] The frame data format
  335. public byte ucChannels; // [out] The frame data channels
  336. public byte ucElemBytes; // [out] The frame data bytes per element
  337. public byte ucFormatGet; // [in] Which frame data format do you want see TUFRM_FORMATS
  338. public UInt32 uiIndex; // [in/out] The frame index number
  339. public UInt32 uiImgSize; // [out] The frame size
  340. public UInt32 uiRsdSize; // [in] The frame reserved size (how many frames do you want)
  341. public UInt32 uiHstSize; // [out] The frame histogram size
  342. public IntPtr pBuffer; // [in/out] The frame buffer
  343. };
  344. // the file save struct
  345. public struct TUCAM_FILE_SAVE
  346. {
  347. public Int32 nSaveFmt; // [in] the format of save file see TUIMG_FORMATS
  348. public IntPtr pstrSavePath; // [in] the path of save file
  349. public IntPtr pFrame; // [in] the struct of camera frame
  350. };
  351. // the record save struct
  352. public struct TUCAM_REC_SAVE
  353. {
  354. public Int32 nCodec; // [in] the coder-decoder type
  355. public IntPtr pstrSavePath; // [in] the path of save record file
  356. public float fFps; // [in] the current FPS
  357. };
  358. // the register read/write struct
  359. public struct TUCAM_REG_RW
  360. {
  361. public Int32 nRegType; // [in] the format of register see TUREG_TYPE
  362. public IntPtr pBuf; // [in/out] pointer to the buffer value
  363. public Int32 nBufSize; // [in] the buffer size
  364. };
  365. // typedef struct draw initialize
  366. public struct TUCAM_DRAW_INIT
  367. {
  368. public IntPtr hWnd; // [in] Handle the draw window
  369. public Int32 nMode; // [in] (The reserved)Whether use hardware acceleration (If the GPU support) default:TUDRAW_DFT
  370. public byte ucChannels; // [in] The data channels
  371. public Int32 nWidth; // [in] The drawing data width
  372. public Int32 nHeight; // [in] The drawing data height
  373. };
  374. // typedef struct drawing
  375. public struct TUCAM_DRAW
  376. {
  377. public Int32 nSrcX; // [in/out] The x-coordinate, in pixels, of the upper left corner of the source rectangle.
  378. public Int32 nSrcY; // [in/out] The y-coordinate, in pixels, of the upper left corner of the source rectangle.
  379. public Int32 nSrcWidth; // [in/out] Width, in pixels, of the source rectangle.
  380. public Int32 nSrcHeight; // [in/out] Height, in pixels, of the source rectangle.
  381. public Int32 nDstX; // [in/out] The x-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
  382. public Int32 nDstY; // [in/out] The y-coordinate, in MM_TEXT client coordinates, of the upper left corner of the destination rectangle.
  383. public Int32 nDstWidth; // [in/out] Width, in MM_TEXT client coordinates, of the destination rectangle.
  384. public Int32 nDstHeight; // [in/out] Height, in MM_TEXT client coordinates, of the destination rectangle.
  385. public IntPtr pFrame; // [in] the struct of camera frame
  386. };
  387. public class TUCamAPI
  388. {
  389. //
  390. // Initialize uninitialize and misc.
  391. //
  392. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  393. public static extern TUCAMRET TUCAM_Api_Init(ref TUCAM_INIT pInitParam);
  394. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  395. public static extern TUCAMRET TUCAM_Api_Uninit();
  396. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  397. public static extern TUCAMRET TUCAM_Dev_Open(ref TUCAM_OPEN pOpenParam);
  398. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  399. public static extern TUCAMRET TUCAM_Dev_Close(IntPtr hTUCam);
  400. // Get some device information (VID/PID/Version)
  401. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  402. public static extern TUCAMRET TUCAM_Dev_GetInfo(IntPtr hTUCam, ref TUCAM_VALUE_INFO pInfo);
  403. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  404. public static extern TUCAMRET TUCAM_Dev_GetInfoEx(UInt32 uiICam, ref TUCAM_VALUE_INFO pInfo);
  405. //
  406. // Capability control
  407. //
  408. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  409. public static extern TUCAMRET TUCAM_Capa_GetAttr(IntPtr hTUCam, ref TUCAM_CAPA_ATTR pAttr);
  410. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  411. public static extern TUCAMRET TUCAM_Capa_GetValue(IntPtr hTUCam, Int32 nCapa, ref Int32 pnVal);
  412. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  413. public static extern TUCAMRET TUCAM_Capa_SetValue(IntPtr hTUCam, Int32 nCapa, Int32 nVal);
  414. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  415. public static extern TUCAMRET TUCAM_Capa_GetValueText(IntPtr hTUCam, ref TUCAM_VALUE_TEXT pVal);
  416. //
  417. // Property control
  418. //
  419. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  420. public static extern TUCAMRET TUCAM_Prop_GetAttr(IntPtr hTUCam, ref TUCAM_PROP_ATTR pAttr);
  421. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  422. public static extern TUCAMRET TUCAM_Prop_GetValue(IntPtr hTUCam, Int32 nProp, ref Double pdbVal, Int32 nChn);
  423. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  424. public static extern TUCAMRET TUCAM_Prop_SetValue(IntPtr hTUCam, Int32 nProp, Double dbval, Int32 nChn);
  425. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  426. public static extern TUCAMRET TUCAM_Prop_GetValueText(IntPtr hTUCam, ref TUCAM_VALUE_TEXT pVal, Int32 nChn);
  427. //
  428. // Buffer control
  429. //
  430. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  431. public static extern TUCAMRET TUCAM_Buf_Alloc(IntPtr hTUCam, ref TUCAM_FRAME pFrame);
  432. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  433. public static extern TUCAMRET TUCAM_Buf_Release(IntPtr hTUCam);
  434. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  435. public static extern TUCAMRET TUCAM_Buf_AbortWait(IntPtr hTUCam);
  436. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  437. public static extern TUCAMRET TUCAM_Buf_WaitForFrame(IntPtr hTUCam, ref TUCAM_FRAME pFrame);
  438. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  439. public static extern TUCAMRET TUCAM_Buf_CopyFrame(IntPtr hTUCam, ref TUCAM_FRAME pFrame);
  440. //
  441. // Capturing control
  442. //
  443. // ROI
  444. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  445. public static extern TUCAMRET TUCAM_Cap_SetROI(IntPtr hTUCam, TUCAM_ROI_ATTR roiAttr);
  446. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  447. public static extern TUCAMRET TUCAM_Cap_GetROI(IntPtr hTUCam, ref TUCAM_ROI_ATTR roiAttr);
  448. // Trigger
  449. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  450. public static extern TUCAMRET TUCAM_Cap_SetTrigger(IntPtr hTUCam, TUCAM_TRIGGER_ATTR tgrAttr);
  451. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  452. public static extern TUCAMRET TUCAM_Cap_GetTrigger(IntPtr hTUCam, ref TUCAM_TRIGGER_ATTR tgrAttr);
  453. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  454. public static extern TUCAMRET TUCAM_Cap_DoSoftwareTrigger(IntPtr hTUCam);
  455. // TriggerOut
  456. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  457. public static extern TUCAMRET TUCAM_Cap_SetTriggerOut(IntPtr hTUCam, TUCAM_TRGOUT_ATTR tgroutAttr);
  458. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  459. public static extern TUCAMRET TUCAM_Cap_GetTriggerOut(IntPtr hTUCam, ref TUCAM_TRGOUT_ATTR pTgrOutAttr);
  460. // Capturing
  461. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  462. public static extern TUCAMRET TUCAM_Cap_Start(IntPtr hTUCam, UInt32 uiMode);
  463. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  464. public static extern TUCAMRET TUCAM_Cap_Stop(IntPtr hTUCam);
  465. //
  466. // File control
  467. //
  468. // Image
  469. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  470. public static extern TUCAMRET TUCAM_File_SaveImage(IntPtr hTUCam, TUCAM_FILE_SAVE fileSave);
  471. // Profiles
  472. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  473. public static extern TUCAMRET TUCAM_File_LoadProfiles(IntPtr hTUCam, IntPtr pPrfName);
  474. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  475. public static extern TUCAMRET TUCAM_File_SaveProfiles(IntPtr hTUCam, IntPtr pPrfName);
  476. // Video
  477. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  478. public static extern TUCAMRET TUCAM_Rec_Start(IntPtr hTUCam, TUCAM_REC_SAVE recSave);
  479. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  480. public static extern TUCAMRET TUCAM_Rec_AppendFrame(IntPtr hTUCam, ref TUCAM_FRAME pFrame);
  481. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  482. public static extern TUCAMRET TUCAM_Rec_Stop(IntPtr hTUCam);
  483. //
  484. // Extended control
  485. //
  486. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  487. public static extern TUCAMRET TUCAM_Reg_Read(IntPtr hTUCam, TUCAM_REG_RW regRW);
  488. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  489. public static extern TUCAMRET TUCAM_Reg_Write(IntPtr hTUCam, TUCAM_REG_RW regRW);
  490. // Drawing control
  491. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  492. public static extern TUCAMRET TUCAM_Draw_Init(IntPtr hTUCam, TUCAM_DRAW_INIT drawInit);
  493. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  494. public static extern TUCAMRET TUCAM_Draw_Frame(IntPtr hTUCam, ref TUCAM_DRAW pDrawing);
  495. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  496. public static extern TUCAMRET TUCAM_Draw_Uninit(IntPtr hTUCam);
  497. //
  498. // Find color temperature index value according to RGB
  499. //
  500. [DllImport("TUCam.dll", CallingConvention = CallingConvention.Cdecl)]
  501. public static extern TUCAMRET TUCAM_Index_GetColorTemperature(IntPtr hTUCam, Int32 nRed, Int32 nGeen, Int32 nBlue, ref UInt32 pusValue);
  502. }
  503. }