CORE1.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /*****************************************************************************
  2. * CORE1.h
  3. *****************************************************************************
  4. *
  5. * Project: HALCON/libhalcon
  6. * Description: Mid level procedure interface
  7. *
  8. * (c) 1996-2020 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, HBOOL* b);
  28. /* HPGetObj - get key of a input object */
  29. extern HLibExport Herror HPGetObj(Hproc_handle proc_handle, HINT 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, HINT 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, HINT par_num,
  36. INT4_8* num);
  37. /* HPTestObj - test, whether key specifies a valid database object */
  38. extern HLibExport HBOOL 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. HINT 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, HINT 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, HINT par_num,
  61. Hrlregion** region);
  62. /* HPGetCParNum - get number of values of input control parameter */
  63. extern HLibExport Herror HPGetCParNum(Hproc_handle proc_handle, HINT 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, HINT 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, HINT par_num,
  70. HINT kind_in, HINT* 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, HINT par_num,
  74. HINT 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, HINT parnr,
  78. void* Val, INT4_8 num, HINT type);
  79. /* HPPutElem - store output control parameter values by copy */
  80. extern HLibExport Herror HPPutElem(Hproc_handle proc_handle, HINT parnr,
  81. void const* Val, INT4_8 num, HINT type);
  82. /* HPPutPar - store output control parameter values */
  83. extern HLibExport Herror HPPutPar(Hproc_handle proc_handle, HINT par_num,
  84. HINT 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, HINT par_num,
  87. Hcpar* Val, INT4_8 num);
  88. /* HPPutCPar - store output control parameter values */
  89. extern HLibExport Herror HPPutCPar(Hproc_handle proc_handle, HINT 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. HINT width, HINT 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. HINT 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, HINT 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. HINT 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. HBOOL 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, HINT 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. HINT comp, Himage* image, HBOOL 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. HINT 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. HINT 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, HINT max_channels);
  182. /* HPNumOfChannels - check number of channels of input object */
  183. extern HLibExport Herror HPNumOfChannels(Hproc_handle proc_handle,
  184. HINT par_num, INT4_8 obj_num,
  185. HINT* chn_num);
  186. /* HPCheckSingleInputObject - check if it is a single input object */
  187. extern HLibExport Herror HPCheckSingleInputObject(Hproc_handle ph,
  188. INT4_8 obj_num);
  189. /* HPCrXLD - create XLD object */
  190. extern HLibExport Herror HPCrXLD(Hproc_handle proc_handle, HINT Par, void* XLD,
  191. HINT Type, Hkey* Uses, HINT NumUses,
  192. DBFreeProc free_proc, Hkey* key);
  193. /* HPGetXLD - fetch XLD object (in fact void **XLD) */
  194. extern HLibExport Herror HPGetXLD(Hproc_handle proc_handle, Hkey Key,
  195. HINT* Type, void* XLD, Hkey** Uses,
  196. HINT* NumUses);
  197. /* HPNumOfObjChannels - return number of defined channels of an object. */
  198. extern HLibExport Herror HPNumOfObjChannels(Hproc_handle proc_handle, Hkey obj,
  199. HINT* chn_num);
  200. /* HNumOfOutpObj - return number of objects of an output object parameter */
  201. extern HLibExport Herror HNumOfOutpObj(Hproc_handle proc_handle, HINT par_num,
  202. HINT* outp_objs);
  203. /* HGetInputKeyByPtr - get input object key containing ptr */
  204. extern HLibExport Herror HGetInputKeyByPtr(Hproc_handle proc_id, void* ptr,
  205. Hkey* key);
  206. /* HGetOutputKeyByPtr - get output object key containing ptr */
  207. extern HLibExport Herror HGetOutputKeyByPtr(Hproc_handle proc_id, void* ptr,
  208. Hkey* key);
  209. /* HGetInputRegionKeyByPtr - get input object key containing ptr */
  210. extern HLibExport Herror HGetInputRegionKeyByPtr(Hproc_handle proc_id,
  211. Hrlregion* ptr, Hkey* key);
  212. extern HLibExport Herror HPAllocOutpCtrl(Hproc_handle ph, HINT par, HINT type,
  213. INT4_8 length,
  214. void* H_RESTRICT* elem);
  215. #define HAllocOutpCtrl(ph, par, type, length, elem) \
  216. HPAllocOutpCtrl(ph, par, type, length, (void* H_RESTRICT*)elem)
  217. extern HLibExport Herror HFreeOutpCtrl(Hproc_handle ph, HINT par);
  218. extern HLibExport Herror HPReallocOutpCtrl(Hproc_handle ph, HINT par,
  219. HINT newtype, INT4_8 newlength,
  220. void* H_RESTRICT* elem);
  221. #define HReallocOutpCtrl(ph, par, type, newlength, elem) \
  222. HPReallocOutpCtrl(ph, par, type, newlength, (void* H_RESTRICT*)elem)
  223. extern HLibExport void HSetNumOutpCtrl(Hproc_handle ph, HINT par, INT4_8 num);
  224. extern HLibExport void HPGetPElem(Hproc_handle ph, HINT par,
  225. void const* H_RESTRICT* elem, INT4_8* num,
  226. HINT* type);
  227. /* definition of conversion flags to pass to convert slot of HPGetPElemx: */
  228. /* no conversion;do only consider original element types */
  229. #define CONV_NONE 0
  230. #define CONV_CAST 1 /* <INT4_8>=(INT4_8)<double>; <double>=(double)<INT4_8>*/
  231. #define CONV_IDNT 2 /* convert double->INT4_8 if double has no fraction */
  232. #define CONV_RND 3 /* <INT4_8>=(INT4_8)(<double>+0.5) */
  233. /* direct access input ctrl arrays */
  234. extern HLibExport Herror HPGetPElemL(Hproc_handle ph, HINT par, HINT convert,
  235. INT4_8 const* H_RESTRICT* elem,
  236. INT4_8* num);
  237. extern HLibExport Herror HPGetPElemD(Hproc_handle ph, HINT par, HINT convert,
  238. double const* H_RESTRICT* elem,
  239. INT4_8* num);
  240. extern HLibExport Herror HPGetPElemS(Hproc_handle ph, HINT par, HINT convert,
  241. char const* const* H_RESTRICT* elem,
  242. INT4_8* num);
  243. extern HLibExport Herror HPGetPElemH(Hproc_handle ph, HINT par,
  244. const HHandleInfo* expected_type,
  245. INT4_8 expected_num, void** elem,
  246. INT4_8* num, HBOOL alloc);
  247. /* copy variant */
  248. extern HLibExport Herror HPGetElemL(Hproc_handle ph, HINT par, HINT convert,
  249. HINT memtype, INT4_8* H_RESTRICT* elem,
  250. INT4_8* num);
  251. extern HLibExport Herror HPGetElemD(Hproc_handle ph, HINT par, HINT convert,
  252. HINT memtype, double* H_RESTRICT* elem,
  253. INT4_8* num);
  254. extern HLibExport Herror HPGetElemS(Hproc_handle ph, HINT par, HINT convert,
  255. HINT memtype,
  256. char* H_RESTRICT* H_RESTRICT* elem,
  257. INT4_8* num);
  258. /* copy variant with preallocated arrays */
  259. extern HLibExport Herror HPCopyElemL(Hproc_handle ph, HINT par, HINT convert,
  260. INT4_8* H_RESTRICT lelem, INT4_8* num);
  261. extern HLibExport Herror HPCopyElemD(Hproc_handle ph, HINT par, HINT convert,
  262. double* H_RESTRICT delem, INT4_8* num);
  263. extern HLibExport Herror HPCopyElemF(Hproc_handle ph, HINT par, HINT convert,
  264. float* H_RESTRICT delem, INT4_8* num);
  265. /* returning handles */
  266. extern HLibExport Herror HAllocOutputHandles(Hproc_handle ph, HINT parnr,
  267. Hphandle** elem, INT4_8 num,
  268. const HHandleInfo* type);
  269. extern HLibExport Herror HXAllocOutputHandle(Hproc_handle ph, HINT parnr,
  270. void*** elem,
  271. const HHandleInfo* type);
  272. extern Herror HcparToBool(Hcpar const* H_RESTRICT par_value, Herror err,
  273. HBOOL* val);
  274. #if defined(__cplusplus)
  275. }
  276. #endif
  277. #endif