HComponentTraining.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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_HCOMPONENTTRAINING
  8. #define HCPP_HCOMPONENTTRAINING
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a training result for the component-based matching.
  12. class LIntExport HComponentTraining : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HComponentTraining():HHandle() {}
  17. // Copy constructor
  18. HComponentTraining(const HComponentTraining& source) : HHandle(source) {}
  19. // Copy constructor
  20. HComponentTraining(const HHandle& handle);
  21. // Create HComponentTraining from handle, taking ownership
  22. explicit HComponentTraining(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_training')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. // Deep copy of all data represented by this object instance
  36. HComponentTraining Clone() const;
  37. /*****************************************************************************
  38. * Operator-based class constructors
  39. *****************************************************************************/
  40. // train_model_components: Train components and relations for the component-based matching.
  41. explicit HComponentTraining(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, HRegion* ModelComponents, const HTuple& ContrastLow, const HTuple& ContrastHigh, const HTuple& MinSize, const HTuple& MinScore, const HTuple& SearchRowTol, const HTuple& SearchColumnTol, const HTuple& SearchAngleTol, const HString& TrainingEmphasis, const HString& AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  42. // train_model_components: Train components and relations for the component-based matching.
  43. explicit HComponentTraining(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, HRegion* ModelComponents, Hlong ContrastLow, Hlong ContrastHigh, Hlong MinSize, double MinScore, Hlong SearchRowTol, Hlong SearchColumnTol, double SearchAngleTol, const HString& TrainingEmphasis, const HString& AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  44. // train_model_components: Train components and relations for the component-based matching.
  45. explicit HComponentTraining(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, HRegion* ModelComponents, Hlong ContrastLow, Hlong ContrastHigh, Hlong MinSize, double MinScore, Hlong SearchRowTol, Hlong SearchColumnTol, double SearchAngleTol, const char* TrainingEmphasis, const char* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  46. #ifdef _WIN32
  47. // train_model_components: Train components and relations for the component-based matching.
  48. explicit HComponentTraining(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, HRegion* ModelComponents, Hlong ContrastLow, Hlong ContrastHigh, Hlong MinSize, double MinScore, Hlong SearchRowTol, Hlong SearchColumnTol, double SearchAngleTol, const wchar_t* TrainingEmphasis, const wchar_t* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  49. #endif
  50. /***************************************************************************
  51. * Operators *
  52. ***************************************************************************/
  53. // Prepare a component model for matching based on trained components.
  54. HComponentModel CreateTrainedComponentModel(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) const;
  55. // Prepare a component model for matching based on trained components.
  56. HComponentModel CreateTrainedComponentModel(double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const HString& OptimizationComp, const HString& MetricComp, const HString& PregenerationComp, Hlong* RootRanking) const;
  57. // Prepare a component model for matching based on trained components.
  58. HComponentModel CreateTrainedComponentModel(double AngleStart, double AngleExtent, Hlong MinContrastComp, double MinScoreComp, Hlong NumLevelsComp, double AngleStepComp, const char* OptimizationComp, const char* MetricComp, const char* PregenerationComp, Hlong* RootRanking) const;
  59. #ifdef _WIN32
  60. // Prepare a component model for matching based on trained components.
  61. HComponentModel CreateTrainedComponentModel(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) const;
  62. #endif
  63. // Free the memory of a component training result.
  64. void ClearTrainingComponents() const;
  65. // Return the relations between the model components that are contained in a training result.
  66. HRegion GetComponentRelations(Hlong ReferenceComponent, const HTuple& Image, HTuple* Row, HTuple* Column, HTuple* Phi, HTuple* Length1, HTuple* Length2, HTuple* AngleStart, HTuple* AngleExtent) const;
  67. // Return the relations between the model components that are contained in a training result.
  68. HRegion GetComponentRelations(Hlong ReferenceComponent, const HString& Image, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent) const;
  69. // Return the relations between the model components that are contained in a training result.
  70. HRegion GetComponentRelations(Hlong ReferenceComponent, const char* Image, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent) const;
  71. #ifdef _WIN32
  72. // Return the relations between the model components that are contained in a training result.
  73. HRegion GetComponentRelations(Hlong ReferenceComponent, const wchar_t* Image, double* Row, double* Column, double* Phi, double* Length1, double* Length2, double* AngleStart, double* AngleExtent) const;
  74. #endif
  75. // Return the initial or model components in a certain image.
  76. HRegion GetTrainingComponents(const HTuple& Components, const HTuple& Image, const HString& MarkOrientation, HTuple* Row, HTuple* Column, HTuple* Angle, HTuple* Score) const;
  77. // Return the initial or model components in a certain image.
  78. HRegion GetTrainingComponents(const HString& Components, const HString& Image, const HString& MarkOrientation, double* Row, double* Column, double* Angle, double* Score) const;
  79. // Return the initial or model components in a certain image.
  80. HRegion GetTrainingComponents(const char* Components, const char* Image, const char* MarkOrientation, double* Row, double* Column, double* Angle, double* Score) const;
  81. #ifdef _WIN32
  82. // Return the initial or model components in a certain image.
  83. HRegion GetTrainingComponents(const wchar_t* Components, const wchar_t* Image, const wchar_t* MarkOrientation, double* Row, double* Column, double* Angle, double* Score) const;
  84. #endif
  85. // Modify the relations within a training result.
  86. void ModifyComponentRelations(const HTuple& ReferenceComponent, const HTuple& ToleranceComponent, const HTuple& PositionTolerance, const HTuple& AngleTolerance) const;
  87. // Modify the relations within a training result.
  88. void ModifyComponentRelations(const HString& ReferenceComponent, const HString& ToleranceComponent, double PositionTolerance, double AngleTolerance) const;
  89. // Modify the relations within a training result.
  90. void ModifyComponentRelations(const char* ReferenceComponent, const char* ToleranceComponent, double PositionTolerance, double AngleTolerance) const;
  91. #ifdef _WIN32
  92. // Modify the relations within a training result.
  93. void ModifyComponentRelations(const wchar_t* ReferenceComponent, const wchar_t* ToleranceComponent, double PositionTolerance, double AngleTolerance) const;
  94. #endif
  95. // Deserialize a component training result.
  96. void DeserializeTrainingComponents(const HSerializedItem& SerializedItemHandle);
  97. // Serialize a component training result.
  98. HSerializedItem SerializeTrainingComponents() const;
  99. // Read a component training result from a file.
  100. void ReadTrainingComponents(const HString& FileName);
  101. // Read a component training result from a file.
  102. void ReadTrainingComponents(const char* FileName);
  103. #ifdef _WIN32
  104. // Read a component training result from a file.
  105. void ReadTrainingComponents(const wchar_t* FileName);
  106. #endif
  107. // Write a component training result to a file.
  108. void WriteTrainingComponents(const HString& FileName) const;
  109. // Write a component training result to a file.
  110. void WriteTrainingComponents(const char* FileName) const;
  111. #ifdef _WIN32
  112. // Write a component training result to a file.
  113. void WriteTrainingComponents(const wchar_t* FileName) const;
  114. #endif
  115. // Adopt new parameters that are used to create the model components into the training result.
  116. HRegion ClusterModelComponents(const HImage& TrainingImages, const HString& AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold) const;
  117. // Adopt new parameters that are used to create the model components into the training result.
  118. HRegion ClusterModelComponents(const HImage& TrainingImages, const char* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold) const;
  119. #ifdef _WIN32
  120. // Adopt new parameters that are used to create the model components into the training result.
  121. HRegion ClusterModelComponents(const HImage& TrainingImages, const wchar_t* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold) const;
  122. #endif
  123. // Inspect the rigid model components obtained from the training.
  124. HRegion InspectClusteredComponents(const HString& AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold) const;
  125. // Inspect the rigid model components obtained from the training.
  126. HRegion InspectClusteredComponents(const char* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold) const;
  127. #ifdef _WIN32
  128. // Inspect the rigid model components obtained from the training.
  129. HRegion InspectClusteredComponents(const wchar_t* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold) const;
  130. #endif
  131. // Train components and relations for the component-based matching.
  132. HRegion TrainModelComponents(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, const HTuple& ContrastLow, const HTuple& ContrastHigh, const HTuple& MinSize, const HTuple& MinScore, const HTuple& SearchRowTol, const HTuple& SearchColumnTol, const HTuple& SearchAngleTol, const HString& TrainingEmphasis, const HString& AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  133. // Train components and relations for the component-based matching.
  134. HRegion TrainModelComponents(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, Hlong ContrastLow, Hlong ContrastHigh, Hlong MinSize, double MinScore, Hlong SearchRowTol, Hlong SearchColumnTol, double SearchAngleTol, const HString& TrainingEmphasis, const HString& AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  135. // Train components and relations for the component-based matching.
  136. HRegion TrainModelComponents(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, Hlong ContrastLow, Hlong ContrastHigh, Hlong MinSize, double MinScore, Hlong SearchRowTol, Hlong SearchColumnTol, double SearchAngleTol, const char* TrainingEmphasis, const char* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  137. #ifdef _WIN32
  138. // Train components and relations for the component-based matching.
  139. HRegion TrainModelComponents(const HImage& ModelImage, const HRegion& InitialComponents, const HImage& TrainingImages, Hlong ContrastLow, Hlong ContrastHigh, Hlong MinSize, double MinScore, Hlong SearchRowTol, Hlong SearchColumnTol, double SearchAngleTol, const wchar_t* TrainingEmphasis, const wchar_t* AmbiguityCriterion, double MaxContourOverlap, double ClusterThreshold);
  140. #endif
  141. };
  142. // forward declarations and types for internal array implementation
  143. template<class T> class HSmartPtr;
  144. template<class T> class HHandleBaseArrayRef;
  145. typedef HHandleBaseArrayRef<HComponentTraining> HComponentTrainingArrayRef;
  146. typedef HSmartPtr< HComponentTrainingArrayRef > HComponentTrainingArrayPtr;
  147. // Represents multiple tool instances
  148. class LIntExport HComponentTrainingArray : public HHandleBaseArray
  149. {
  150. public:
  151. // Create empty array
  152. HComponentTrainingArray();
  153. // Create array from native array of tool instances
  154. HComponentTrainingArray(HComponentTraining* classes, Hlong length);
  155. // Copy constructor
  156. HComponentTrainingArray(const HComponentTrainingArray &tool_array);
  157. // Destructor
  158. virtual ~HComponentTrainingArray();
  159. // Assignment operator
  160. HComponentTrainingArray &operator=(const HComponentTrainingArray &tool_array);
  161. // Clears array and all tool instances
  162. virtual void Clear();
  163. // Get array of native tool instances
  164. const HComponentTraining* Tools() const;
  165. // Get number of tools
  166. virtual Hlong Length() const;
  167. // Create tool array from tuple of handles
  168. virtual void SetFromTuple(const HTuple& handles);
  169. // Get tuple of handles for tool array
  170. virtual HTuple ConvertToTuple() const;
  171. protected:
  172. // Smart pointer to internal data container
  173. HComponentTrainingArrayPtr *mArrayPtr;
  174. };
  175. }
  176. #endif