HNCCModel.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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_HNCCMODEL
  8. #define HCPP_HNCCMODEL
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of an NCC model for matching.
  12. class LIntExport HNCCModel : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HNCCModel():HHandle() {}
  17. // Copy constructor
  18. HNCCModel(const HNCCModel& source) : HHandle(source) {}
  19. // Copy constructor
  20. HNCCModel(const HHandle& handle);
  21. // Create HNCCModel from handle, taking ownership
  22. explicit HNCCModel(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 ('ncc_model')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. // Deep copy of all data represented by this object instance
  36. HNCCModel Clone() const;
  37. /*****************************************************************************
  38. * Operator-based class constructors
  39. *****************************************************************************/
  40. // read_ncc_model: Read an NCC model from a file.
  41. explicit HNCCModel(const HString& FileName);
  42. // read_ncc_model: Read an NCC model from a file.
  43. explicit HNCCModel(const char* FileName);
  44. #ifdef _WIN32
  45. // read_ncc_model: Read an NCC model from a file.
  46. explicit HNCCModel(const wchar_t* FileName);
  47. #endif
  48. // create_ncc_model: Prepare an NCC model for matching.
  49. explicit HNCCModel(const HImage& Template, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, const HString& Metric);
  50. // create_ncc_model: Prepare an NCC model for matching.
  51. explicit HNCCModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Metric);
  52. // create_ncc_model: Prepare an NCC model for matching.
  53. explicit HNCCModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Metric);
  54. #ifdef _WIN32
  55. // create_ncc_model: Prepare an NCC model for matching.
  56. explicit HNCCModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Metric);
  57. #endif
  58. /***************************************************************************
  59. * Operators *
  60. ***************************************************************************/
  61. // Free the memory of an NCC model.
  62. void ClearNccModel() const;
  63. // Deserialize an NCC model.
  64. void DeserializeNccModel(const HSerializedItem& SerializedItemHandle);
  65. // Serialize an NCC model.
  66. HSerializedItem SerializeNccModel() const;
  67. // Read an NCC model from a file.
  68. void ReadNccModel(const HString& FileName);
  69. // Read an NCC model from a file.
  70. void ReadNccModel(const char* FileName);
  71. #ifdef _WIN32
  72. // Read an NCC model from a file.
  73. void ReadNccModel(const wchar_t* FileName);
  74. #endif
  75. // Write an NCC model to a file.
  76. void WriteNccModel(const HString& FileName) const;
  77. // Write an NCC model to a file.
  78. void WriteNccModel(const char* FileName) const;
  79. #ifdef _WIN32
  80. // Write an NCC model to a file.
  81. void WriteNccModel(const wchar_t* FileName) const;
  82. #endif
  83. // Determine the parameters of an NCC model.
  84. static HTuple DetermineNccModelParams(const HImage& Template, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HString& Metric, const HTuple& Parameters, HTuple* ParameterValue);
  85. // Determine the parameters of an NCC model.
  86. static HTuple DetermineNccModelParams(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, const HString& Metric, const HString& Parameters, HTuple* ParameterValue);
  87. // Determine the parameters of an NCC model.
  88. static HTuple DetermineNccModelParams(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, const char* Metric, const char* Parameters, HTuple* ParameterValue);
  89. #ifdef _WIN32
  90. // Determine the parameters of an NCC model.
  91. static HTuple DetermineNccModelParams(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, const wchar_t* Metric, const wchar_t* Parameters, HTuple* ParameterValue);
  92. #endif
  93. // Return the parameters of an NCC model.
  94. Hlong GetNccModelParams(double* AngleStart, double* AngleExtent, double* AngleStep, HString* Metric) const;
  95. // Return the origin (reference point) of an NCC model.
  96. void GetNccModelOrigin(double* Row, double* Column) const;
  97. // Set the origin (reference point) of an NCC model.
  98. void SetNccModelOrigin(double Row, double Column) const;
  99. // Find the best matches of an NCC model in an image.
  100. void FindNccModel(const HImage& Image, double AngleStart, double AngleExtent, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& SubPixel, const HTuple& NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score) const;
  101. // Find the best matches of an NCC model in an image.
  102. void FindNccModel(const HImage& Image, double AngleStart, double AngleExtent, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& SubPixel, Hlong NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score) const;
  103. // Find the best matches of an NCC model in an image.
  104. void FindNccModel(const HImage& Image, double AngleStart, double AngleExtent, double MinScore, Hlong NumMatches, double MaxOverlap, const char* SubPixel, Hlong NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score) const;
  105. #ifdef _WIN32
  106. // Find the best matches of an NCC model in an image.
  107. void FindNccModel(const HImage& Image, double AngleStart, double AngleExtent, double MinScore, Hlong NumMatches, double MaxOverlap, const wchar_t* SubPixel, Hlong NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score) const;
  108. #endif
  109. // Set selected parameters of the NCC model.
  110. void SetNccModelParam(const HTuple& GenParamName, const HTuple& GenParamValue) const;
  111. // Prepare an NCC model for matching.
  112. void CreateNccModel(const HImage& Template, const HTuple& NumLevels, double AngleStart, double AngleExtent, const HTuple& AngleStep, const HString& Metric);
  113. // Prepare an NCC model for matching.
  114. void CreateNccModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const HString& Metric);
  115. // Prepare an NCC model for matching.
  116. void CreateNccModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const char* Metric);
  117. #ifdef _WIN32
  118. // Prepare an NCC model for matching.
  119. void CreateNccModel(const HImage& Template, Hlong NumLevels, double AngleStart, double AngleExtent, double AngleStep, const wchar_t* Metric);
  120. #endif
  121. // Find the best matches of multiple NCC models.
  122. static void FindNccModels(const HImage& Image, const HNCCModelArray& ModelIDs, const HTuple& AngleStart, const HTuple& AngleExtent, const HTuple& MinScore, const HTuple& NumMatches, const HTuple& MaxOverlap, const HTuple& SubPixel, const HTuple& NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score, HTuple* Model);
  123. // Find the best matches of multiple NCC models.
  124. void FindNccModels(const HImage& Image, double AngleStart, double AngleExtent, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& SubPixel, Hlong NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score, HTuple* Model) const;
  125. // Find the best matches of multiple NCC models.
  126. void FindNccModels(const HImage& Image, double AngleStart, double AngleExtent, double MinScore, Hlong NumMatches, double MaxOverlap, const char* SubPixel, Hlong NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score, HTuple* Model) const;
  127. #ifdef _WIN32
  128. // Find the best matches of multiple NCC models.
  129. void FindNccModels(const HImage& Image, double AngleStart, double AngleExtent, double MinScore, Hlong NumMatches, double MaxOverlap, const wchar_t* SubPixel, Hlong NumLevels, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score, HTuple* Model) const;
  130. #endif
  131. // Return the region used to create an NCC model.
  132. HRegion GetNccModelRegion() const;
  133. };
  134. // forward declarations and types for internal array implementation
  135. template<class T> class HSmartPtr;
  136. template<class T> class HHandleBaseArrayRef;
  137. typedef HHandleBaseArrayRef<HNCCModel> HNCCModelArrayRef;
  138. typedef HSmartPtr< HNCCModelArrayRef > HNCCModelArrayPtr;
  139. // Represents multiple tool instances
  140. class LIntExport HNCCModelArray : public HHandleBaseArray
  141. {
  142. public:
  143. // Create empty array
  144. HNCCModelArray();
  145. // Create array from native array of tool instances
  146. HNCCModelArray(HNCCModel* classes, Hlong length);
  147. // Copy constructor
  148. HNCCModelArray(const HNCCModelArray &tool_array);
  149. // Destructor
  150. virtual ~HNCCModelArray();
  151. // Assignment operator
  152. HNCCModelArray &operator=(const HNCCModelArray &tool_array);
  153. // Clears array and all tool instances
  154. virtual void Clear();
  155. // Get array of native tool instances
  156. const HNCCModel* Tools() const;
  157. // Get number of tools
  158. virtual Hlong Length() const;
  159. // Create tool array from tuple of handles
  160. virtual void SetFromTuple(const HTuple& handles);
  161. // Get tuple of handles for tool array
  162. virtual HTuple ConvertToTuple() const;
  163. protected:
  164. // Smart pointer to internal data container
  165. HNCCModelArrayPtr *mArrayPtr;
  166. };
  167. }
  168. #endif