CORE1.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /*****************************************************************************
  2. * CORE1.h
  3. *****************************************************************************
  4. *
  5. * Project: HALCON/libhalcon
  6. * Description: Mid level procedure interface
  7. *
  8. * (c) 1996-2022 by MVTec Software GmbH
  9. * www.mvtec.com
  10. *
  11. *****************************************************************************
  12. *
  13. *
  14. */
  15. #ifndef CORE1_H
  16. #define CORE1_H
  17. #include "hlib/DBNew.h" /* -> DBFreeProc */
  18. #if defined(__cplusplus)
  19. extern "C" {
  20. #endif
  21. /* HPAllocStringMem - allocate memory for StringMem */
  22. extern HLibExport Herror HPAllocStringMem(Hproc_handle proc_handle,
  23. size_t size);
  24. /* HFreeStringMem - give free memory of StringMem */
  25. extern HLibExport Herror HFreeStringMem(Hproc_handle proc_handle);
  26. /* HNoInpObj - returns true, if any input object parameter is empty */
  27. extern HLibExport Herror HNoInpObj(Hproc_handle proc_handle, bool* b);
  28. /* HPGetObj - get key of a input object */
  29. extern HLibExport Herror HPGetObj(Hproc_handle proc_handle, int par_num,
  30. INT4_8 obj_num, Hkey* key);
  31. /* HPGetOutpObj - get key of a output object */
  32. extern HLibExport Herror HPGetOutpObj(Hproc_handle proc_handle, int par_num,
  33. INT4_8 obj_num, Hkey* key);
  34. /* HPGetObjNum - get number of objects of input object parameter */
  35. extern HLibExport Herror HPGetObjNum(Hproc_handle proc_handle, int par_num,
  36. INT4_8* num);
  37. /* HPTestObj - test, whether key specifies a valid database object */
  38. extern HLibExport bool HPTestObj(Hkey obj);
  39. /* HPCountTuple - count number of managed data base objects */
  40. extern HLibExport Herror HPCountTuple(char* relation, INT4_8* num);
  41. /* HPGetComp - get key of a component of an object */
  42. extern HLibExport Herror HPGetComp(Hproc_handle proc_handle, Hkey obj_key,
  43. int comp, Hkey* key);
  44. /* HPGetFRL - get runlength code of a region (no copy; just pointer to data) */
  45. extern HLibExport Herror HPGetFRL(Hproc_handle proc_handle, Hkey rl_key,
  46. Hrlregion** region);
  47. /* HPGetFRL - get runlength code of a region (region is copied!) */
  48. extern HLibExport Herror HPGetRL(Hproc_handle proc_handle, Hkey rl_key,
  49. Hrlregion* rl);
  50. /* HPGetFDRL - get runlength code of a region (no copy; just pointer to data)*/
  51. extern HLibExport Herror HPGetFDRL(Hproc_handle proc_handle, Hkey obj_key,
  52. Hrlregion** rl);
  53. /* HPGetDRL - get chord coding of a region (region gets copied!) */
  54. extern HLibExport Herror HPGetDRL(Hproc_handle proc_handle, Hkey obj_key,
  55. Hrlregion* rl);
  56. /* HPGetURL - merge all regions of an object into a new one */
  57. extern HLibExport Herror HPGetURL(Hproc_handle proc_handle, int par_num,
  58. Hrlregion* region);
  59. /* HPGetURLLocal - merge all regions of an object into a new one */
  60. extern HLibExport Herror HPGetURLLocal(Hproc_handle proc_handle, int par_num,
  61. Hrlregion** region);
  62. /* HPGetCParNum - get number of values of input control parameter */
  63. extern HLibExport Herror HPGetCParNum(Hproc_handle proc_handle, int par_num,
  64. INT4_8* num);
  65. /* HPGetPPar - get array of pointers to value structures of inp. ctrl. par. */
  66. extern HLibExport Herror HPGetPPar(Hproc_handle proc_handle, int par_num,
  67. Hcpar* H_RESTRICT* val, INT4_8* num);
  68. /* HPGetPar - get values of input control parameter */
  69. extern HLibExport Herror HPGetPar(Hproc_handle proc_handle, int par_num,
  70. int kind_in, int* kind, Hpar Val[],
  71. INT4_8 min, INT4_8 max, INT4_8* num);
  72. /* HPGetCPar - get values of input control parameter */
  73. extern HLibExport Herror HPGetCPar(Hproc_handle proc_handle, int par_num,
  74. int kind_in, Hcpar Val[], INT4_8 min,
  75. INT4_8 max, INT4_8* num);
  76. /* HPPutPElem - store output control parameter values by reference */
  77. extern HLibExport Herror HPPutPElem(Hproc_handle proc_handle, int parnr,
  78. void* Val, INT4_8 num, int type);
  79. /* HPPutElem - store output control parameter values by copy */
  80. extern HLibExport Herror HPPutElem(Hproc_handle proc_handle, int parnr,
  81. void const* Val, INT4_8 num, int type);
  82. /* HPPutPar - store output control parameter values */
  83. extern HLibExport Herror HPPutPar(Hproc_handle proc_handle, int par_num,
  84. int kind, Hpar* Elem, INT4_8 num);
  85. /* HPPutPPar - store output control parameter values (by using pointers) */
  86. extern HLibExport Herror HPPutPPar(Hproc_handle proc_handle, int par_num,
  87. Hcpar* Val, INT4_8 num);
  88. /* HPPutCPar - store output control parameter values */
  89. extern HLibExport Herror HPPutCPar(Hproc_handle proc_handle, int par_num,
  90. Hcpar* Val, INT4_8 num);
  91. /* HPFreeAllParStrings - free all strings in parameter array */
  92. extern HLibExport Herror HPFreeAllParStrings(Hproc_handle proc_handle,
  93. Hcpar* par, INT4_8 num);
  94. /* HPFreeAllParHandles - free all handles in parameter array */
  95. extern HLibExport Herror HPFreeAllParHandles(Hproc_handle proc_handle,
  96. Hcpar* par, INT4_8 num);
  97. /* HPPutRL - copy region into region object, return its key */
  98. extern HLibExport Herror HPPutRL(Hproc_handle proc_handle, Hrlregion* region,
  99. Hkey* key);
  100. /* HPPutPRL - store region into region object, return its key */
  101. extern HLibExport Herror HPPutPRL(Hproc_handle proc_handle, Hrlregion** region,
  102. Hkey* key);
  103. /* HPPutDRL - copy region into component object and return its region
  104. * object key..*/
  105. extern HLibExport Herror HPPutDRL(Hproc_handle proc_handle, Hkey obj_key,
  106. Hrlregion* rl, Hkey* key);
  107. /* HPPutPRLComp - store region into component object and return its region
  108. * object key. */
  109. extern HLibExport Herror HPPutPRLComp(Hproc_handle proc_handle, Hkey obj_key,
  110. Hrlregion** reg, Hkey* key);
  111. /* HPPutRect - insert rectangular region in output object */
  112. extern HLibExport Herror HPPutRect(Hproc_handle proc_handle, Hkey obj,
  113. int width, int height);
  114. /* HPGetImage - fetch key of image object from database (including spy) */
  115. extern HLibExport Herror HPGetImage(Hproc_handle proc_handle, Hkey key,
  116. Himage* image);
  117. /* HP0GetImage - fetch key of image object from database (without spy) */
  118. extern HLibExport Herror HP0GetImage(Hproc_handle proc_handle, Hkey key,
  119. Himage* image);
  120. extern HLibExport Herror HPGetImageManip(Hproc_handle proc_handle, Hkey key,
  121. Himage* image);
  122. /* HPGetImage - fetch key of image object from database (including spy) */
  123. extern HLibExport Herror HPGetCDImage(Hproc_handle proc_handle, Hkey key,
  124. Himage* image);
  125. /* HP0GetImage - fetch key of image object from database (without spy) */
  126. extern HLibExport Herror HP0GetCDImage(Hproc_handle proc_handle, Hkey key,
  127. Himage* image);
  128. /* HPGetDImage - fetch gray value channel of image object (without key) */
  129. extern HLibExport Herror HPGetDImage(Hproc_handle proc_handle, Hkey obj_key,
  130. int comp, Himage* image);
  131. /* HPDelObj - delete an object */
  132. extern HLibExport Herror HPDelObj(Hproc_handle proc_handle, Hkey obj_key);
  133. /* HCrIObj - create new image object */
  134. extern HLibExport Herror HCrIObj(Hproc_handle proc_handle, Hkey* key);
  135. /* HPCrObj - create new image object and insert it into output object list */
  136. extern HLibExport Herror HPCrObj(Hproc_handle proc_handle, int par_num,
  137. Hkey* key);
  138. /* HPCopyIObj - copy image object */
  139. extern HLibExport Herror HPCopyIObj(Hproc_handle proc_handle, Hkey obj_key,
  140. Hkey* tuple);
  141. /* HPCopyObj - copy image object and insert it into output object list */
  142. extern HLibExport Herror HPCopyObj(Hproc_handle proc_handle, Hkey obj_key,
  143. int par_num, Hkey* key);
  144. /* HPPutImage - store image data as image object in database */
  145. extern HLibExport Herror HPPutImage(Hproc_handle proc_handle, Himage* image,
  146. bool copy, Hkey* key);
  147. /* HPDefObj - build up new object from already created objhects/components */
  148. extern HLibExport Herror HPDefObj(Hproc_handle proc_handle, Hkey obj_key,
  149. Hkey comp_key, int comp);
  150. /* HPPutDImage - store image data in database and assign it to object */
  151. extern HLibExport Herror HPPutDImage(Hproc_handle proc_handle, Hkey obj_key,
  152. int comp, Himage* image, bool copy,
  153. Hkey* key);
  154. /* HPNewRegion - create new output object with copied region */
  155. extern HLibExport Herror HPNewRegion(Hproc_handle proc_handle,
  156. Hrlregion* region);
  157. /* HPPushRegion - create new output object with defined region */
  158. extern HLibExport Herror HPPushRegion(Hproc_handle proc_handle,
  159. Hrlregion* region);
  160. /* HPPushGlobalRegion - create new output object with defined region */
  161. extern HLibExport Herror HPPushGlobalRegion(Hproc_handle proc_handle,
  162. Hrlregion* region);
  163. /* HPDupObj - duplicate object and insert it into output object list */
  164. extern HLibExport Herror HPDupObj(Hproc_handle proc_handle, INT4_8 obj_index);
  165. /* HPAllSegm - loop over all components of all objects of first input par. */
  166. extern HLibExport Herror HPAllSegm(Hproc_handle proc_handle, INT4_8 obj_index,
  167. Hrlregion** region, Himage* images,
  168. int max_channels);
  169. /* HPAllReg - loop over all region components of all obj.s of first inp. par.*/
  170. extern HLibExport Herror HPAllReg(Hproc_handle proc_handle, INT4_8 obj_index,
  171. Hrlregion** region);
  172. /* HPAllFilter - loop over all image obj.s of 1. inp. par. & create new obj.*/
  173. extern HLibExport Herror HPAllFilter(Hproc_handle proc_handle,
  174. INT4_8 obj_index, Hrlregion** region,
  175. Himage* images_in, Himage* images_out,
  176. int max_channels);
  177. /* HPAllFilter2 - loop over all image obj.s of 1. inp. par. & create new obj.*/
  178. extern HLibExport Herror HPAllFilter2(Hproc_handle proc_handle,
  179. INT4_8 obj_index, Hrlregion* region,
  180. Himage* images_in1, Himage* images_in2,
  181. Himage* images_out, int max_channels);
  182. /* HPNumOfChannels - check number of channels of input object */
  183. extern HLibExport Herror HPNumOfChannels(Hproc_handle proc_handle, int par_num,
  184. INT4_8 obj_num, int* chn_num);
  185. /* HPCheckSingleInputObject - check if it is a single input object */
  186. extern HLibExport Herror HPCheckSingleInputObject(Hproc_handle ph,
  187. INT4_8 obj_num);
  188. /* HPCrXLD - create XLD object */
  189. extern HLibExport Herror HPCrXLD(Hproc_handle proc_handle, int Par, void* XLD,
  190. int Type, Hkey* Uses, int NumUses,
  191. DBFreeProc free_proc, Hkey* key);
  192. /* HPGetXLD - fetch XLD object (in fact void **XLD) */
  193. extern HLibExport Herror HPGetXLD(Hproc_handle proc_handle, Hkey Key,
  194. int* Type, void* XLD, Hkey** Uses,
  195. int* NumUses);
  196. /* HPNumOfObjChannels - return number of defined channels of an object. */
  197. extern HLibExport Herror HPNumOfObjChannels(Hproc_handle proc_handle, Hkey obj,
  198. int* chn_num);
  199. /* HNumOfOutpObj - return number of objects of an output object parameter */
  200. extern HLibExport Herror HNumOfOutpObj(Hproc_handle proc_handle, int par_num,
  201. int* outp_objs);
  202. /* HGetInputKeyByPtr - get input object key containing ptr */
  203. extern HLibExport Herror HGetInputKeyByPtr(Hproc_handle proc_id, void* ptr,
  204. Hkey* key);
  205. /* HGetOutputKeyByPtr - get output object key containing ptr */
  206. extern HLibExport Herror HGetOutputKeyByPtr(Hproc_handle proc_id, void* ptr,
  207. Hkey* key);
  208. /* HGetInputRegionKeyByPtr - get input object key containing ptr */
  209. extern HLibExport Herror HGetInputRegionKeyByPtr(Hproc_handle proc_id,
  210. Hrlregion* ptr, Hkey* key);
  211. extern HLibExport Herror HPAllocOutpCtrl(Hproc_handle ph, int par, int type,
  212. INT4_8 length,
  213. void* H_RESTRICT* elem);
  214. #define HAllocOutpCtrl(ph, par, type, length, elem) \
  215. HPAllocOutpCtrl(ph, par, type, length, (void* H_RESTRICT*)elem)
  216. extern HLibExport Herror HFreeOutpCtrl(Hproc_handle ph, int par);
  217. extern HLibExport Herror HPReallocOutpCtrl(Hproc_handle ph, int par,
  218. int newtype, INT4_8 newlength,
  219. void* H_RESTRICT* elem);
  220. #define HReallocOutpCtrl(ph, par, type, newlength, elem) \
  221. HPReallocOutpCtrl(ph, par, type, newlength, (void* H_RESTRICT*)elem)
  222. extern HLibExport void HSetNumOutpCtrl(Hproc_handle ph, int par, INT4_8 num);
  223. extern HLibExport void HPGetPElem(Hproc_handle ph, int par,
  224. void const* H_RESTRICT* elem, INT4_8* num,
  225. int* type);
  226. /* definition of conversion flags to pass to convert slot of HPGetPElemx: */
  227. /* no conversion;do only consider original element types */
  228. #define CONV_NONE 0
  229. #define CONV_CAST 1 /* <INT4_8>=(INT4_8)<double>; <double>=(double)<INT4_8>*/
  230. #define CONV_IDNT 2 /* convert double->INT4_8 if double has no fraction */
  231. #define CONV_RND 3 /* <INT4_8>=(INT4_8)(<double>+0.5) */
  232. /* direct access input ctrl arrays */
  233. extern HLibExport Herror HPGetPElemL(Hproc_handle ph, int par, int convert,
  234. INT4_8 const* H_RESTRICT* elem,
  235. INT4_8* num);
  236. extern HLibExport Herror HPGetPElemD(Hproc_handle ph, int par, int convert,
  237. double const* H_RESTRICT* elem,
  238. INT4_8* num);
  239. extern HLibExport Herror HPGetPElemS(Hproc_handle ph, int par, int convert,
  240. char const* const* H_RESTRICT* elem,
  241. INT4_8* num);
  242. extern HLibExport Herror HPGetPElemH(Hproc_handle ph, int par,
  243. const HHandleInfo* expected_type,
  244. INT4_8 expected_num, void** elem,
  245. INT4_8* num, bool alloc);
  246. /* copy variant */
  247. extern HLibExport Herror HPGetElemL(Hproc_handle ph, int par, int convert,
  248. int memtype, INT4_8* H_RESTRICT* elem,
  249. INT4_8* num);
  250. extern HLibExport Herror HPGetElemD(Hproc_handle ph, int par, int convert,
  251. int memtype, double* H_RESTRICT* elem,
  252. INT4_8* num);
  253. extern HLibExport Herror HPGetElemS(Hproc_handle ph, int par, int convert,
  254. int memtype,
  255. char* H_RESTRICT* H_RESTRICT* elem,
  256. INT4_8* num);
  257. /* copy variant with preallocated arrays */
  258. extern HLibExport Herror HPCopyElemLFromTuple(Hctuple* H_RESTRICT ctuple,
  259. int convert,
  260. INT4_8* H_RESTRICT lelem,
  261. INT4_8* num);
  262. extern HLibExport Herror HPCopyElemL(Hproc_handle ph, int par, int convert,
  263. INT4_8* H_RESTRICT lelem, INT4_8* num);
  264. extern HLibExport Herror HPCopyElemD(Hproc_handle ph, int par, int convert,
  265. double* H_RESTRICT delem, INT4_8* num);
  266. extern HLibExport Herror HPCopyElemF(Hproc_handle ph, int par, int convert,
  267. float* H_RESTRICT delem, INT4_8* num);
  268. /* returning handles */
  269. extern HLibExport Herror HAllocOutputHandles(Hproc_handle ph, int parnr,
  270. Hphandle** elem, INT4_8 num,
  271. const HHandleInfo* type);
  272. extern HLibExport Herror HXAllocOutputHandle(Hproc_handle ph, int parnr,
  273. void*** elem,
  274. const HHandleInfo* type);
  275. extern Herror HcparToBool(Hcpar const* H_RESTRICT par_value, Herror err,
  276. bool* val);
  277. #if defined(__cplusplus)
  278. }
  279. #endif
  280. #endif