HTemplate.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /***********************************************************
  2. * File generated by the HALCON-Compiler hcomp version 20.11
  3. * Usage: Interface to C++
  4. *
  5. * Software by: MVTec Software GmbH, www.mvtec.com
  6. ***********************************************************/
  7. #ifndef HCPP_HTEMPLATE
  8. #define HCPP_HTEMPLATE
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a template for gray value matching.
  12. class LIntExport HTemplate : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HTemplate():HHandle() {}
  17. // Copy constructor
  18. HTemplate(const HTemplate& source) : HHandle(source) {}
  19. // Copy constructor
  20. HTemplate(const HHandle& handle);
  21. // Create HTemplate from handle, taking ownership
  22. explicit HTemplate(Hlong handle);
  23. bool operator==(const HHandle& obj) const
  24. {
  25. return HHandleBase::operator==(obj);
  26. }
  27. bool operator!=(const HHandle& obj) const
  28. {
  29. return HHandleBase::operator!=(obj);
  30. }
  31. protected:
  32. // Verify matching semantic type ('template')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. // Deep copy of all data represented by this object instance
  36. HTemplate Clone() const;
  37. /*****************************************************************************
  38. * Operator-based class constructors
  39. *****************************************************************************/
  40. // create_template_rot: Preparing a pattern for template matching with rotation.
  41. explicit HTemplate(const HImage& Template, Hlong NumLevel, double AngleStart, double AngleExtend, double AngleStep, const HString& Optimize, const HString& GrayValues);
  42. // create_template_rot: Preparing a pattern for template matching with rotation.
  43. explicit HTemplate(const HImage& Template, Hlong NumLevel, double AngleStart, double AngleExtend, double AngleStep, const char* Optimize, const char* GrayValues);
  44. #ifdef _WIN32
  45. // create_template_rot: Preparing a pattern for template matching with rotation.
  46. explicit HTemplate(const HImage& Template, Hlong NumLevel, double AngleStart, double AngleExtend, double AngleStep, const wchar_t* Optimize, const wchar_t* GrayValues);
  47. #endif
  48. // create_template: Preparing a pattern for template matching.
  49. explicit HTemplate(const HImage& Template, Hlong FirstError, Hlong NumLevel, const HString& Optimize, const HString& GrayValues);
  50. // create_template: Preparing a pattern for template matching.
  51. explicit HTemplate(const HImage& Template, Hlong FirstError, Hlong NumLevel, const char* Optimize, const char* GrayValues);
  52. #ifdef _WIN32
  53. // create_template: Preparing a pattern for template matching.
  54. explicit HTemplate(const HImage& Template, Hlong FirstError, Hlong NumLevel, const wchar_t* Optimize, const wchar_t* GrayValues);
  55. #endif
  56. // read_template: Reading a template from file.
  57. explicit HTemplate(const HString& FileName);
  58. // read_template: Reading a template from file.
  59. explicit HTemplate(const char* FileName);
  60. #ifdef _WIN32
  61. // read_template: Reading a template from file.
  62. explicit HTemplate(const wchar_t* FileName);
  63. #endif
  64. /***************************************************************************
  65. * Operators *
  66. ***************************************************************************/
  67. // Preparing a pattern for template matching with rotation.
  68. void CreateTemplateRot(const HImage& Template, Hlong NumLevel, double AngleStart, double AngleExtend, double AngleStep, const HString& Optimize, const HString& GrayValues);
  69. // Preparing a pattern for template matching with rotation.
  70. void CreateTemplateRot(const HImage& Template, Hlong NumLevel, double AngleStart, double AngleExtend, double AngleStep, const char* Optimize, const char* GrayValues);
  71. #ifdef _WIN32
  72. // Preparing a pattern for template matching with rotation.
  73. void CreateTemplateRot(const HImage& Template, Hlong NumLevel, double AngleStart, double AngleExtend, double AngleStep, const wchar_t* Optimize, const wchar_t* GrayValues);
  74. #endif
  75. // Preparing a pattern for template matching.
  76. void CreateTemplate(const HImage& Template, Hlong FirstError, Hlong NumLevel, const HString& Optimize, const HString& GrayValues);
  77. // Preparing a pattern for template matching.
  78. void CreateTemplate(const HImage& Template, Hlong FirstError, Hlong NumLevel, const char* Optimize, const char* GrayValues);
  79. #ifdef _WIN32
  80. // Preparing a pattern for template matching.
  81. void CreateTemplate(const HImage& Template, Hlong FirstError, Hlong NumLevel, const wchar_t* Optimize, const wchar_t* GrayValues);
  82. #endif
  83. // Serialize a template.
  84. HSerializedItem SerializeTemplate() const;
  85. // Deserialize a serialized template.
  86. void DeserializeTemplate(const HSerializedItem& SerializedItemHandle);
  87. // Writing a template to file.
  88. void WriteTemplate(const HString& FileName) const;
  89. // Writing a template to file.
  90. void WriteTemplate(const char* FileName) const;
  91. #ifdef _WIN32
  92. // Writing a template to file.
  93. void WriteTemplate(const wchar_t* FileName) const;
  94. #endif
  95. // Reading a template from file.
  96. void ReadTemplate(const HString& FileName);
  97. // Reading a template from file.
  98. void ReadTemplate(const char* FileName);
  99. #ifdef _WIN32
  100. // Reading a template from file.
  101. void ReadTemplate(const wchar_t* FileName);
  102. #endif
  103. // Deallocation of the memory of a template.
  104. void ClearTemplate() const;
  105. // Gray value offset for template.
  106. void SetOffsetTemplate(Hlong GrayOffset) const;
  107. // Define reference position for a matching template.
  108. void SetReferenceTemplate(double Row, double Column) const;
  109. // Adapting a template to the size of an image.
  110. void AdaptTemplate(const HImage& Image) const;
  111. // Searching all good gray value matches in a pyramid.
  112. HRegion FastMatchMg(const HImage& Image, double MaxError, const HTuple& NumLevel) const;
  113. // Searching all good gray value matches in a pyramid.
  114. HRegion FastMatchMg(const HImage& Image, double MaxError, Hlong NumLevel) const;
  115. // Searching the best gray value matches in a pre generated pyramid.
  116. void BestMatchPreMg(const HImage& ImagePyramid, double MaxError, const HString& SubPixel, Hlong NumLevels, const HTuple& WhichLevels, double* Row, double* Column, double* Error) const;
  117. // Searching the best gray value matches in a pre generated pyramid.
  118. void BestMatchPreMg(const HImage& ImagePyramid, double MaxError, const HString& SubPixel, Hlong NumLevels, Hlong WhichLevels, double* Row, double* Column, double* Error) const;
  119. // Searching the best gray value matches in a pre generated pyramid.
  120. void BestMatchPreMg(const HImage& ImagePyramid, double MaxError, const char* SubPixel, Hlong NumLevels, Hlong WhichLevels, double* Row, double* Column, double* Error) const;
  121. #ifdef _WIN32
  122. // Searching the best gray value matches in a pre generated pyramid.
  123. void BestMatchPreMg(const HImage& ImagePyramid, double MaxError, const wchar_t* SubPixel, Hlong NumLevels, Hlong WhichLevels, double* Row, double* Column, double* Error) const;
  124. #endif
  125. // Searching the best gray value matches in a pyramid.
  126. void BestMatchMg(const HImage& Image, double MaxError, const HString& SubPixel, Hlong NumLevels, const HTuple& WhichLevels, double* Row, double* Column, double* Error) const;
  127. // Searching the best gray value matches in a pyramid.
  128. void BestMatchMg(const HImage& Image, double MaxError, const HString& SubPixel, Hlong NumLevels, Hlong WhichLevels, double* Row, double* Column, double* Error) const;
  129. // Searching the best gray value matches in a pyramid.
  130. void BestMatchMg(const HImage& Image, double MaxError, const char* SubPixel, Hlong NumLevels, Hlong WhichLevels, double* Row, double* Column, double* Error) const;
  131. #ifdef _WIN32
  132. // Searching the best gray value matches in a pyramid.
  133. void BestMatchMg(const HImage& Image, double MaxError, const wchar_t* SubPixel, Hlong NumLevels, Hlong WhichLevels, double* Row, double* Column, double* Error) const;
  134. #endif
  135. // Searching all good matches of a template and an image.
  136. HRegion FastMatch(const HImage& Image, double MaxError) const;
  137. // Searching the best matching of a template and a pyramid with rotation.
  138. void BestMatchRotMg(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const HString& SubPixel, Hlong NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Error) const;
  139. // Searching the best matching of a template and a pyramid with rotation.
  140. void BestMatchRotMg(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const HString& SubPixel, Hlong NumLevels, double* Row, double* Column, double* Angle, double* Error) const;
  141. // Searching the best matching of a template and a pyramid with rotation.
  142. void BestMatchRotMg(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const char* SubPixel, Hlong NumLevels, double* Row, double* Column, double* Angle, double* Error) const;
  143. #ifdef _WIN32
  144. // Searching the best matching of a template and a pyramid with rotation.
  145. void BestMatchRotMg(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const wchar_t* SubPixel, Hlong NumLevels, double* Row, double* Column, double* Angle, double* Error) const;
  146. #endif
  147. // Searching the best matching of a template and an image with rotation.
  148. void BestMatchRot(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const HString& SubPixel, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Error) const;
  149. // Searching the best matching of a template and an image with rotation.
  150. void BestMatchRot(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const HString& SubPixel, double* Row, double* Column, double* Angle, double* Error) const;
  151. // Searching the best matching of a template and an image with rotation.
  152. void BestMatchRot(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const char* SubPixel, double* Row, double* Column, double* Angle, double* Error) const;
  153. #ifdef _WIN32
  154. // Searching the best matching of a template and an image with rotation.
  155. void BestMatchRot(const HImage& Image, double AngleStart, double AngleExtend, double MaxError, const wchar_t* SubPixel, double* Row, double* Column, double* Angle, double* Error) const;
  156. #endif
  157. // Searching the best matching of a template and an image.
  158. void BestMatch(const HImage& Image, double MaxError, const HString& SubPixel, HTuple* Row, HTuple* Column, HTuple* Error) const;
  159. // Searching the best matching of a template and an image.
  160. void BestMatch(const HImage& Image, double MaxError, const HString& SubPixel, double* Row, double* Column, double* Error) const;
  161. // Searching the best matching of a template and an image.
  162. void BestMatch(const HImage& Image, double MaxError, const char* SubPixel, double* Row, double* Column, double* Error) const;
  163. #ifdef _WIN32
  164. // Searching the best matching of a template and an image.
  165. void BestMatch(const HImage& Image, double MaxError, const wchar_t* SubPixel, double* Row, double* Column, double* Error) const;
  166. #endif
  167. };
  168. // forward declarations and types for internal array implementation
  169. template<class T> class HSmartPtr;
  170. template<class T> class HHandleBaseArrayRef;
  171. typedef HHandleBaseArrayRef<HTemplate> HTemplateArrayRef;
  172. typedef HSmartPtr< HTemplateArrayRef > HTemplateArrayPtr;
  173. // Represents multiple tool instances
  174. class LIntExport HTemplateArray : public HHandleBaseArray
  175. {
  176. public:
  177. // Create empty array
  178. HTemplateArray();
  179. // Create array from native array of tool instances
  180. HTemplateArray(HTemplate* classes, Hlong length);
  181. // Copy constructor
  182. HTemplateArray(const HTemplateArray &tool_array);
  183. // Destructor
  184. virtual ~HTemplateArray();
  185. // Assignment operator
  186. HTemplateArray &operator=(const HTemplateArray &tool_array);
  187. // Clears array and all tool instances
  188. virtual void Clear();
  189. // Get array of native tool instances
  190. const HTemplate* Tools() const;
  191. // Get number of tools
  192. virtual Hlong Length() const;
  193. // Create tool array from tuple of handles
  194. virtual void SetFromTuple(const HTuple& handles);
  195. // Get tuple of handles for tool array
  196. virtual HTuple ConvertToTuple() const;
  197. protected:
  198. // Smart pointer to internal data container
  199. HTemplateArrayPtr *mArrayPtr;
  200. };
  201. }
  202. #endif