HComponentModel.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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_HCOMPONENTMODEL
  8. #define HCPP_HCOMPONENTMODEL
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a model for the component-based matching.
  12. class LIntExport HComponentModel : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HComponentModel():HHandle() {}
  17. // Copy constructor
  18. HComponentModel(const HComponentModel& source) : HHandle(source) {}
  19. // Copy constructor
  20. HComponentModel(const HHandle& handle);
  21. // Create HComponentModel from handle, taking ownership
  22. explicit HComponentModel(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 ('component_model')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. // Deep copy of all data represented by this object instance
  36. HComponentModel Clone() const;
  37. /*****************************************************************************
  38. * Operator-based class constructors
  39. *****************************************************************************/
  40. // read_component_model: Read a component model from a file.
  41. explicit HComponentModel(const HString& FileName);
  42. // read_component_model: Read a component model from a file.
  43. explicit HComponentModel(const char* FileName);
  44. #ifdef _WIN32
  45. // read_component_model: Read a component model from a file.
  46. explicit HComponentModel(const wchar_t* FileName);
  47. #endif
  48. // create_component_model: Prepare a component model for matching based on explicitly specified components and relations.
  49. explicit HComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, const HTuple& VariationRow, const HTuple& VariationColumn, const HTuple& VariationAngle, double AngleStart, double AngleExtent, const HTuple& ContrastLowComp, const HTuple& ContrastHighComp, const HTuple& MinSizeComp, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HString& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp, HTuple* RootRanking);
  50. // create_component_model: Prepare a component model for matching based on explicitly specified components and relations.
  51. explicit HComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, Hlong VariationRow, Hlong VariationColumn, double VariationAngle, double AngleStart, double AngleExtent, Hlong ContrastLowComp, Hlong ContrastHighComp, Hlong MinSizeComp, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp, Hlong* RootRanking);
  52. // create_component_model: Prepare a component model for matching based on explicitly specified components and relations.
  53. explicit HComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, Hlong VariationRow, Hlong VariationColumn, double VariationAngle, double AngleStart, double AngleExtent, Hlong ContrastLowComp, Hlong ContrastHighComp, Hlong MinSizeComp, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp, Hlong* RootRanking);
  54. #ifdef _WIN32
  55. // create_component_model: Prepare a component model for matching based on explicitly specified components and relations.
  56. explicit HComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, Hlong VariationRow, Hlong VariationColumn, double VariationAngle, double AngleStart, double AngleExtent, Hlong ContrastLowComp, Hlong ContrastHighComp, Hlong MinSizeComp, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const wchar_t* OptimizationComp, const wchar_t* MetricComp, const wchar_t* PregenerationComp, Hlong* RootRanking);
  57. #endif
  58. // create_trained_component_model: Prepare a component model for matching based on trained components.
  59. explicit HComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HString& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp, HTuple* RootRanking);
  60. // create_trained_component_model: Prepare a component model for matching based on trained components.
  61. explicit HComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp, Hlong* RootRanking);
  62. // create_trained_component_model: Prepare a component model for matching based on trained components.
  63. explicit HComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp, Hlong* RootRanking);
  64. #ifdef _WIN32
  65. // create_trained_component_model: Prepare a component model for matching based on trained components.
  66. explicit HComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const wchar_t* OptimizationComp, const wchar_t* MetricComp, const wchar_t* PregenerationComp, Hlong* RootRanking);
  67. #endif
  68. /***************************************************************************
  69. * Operators *
  70. ***************************************************************************/
  71. // Return the components of a found instance of a component model.
  72. HRegion GetFoundComponentModel(const HTuple& ModelStart, const HTuple& ModelEnd, const HTuple& RowComp, const HTuple& ColumnComp, const HTuple& AngleComp, const HTuple& ScoreComp, const HTuple& ModelComp, Hlong ModelMatch, const HString& MarkOrientation, HTuple* RowCompInst, HTuple* ColumnCompInst, HTuple* AngleCompInst, HTuple* ScoreCompInst) const;
  73. // Return the components of a found instance of a component model.
  74. HRegion GetFoundComponentModel(Hlong ModelStart, Hlong ModelEnd, double RowComp, double ColumnComp, double AngleComp, double ScoreComp, Hlong ModelComp, Hlong ModelMatch, const HString& MarkOrientation, double* RowCompInst, double* ColumnCompInst, double* AngleCompInst, double* ScoreCompInst) const;
  75. // Return the components of a found instance of a component model.
  76. HRegion GetFoundComponentModel(Hlong ModelStart, Hlong ModelEnd, double RowComp, double ColumnComp, double AngleComp, double ScoreComp, Hlong ModelComp, Hlong ModelMatch, const char* MarkOrientation, double* RowCompInst, double* ColumnCompInst, double* AngleCompInst, double* ScoreCompInst) const;
  77. #ifdef _WIN32
  78. // Return the components of a found instance of a component model.
  79. HRegion GetFoundComponentModel(Hlong ModelStart, Hlong ModelEnd, double RowComp, double ColumnComp, double AngleComp, double ScoreComp, Hlong ModelComp, Hlong ModelMatch, const wchar_t* MarkOrientation, double* RowCompInst, double* ColumnCompInst, double* AngleCompInst, double* ScoreCompInst) const;
  80. #endif
  81. // Find the best matches of a component model in an image.
  82. HTuple FindComponentModel(const HImage& Image, const HTuple& RootComponent, const HTuple& AngleStartRoot, const HTuple& AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& IfRootNotFound, const HString& IfComponentNotFound, const HString& PosePrediction, const HTuple& MinScoreComp, const HTuple& SubPixelComp, const HTuple& NumLevelsComp, const HTuple& GreedinessComp, HTuple* ModelEnd, HTuple* Score, HTuple* RowComp, HTuple* ColumnComp, HTuple* AngleComp, HTuple* ScoreComp, HTuple* ModelComp) const;
  83. // Find the best matches of a component model in an image.
  84. Hlong FindComponentModel(const HImage& Image, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const HString& IfRootNotFound, const HString& IfComponentNotFound, const HString& PosePrediction, double MinScoreComp, const HString& SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp) const;
  85. // Find the best matches of a component model in an image.
  86. Hlong FindComponentModel(const HImage& Image, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const char* IfRootNotFound, const char* IfComponentNotFound, const char* PosePrediction, double MinScoreComp, const char* SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp) const;
  87. #ifdef _WIN32
  88. // Find the best matches of a component model in an image.
  89. Hlong FindComponentModel(const HImage& Image, Hlong RootComponent, double AngleStartRoot, double AngleExtentRoot, double MinScore, Hlong NumMatches, double MaxOverlap, const wchar_t* IfRootNotFound, const wchar_t* IfComponentNotFound, const wchar_t* PosePrediction, double MinScoreComp, const wchar_t* SubPixelComp, Hlong NumLevelsComp, double GreedinessComp, Hlong* ModelEnd, double* Score, double* RowComp, double* ColumnComp, double* AngleComp, double* ScoreComp, Hlong* ModelComp) const;
  90. #endif
  91. // Free the memory of a component model.
  92. void ClearComponentModel() const;
  93. // Return the search tree of a component model.
  94. HRegion GetComponentModelTree(HRegion* Relations, const HTuple& RootComponent, const HTuple& Image, HTuple* StartNode, HTuple* EndNode, HTuple* Row, HTuple* Column, HTuple* Phi, HTuple* Length1, HTuple* Length2, HTuple* AngleStart, HTuple* AngleExtent) const;
  95. // Return the search tree of a component model.
  96. HRegion GetComponentModelTree(HRegion* Relations, Hlong RootComponent, const HString& Image, Hlong* StartNode, Hlong* EndNode, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent) const;
  97. // Return the search tree of a component model.
  98. HRegion GetComponentModelTree(HRegion* Relations, Hlong RootComponent, const char* Image, Hlong* StartNode, Hlong* EndNode, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent) const;
  99. #ifdef _WIN32
  100. // Return the search tree of a component model.
  101. HRegion GetComponentModelTree(HRegion* Relations, Hlong RootComponent, const wchar_t* Image, Hlong* StartNode, Hlong* EndNode, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent) const;
  102. #endif
  103. // Return the parameters of a component model.
  104. HTuple GetComponentModelParams(HTuple* RootRanking, HShapeModelArray* ShapeModelIDs) const;
  105. // Return the parameters of a component model.
  106. double GetComponentModelParams(Hlong* RootRanking, HShapeModel* ShapeModelIDs) const;
  107. // Deserialize a serialized component model.
  108. void DeserializeComponentModel(const HSerializedItem& SerializedItemHandle);
  109. // Serialize a component model.
  110. HSerializedItem SerializeComponentModel() const;
  111. // Read a component model from a file.
  112. void ReadComponentModel(const HString& FileName);
  113. // Read a component model from a file.
  114. void ReadComponentModel(const char* FileName);
  115. #ifdef _WIN32
  116. // Read a component model from a file.
  117. void ReadComponentModel(const wchar_t* FileName);
  118. #endif
  119. // Write a component model to a file.
  120. void WriteComponentModel(const HString& FileName) const;
  121. // Write a component model to a file.
  122. void WriteComponentModel(const char* FileName) const;
  123. #ifdef _WIN32
  124. // Write a component model to a file.
  125. void WriteComponentModel(const wchar_t* FileName) const;
  126. #endif
  127. // Prepare a component model for matching based on explicitly specified components and relations.
  128. HTuple CreateComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, const HTuple& VariationRow, const HTuple& VariationColumn, const HTuple& VariationAngle, double AngleStart, double AngleExtent, const HTuple& ContrastLowComp, const HTuple& ContrastHighComp, const HTuple& MinSizeComp, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HString& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp);
  129. // Prepare a component model for matching based on explicitly specified components and relations.
  130. Hlong CreateComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, Hlong VariationRow, Hlong VariationColumn, double VariationAngle, double AngleStart, double AngleExtent, Hlong ContrastLowComp, Hlong ContrastHighComp, Hlong MinSizeComp, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp);
  131. // Prepare a component model for matching based on explicitly specified components and relations.
  132. Hlong CreateComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, Hlong VariationRow, Hlong VariationColumn, double VariationAngle, double AngleStart, double AngleExtent, Hlong ContrastLowComp, Hlong ContrastHighComp, Hlong MinSizeComp, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp);
  133. #ifdef _WIN32
  134. // Prepare a component model for matching based on explicitly specified components and relations.
  135. Hlong CreateComponentModel(const HImage& ModelImage, const HRegion& ComponentRegions, Hlong VariationRow, Hlong VariationColumn, double VariationAngle, double AngleStart, double AngleExtent, Hlong ContrastLowComp, Hlong ContrastHighComp, Hlong MinSizeComp, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const wchar_t* OptimizationComp, const wchar_t* MetricComp, const wchar_t* PregenerationComp);
  136. #endif
  137. // Prepare a component model for matching based on trained components.
  138. HTuple CreateTrainedComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, const HTuple& MinContrastComp, const HTuple& MinScoreComp, const HTuple& NumLevelsComp, const HTuple& AngleStepComp, const HString& OptimizationComp, const HTuple& MetricComp, const HTuple& PregenerationComp);
  139. // Prepare a component model for matching based on trained components.
  140. Hlong CreateTrainedComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp);
  141. // Prepare a component model for matching based on trained components.
  142. Hlong CreateTrainedComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp);
  143. #ifdef _WIN32
  144. // Prepare a component model for matching based on trained components.
  145. Hlong CreateTrainedComponentModel(const HComponentTraining& ComponentTrainingID, double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const wchar_t* OptimizationComp, const wchar_t* MetricComp, const wchar_t* PregenerationComp);
  146. #endif
  147. };
  148. // forward declarations and types for internal array implementation
  149. template<class T> class HSmartPtr;
  150. template<class T> class HHandleBaseArrayRef;
  151. typedef HHandleBaseArrayRef<HComponentModel> HComponentModelArrayRef;
  152. typedef HSmartPtr< HComponentModelArrayRef > HComponentModelArrayPtr;
  153. // Represents multiple tool instances
  154. class LIntExport HComponentModelArray : public HHandleBaseArray
  155. {
  156. public:
  157. // Create empty array
  158. HComponentModelArray();
  159. // Create array from native array of tool instances
  160. HComponentModelArray(HComponentModel* classes, Hlong length);
  161. // Copy constructor
  162. HComponentModelArray(const HComponentModelArray &tool_array);
  163. // Destructor
  164. virtual ~HComponentModelArray();
  165. // Assignment operator
  166. HComponentModelArray &operator=(const HComponentModelArray &tool_array);
  167. // Clears array and all tool instances
  168. virtual void Clear();
  169. // Get array of native tool instances
  170. const HComponentModel* Tools() const;
  171. // Get number of tools
  172. virtual Hlong Length() const;
  173. // Create tool array from tuple of handles
  174. virtual void SetFromTuple(const HTuple& handles);
  175. // Get tuple of handles for tool array
  176. virtual HTuple ConvertToTuple() const;
  177. protected:
  178. // Smart pointer to internal data container
  179. HComponentModelArrayPtr *mArrayPtr;
  180. };
  181. }
  182. #endif