CIOFrameGrabDefines.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. /*****************************************************************************
  2. * CIOFrameGrabDefines.h
  3. *****************************************************************************
  4. *
  5. * Project: HALCON/libhalcon
  6. * Description: Basic defines and type definitions of the
  7. * Image acquisition integration interface
  8. * (pure header, no CIOFrameGrabDefines.c file)
  9. * Attention: The types, defines, and constants defined in this file are
  10. * used by the hlib extension programming interface (hlibxpi).
  11. * Therefore, they must not be changed without considering the
  12. * effect on released IA interfaces.
  13. * So, for substantial changes the major version of the hlibxpi
  14. * must be increased and a strategy for handling old interfaces
  15. * is needed. I.e. appropriate wrapper have to be provided or
  16. * the collaboration must be rejected in a defined manner.
  17. *
  18. * (c) 1996-2020 by MVTec Software GmbH
  19. * www.mvtec.com
  20. *
  21. *****************************************************************************
  22. *
  23. *
  24. *****************************************************************************
  25. *
  26. * See also: "Image Acquisition Integration Programmer's Manual"
  27. *
  28. *****************************************************************************
  29. */
  30. #ifndef CIOFRAMEGRAB_DEFINES_H
  31. # define CIOFRAMEGRAB_DEFINES_H
  32. # ifndef HC_NO_FRAMEGRABBER
  33. /* FG_INTERFACE_VERSION identifies the HALCON integration interface version.
  34. * Since HALCON 13.0 this version number is basically fixed to 1300.
  35. * With HALCON 17.12 we introduced the new hlibxpi programming interface which
  36. * is mainly for managing interoperabilty of different versions of hlib and
  37. * extensions like the IA interfaces */
  38. # define FG_INTERFACE_VERSION 1300
  39. # define FG_NUM_RESERVED 20
  40. # ifndef HC_NO_FRAMEGRABBER
  41. # define FG_MAX_INST \
  42. 256 /* max. number of handles (instances) per class */
  43. # else
  44. # define FG_MAX_INST 1
  45. # endif
  46. # ifndef FG_PREFIX
  47. # if !defined(H_PARALLEL)
  48. # define FG_PREFIX "seqhAcq"
  49. # else
  50. # define FG_PREFIX "hAcq"
  51. # endif
  52. # endif
  53. # ifndef XL_SUFFIX
  54. # if defined(HC_LARGE_IMAGES)
  55. # define XL_SUFFIX "xl"
  56. # else
  57. # define XL_SUFFIX ""
  58. # endif
  59. # endif
  60. # define FG_QUERY_PORT 0 /* Query: Available port values */
  61. # define FG_QUERY_CAMERA_TYPE 1 /* Query: Available camera types */
  62. # define FG_QUERY_GENERAL 2 /* Query: General information */
  63. # define FG_QUERY_DEFAULTS 3 /* Query: Default values */
  64. # define FG_QUERY_PARAMETERS 4 /* Query: Additional parameters */
  65. # define FG_QUERY_INFO_BOARDS 5 /* Query: Actual installed boards */
  66. # define FG_QUERY_REVISION 6 /* Query: Interface revision */
  67. # define FG_QUERY_INFO_PARAMETERS 7 /* Query: Info to avail. parameters */
  68. # define FG_QUERY_FIELD 8 /* Query: Available field values */
  69. /* Query: Available bits per channel */
  70. # define FG_QUERY_BITS_PER_CHANNEL 9
  71. # define FG_QUERY_COLOR_SPACE 10 /* Query: Available color spaces */
  72. # define FG_QUERY_EXT_TRIGGER 11 /* Query: Available ext. trigger */
  73. # define FG_QUERY_DEVICE 12 /* Query: Available device values */
  74. # define FG_QUERY_PARAMETERS_RO 13 /* Query: Add. read-only parameters */
  75. # define FG_QUERY_PARAMETERS_WO 14 /* Query: Add. write-only parameters*/
  76. # define FG_QUERY_IMAGE_HEIGHT 15 /* Query: Available image_height */
  77. # define FG_QUERY_IMAGE_WIDTH 16 /* Query: Available image_widht */
  78. # define FG_QUERY_START_ROW 17 /* Query: Available start_row values*/
  79. # define FG_QUERY_START_COLUMN 18 /* Query: Available start_column */
  80. /* Query: horizontal_resolution */
  81. # define FG_QUERY_HORIZONTAL_RESOLUTION 19
  82. # define FG_QUERY_VERTICAL_RESOLUTION 20 /* Query: vertical resolution */
  83. # define FG_QUERY_LINE_IN 21 /* Query: Available line_in values */
  84. /* Query: Not for display in generic GUI */
  85. # define FG_QUERY_PARAMETERS_HIDDEN 22
  86. # define FG_QUERY_GENERIC 23 /* Query: Available generic values */
  87. # define FG_FIRST_FIELD 0 /* grab first field */
  88. # define FG_SECOND_FIELD 1 /* grab second field */
  89. # define FG_NEXT_FIELD 3 /* grab next field */
  90. # define FG_FULL_FRAME 2 /* grab frame / interlaced */
  91. # define FG_PROGRESSIVE_FRAME 4 /* grab frame / progressive */
  92. # define FG_FIELD_DEFAULT 5 /* default */
  93. /* corresponding text encoding: */
  94. # define FG_FIRST_FIELD_TXT "first"
  95. # define FG_SECOND_FIELD_TXT "second"
  96. # define FG_NEXT_FIELD_TXT "next"
  97. # define FG_FULL_FRAME_TXT "interlaced"
  98. # define FG_PROGRESSIVE_FRAME_TXT "progressive"
  99. # define FG_FIELD_DEFAULT_TXT "default"
  100. # define FG_PARAM_HORIZONTAL_RESOLUTION "horizontal_resolution"
  101. # define FG_PARAM_VERTICAL_RESOLUTION "vertical_resolution"
  102. # define FG_PARAM_IMAGE_WIDTH "image_width"
  103. # define FG_PARAM_IMAGE_HEIGHT "image_height"
  104. # define FG_PARAM_START_ROW "start_row"
  105. # define FG_PARAM_START_COL "start_column"
  106. # define FG_PARAM_FIELD "field"
  107. # define FG_PARAM_BITS_PER_CHANNEL "bits_per_channel"
  108. # define FG_PARAM_COLOR_SPACE "color_space"
  109. # define FG_PARAM_GAIN "gain" /* only for compatibility */
  110. # define FG_PARAM_GENERIC "generic"
  111. # define FG_PARAM_EXT_TRIGGER "external_trigger"
  112. # define FG_PARAM_CAMERA_TYPE "camera_type"
  113. # define FG_PARAM_DEVICE "device"
  114. # define FG_PARAM_PORT "port"
  115. # define FG_PARAM_LINE_IN "line_in"
  116. # define FG_MAX_CHANNELS \
  117. 1000 /* max number of channels that can be grabbed */
  118. # define FG_MAX_LUT_LENGTH 65536 /* max. length of a Lut */
  119. # define FG_INIT_NAME "FGInit"
  120. # define FG_FLAGS_NAME "FGFlags"
  121. # define FG_MAX_PARAM 2048
  122. /* defines for encoding which method is used for allocating Hrlregions */
  123. # define FG_RLALLOC_PERMANENT 1
  124. # define FG_RLALLOC_TMP 2
  125. # define FG_RLALLOC_LOCAL 4
  126. /* This Macro checks the syntax of Generic. *
  127. * Call it within the loop over the tuple of Generic parameters. *
  128. * i index of parameter *
  129. * pos char *, that points to the "=" *
  130. * ret_act_t return action in case of wrong type (H_ERR_FGPART) *
  131. * ret_act_v return action in case of wrong value (H_ERR_FGPARV) */
  132. # define CHECK_GENERIC(i, pos, ret_act_t, ret_act_v) \
  133. { \
  134. if (fginst->generic[(i)].type == STRING_PAR) \
  135. { \
  136. if (!strlen(fginst->generic[i].par.s)) \
  137. continue; \
  138. if (((pos) = strstr(fginst->generic[(i)].par.s, "=")) != NULL) \
  139. { \
  140. if (strstr((pos) + 1, "=")) \
  141. { \
  142. sprintf(errMsg, \
  143. "Error: More than one '=' found in '%s'. " \
  144. "Please make sure to use a syntax like this " \
  145. "for multiple parameters: " \
  146. "['par1=arg1', 'par2=arg2', ...]", \
  147. fginst->generic[i].par.s); \
  148. MY_PRINT_ERROR_MESSAGE(errMsg); \
  149. ret_act_v; \
  150. } \
  151. } \
  152. else \
  153. { \
  154. sprintf(errMsg, \
  155. "Error: No '=' found in '%s'. " \
  156. "Please make sure to use a syntax like this: " \
  157. "'parameter=argument'", \
  158. fginst->generic[i].par.s); \
  159. MY_PRINT_ERROR_MESSAGE(errMsg); \
  160. ret_act_v; \
  161. } \
  162. } \
  163. else \
  164. { \
  165. if (fginst->num_generic == 1 && \
  166. ((fginst->generic[(i)].type == LONG_PAR && \
  167. fginst->generic[(i)].par.l == -1) || \
  168. (fginst->generic[(i)].type == FLOAT_PAR && \
  169. fginst->generic[(i)].par.f == -1.0))) \
  170. break; \
  171. else \
  172. { \
  173. MY_PRINT_ERROR_MESSAGE("Generic parameter accepts " \
  174. "only string values!"); \
  175. ret_act_t; \
  176. } \
  177. } \
  178. }
  179. # ifdef _WIN32
  180. # include <windows.h>
  181. # endif
  182. /* define HALCON acquisition callback */
  183. # ifndef _WIN32
  184. # define __stdcall
  185. # endif
  186. typedef Herror(__stdcall* HAcqCallback)(void* AcqHandle, void* Context,
  187. void* UserContext);
  188. # if defined(__cplusplus)
  189. extern "C" {
  190. # endif
  191. # ifndef HCVERSION_H
  192. # ifndef _WIN32
  193. /* time */
  194. # if !defined(HE_TI_C6X)
  195. # if defined(__vxworks)
  196. # include <sys/times.h>
  197. # else
  198. # include <sys/time.h>
  199. # endif /* __vxworks */
  200. # else
  201. struct timezone
  202. {
  203. int tz_minuteswest; /* minutes W of Greenwich */
  204. int tz_dsttime; /* type of dst correction */
  205. };
  206. # if !defined(_B_TIME_H_)
  207. struct timeval
  208. {
  209. int tv_sec; /* seconds */
  210. int tv_usec; /* and microseconds */
  211. };
  212. # endif
  213. # endif /* ! HE_TI_C6X */
  214. # endif /* _WIN32 */
  215. # endif /* ifndef HCVERSION_H */
  216. /*****************************************************************************
  217. *
  218. * struct FGInstance
  219. *
  220. *****************************************************************************/
  221. typedef struct _FGInstance
  222. {
  223. struct _FGClass* fgclass; /* a pointer to the corresponding class */
  224. /* ----------------------- regular parameters --------------------------- */
  225. HIMGDIM horizontal_resolution, /* desired resolution delivered */
  226. vertical_resolution; /* by the board */
  227. HIMGDIM image_width, image_height; /* desired image size */
  228. HIMGDIM start_row, start_col; /* upper left corner */
  229. HINT field; /* even- or odd-field, full image mode */
  230. HINT bits_per_channel; /* color depth per pixel & channel */
  231. char color_space[MAX_STRING]; /* "gray", "rgb", "yuv", ... */
  232. float gain; /* for backwards compatibility only! */
  233. HBOOL external_trigger; /* trigger mode */
  234. char camera_type[MAX_STRING]; /* used camera type (fg-specific!) */
  235. char device[MAX_STRING]; /* device name */
  236. HINT port; /* port to use */
  237. HINT line_in; /* multiplexer input line */
  238. Hcpar* generic; /* generic parameter */
  239. HINT num_generic;
  240. /* ---------------------- miscellaneous parameters ---------------------- */
  241. INT4_8 mode; /* current operating mode */
  242. HIMGDIM width_max, height_max; /* maximum image size */
  243. HINT num_channels; /* number of image channels */
  244. HBOOL async_grab; /* TRUE <=> async grabbing engaged */
  245. Himage* image; /* image objects to grab into (aux.) */
  246. void* gen_pointer; /* generic pointer (auxiliary) */
  247. /* -------------------- external memory allocation ---------------------- */
  248. HBOOL halcon_malloc; /* TRUE <-> standard memory allocation */
  249. /* by HNewImage */
  250. HImageFreeProc clear_proc; /* pointer to specific clear function */
  251. /* (if halcon_malloc==FALSE) */
  252. } FGInstance;
  253. /*****************************************************************************
  254. *
  255. * struct FGClass
  256. *
  257. *****************************************************************************/
  258. typedef struct _FGClass
  259. {
  260. /* -------------------------- internal -------------------------------- */
  261. char name[MAX_STRING]; /* frame grabber name (interface module) */
  262. void* lib_handle; /* handle of interface library */
  263. HINT interface_version; /* current HALCON frame grabber */
  264. /* interface version */
  265. INT4 flags; /* interface flags */
  266. /* ------------------- properties / management ------------------------ */
  267. HBOOL available; /* supported for the current platform */
  268. HINT instances_num; /* current number instances (INTERNAL!) */
  269. HINT instances_max; /* maximum number of instances */
  270. FGInstance* instance[FG_MAX_INST]; /* list of instances (INTERNAL!) */
  271. /* ----------------- interface-specific functions --------------------- */
  272. FGInstance** (*OpenRequest)(Hproc_handle proc_id, FGInstance* fginst);
  273. Herror (*Open)(Hproc_handle proc_id, FGInstance* fginst);
  274. Herror (*Close)(Hproc_handle proc_id, FGInstance* fginst);
  275. Herror (*Grab)(Hproc_handle proc_id, FGInstance* fginst, Himage* image,
  276. HINT* num_image);
  277. Herror (*GrabStartAsync)(Hproc_handle proc_id, FGInstance* fginst,
  278. double maxDelay);
  279. Herror (*GrabAsync)(Hproc_handle proc_id, FGInstance* fginst,
  280. double maxDelay, Himage* image, HINT* num_image);
  281. Herror (*GrabData)(Hproc_handle proc_id, FGInstance* fginst, Himage** image,
  282. HINT** num_channel, HINT* num_image, Hrlregion*** region,
  283. HINT* num_region, Hcont*** cont, HINT* num_cont,
  284. Hcpar** data, HINT* num_data);
  285. Herror (*GrabDataAsync)(Hproc_handle proc_id, FGInstance* fginst,
  286. double maxDelay, Himage** image, HINT** num_channel,
  287. HINT* num_image, Hrlregion*** region,
  288. HINT* num_region, Hcont*** cont, HINT* num_cont,
  289. Hcpar** data, HINT* num_data);
  290. Herror (*Info)(Hproc_handle proc_id, HINT queryType, char** info,
  291. Hcpar** values, HINT* numValues);
  292. Herror (*SetParam)(Hproc_handle proc_id, FGInstance* fginst, char* param,
  293. Hcpar* value, HINT num);
  294. Herror (*GetParam)(Hproc_handle proc_id, FGInstance* fginst, char* param,
  295. Hcpar* value, HINT* num);
  296. Herror (*SetLut)(Hproc_handle proc_id, FGInstance* fginst, INT4_8* red,
  297. INT4_8* green, INT4_8* blue, HINT num);
  298. Herror (*GetLut)(Hproc_handle proc_id, FGInstance* fginst, INT4_8* red,
  299. INT4_8* green, INT4_8* blue, HINT* num);
  300. Herror (*SetCallback)(Hproc_handle proc_id, FGInstance* fginst,
  301. char* callback_type, HAcqCallback callback_function,
  302. void* user_context);
  303. Herror (*GetCallback)(Hproc_handle proc_id, FGInstance* fginst,
  304. char* callback_type, HAcqCallback* callback_function,
  305. void** user_context);
  306. /* -------------------------- default values -------------------------- */
  307. HIMGDIM horizontal_resolution, /* desired resolution delivered */
  308. vertical_resolution; /* by the board */
  309. HIMGDIM image_width, image_height; /* desired image size */
  310. HIMGDIM start_row, start_col; /* upper left corner */
  311. HINT field; /* even- or odd-field, full image mode */
  312. HINT bits_per_channel; /* color depth per pixel & channel */
  313. char color_space[MAX_STRING]; /* "gray", "rgb", "yuv", ... */
  314. float gain; /* for backwards compatibility only! */
  315. HBOOL external_trigger; /* trigger mode */
  316. char camera_type[MAX_STRING]; /* used camera type (fg-specific!) */
  317. char device[MAX_STRING]; /* device name */
  318. HINT port; /* port to use */
  319. HINT line_in; /* multiplexer input line */
  320. Hcpar* generic; /* generic parameter */
  321. HINT num_generic;
  322. /* ------------------------- miscellaneous ---------------------------- */
  323. void* reserved[FG_NUM_RESERVED];
  324. } FGClass;
  325. /*
  326. * Special framegrabber flags. To set the flags, the interface should export
  327. * the symbol FG_FLAGS_NAME, which must be an INT4. Note that if the interface
  328. * is openend using the HAddFgClass function, the flags cannot be set.
  329. *
  330. * The following flags are defined:
  331. *
  332. * FG_FLAG_THREAD_OPEN: if set, the interface is opened and closed from the
  333. * same thread.
  334. * FG_FLAG_THREAD_ALL: if set, all interface functions are called from the
  335. * same thread.
  336. */
  337. # define FG_FLAG_THREAD_OPEN (1 << 0)
  338. # define FG_FLAG_THREAD_ALL (FG_FLAG_THREAD_OPEN | (1 << 1))
  339. typedef Herror (*FG_INIT_FUNC)(Hproc_handle, FGClass*);
  340. # if defined(__cplusplus)
  341. }
  342. # endif
  343. # endif /* ifndef HC_NO_FRAMEGRABBER */
  344. #endif /* ifndef #ifndef CIOFRAMEGRAB_DEFINES_H */