HClassTrainData.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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_HCLASSTRAINDATA
  8. #define HCPP_HCLASSTRAINDATA
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a training data management class.
  12. class LIntExport HClassTrainData : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HClassTrainData():HHandle() {}
  17. // Copy constructor
  18. HClassTrainData(const HClassTrainData& source) : HHandle(source) {}
  19. // Copy constructor
  20. HClassTrainData(const HHandle& handle);
  21. bool operator==(const HHandle& obj) const
  22. {
  23. return HHandleBase::operator==(obj);
  24. }
  25. bool operator!=(const HHandle& obj) const
  26. {
  27. return HHandleBase::operator!=(obj);
  28. }
  29. protected:
  30. // Verify matching semantic type ('class_train_data')!
  31. virtual void AssertType(Hphandle handle) const;
  32. public:
  33. // Deep copy of all data represented by this object instance
  34. HClassTrainData Clone() const;
  35. /*****************************************************************************
  36. * Operator-based class constructors
  37. *****************************************************************************/
  38. // read_class_train_data: Read the training data for classifiers from a file.
  39. explicit HClassTrainData(const HString& FileName);
  40. // read_class_train_data: Read the training data for classifiers from a file.
  41. explicit HClassTrainData(const char* FileName);
  42. #ifdef _WIN32
  43. // read_class_train_data: Read the training data for classifiers from a file.
  44. explicit HClassTrainData(const wchar_t* FileName);
  45. #endif
  46. // create_class_train_data: Create a handle for training data for classifiers.
  47. explicit HClassTrainData(Hlong NumDim);
  48. /***************************************************************************
  49. * Operators *
  50. ***************************************************************************/
  51. // Deserialize serialized training data for classifiers.
  52. void DeserializeClassTrainData(const HSerializedItem& SerializedItemHandle);
  53. // Serialize training data for classifiers.
  54. HSerializedItem SerializeClassTrainData() const;
  55. // Read the training data for classifiers from a file.
  56. void ReadClassTrainData(const HString& FileName);
  57. // Read the training data for classifiers from a file.
  58. void ReadClassTrainData(const char* FileName);
  59. #ifdef _WIN32
  60. // Read the training data for classifiers from a file.
  61. void ReadClassTrainData(const wchar_t* FileName);
  62. #endif
  63. // Save the training data for classifiers in a file.
  64. void WriteClassTrainData(const HString& FileName) const;
  65. // Save the training data for classifiers in a file.
  66. void WriteClassTrainData(const char* FileName) const;
  67. #ifdef _WIN32
  68. // Save the training data for classifiers in a file.
  69. void WriteClassTrainData(const wchar_t* FileName) const;
  70. #endif
  71. // Select certain features from training data to create training data containing less features.
  72. HClassTrainData SelectSubFeatureClassTrainData(const HTuple& SubFeatureIndices) const;
  73. // Define subfeatures in training data.
  74. void SetFeatureLengthsClassTrainData(const HTuple& SubFeatureLength, const HTuple& Names) const;
  75. // Get the training data of a Gaussian Mixture Model (GMM).
  76. void GetClassTrainDataGmm(const HClassGmm& GMMHandle);
  77. // Add training data to a Gaussian Mixture Model (GMM).
  78. void AddClassTrainDataGmm(const HClassGmm& GMMHandle) const;
  79. // Get the training data of a multilayer perceptron (MLP).
  80. void GetClassTrainDataMlp(const HClassMlp& MLPHandle);
  81. // Add training data to a multilayer perceptron (MLP).
  82. void AddClassTrainDataMlp(const HClassMlp& MLPHandle) const;
  83. // Get the training data of a k-nearest neighbors (k-NN) classifier.
  84. void GetClassTrainDataKnn(const HClassKnn& KNNHandle);
  85. // Add training data to a k-nearest neighbors (k-NN) classifier.
  86. void AddClassTrainDataKnn(const HClassKnn& KNNHandle) const;
  87. // Get the training data of a support vector machine (SVM).
  88. void GetClassTrainDataSvm(const HClassSvm& SVMHandle);
  89. // Add training data to a support vector machine (SVM).
  90. void AddClassTrainDataSvm(const HClassSvm& SVMHandle) const;
  91. // Return the number of training samples stored in the training data.
  92. Hlong GetSampleNumClassTrainData() const;
  93. // Return a training sample from training data.
  94. HTuple GetSampleClassTrainData(Hlong IndexSample, Hlong* ClassID) const;
  95. // Clears training data for classifiers.
  96. void ClearClassTrainData() const;
  97. // Add a training sample to training data.
  98. void AddSampleClassTrainData(const HString& Order, const HTuple& Features, const HTuple& ClassID) const;
  99. // Add a training sample to training data.
  100. void AddSampleClassTrainData(const char* Order, const HTuple& Features, const HTuple& ClassID) const;
  101. #ifdef _WIN32
  102. // Add a training sample to training data.
  103. void AddSampleClassTrainData(const wchar_t* Order, const HTuple& Features, const HTuple& ClassID) const;
  104. #endif
  105. // Create a handle for training data for classifiers.
  106. void CreateClassTrainData(Hlong NumDim);
  107. // Selects an optimal combination of features to classify the provided data.
  108. HClassMlp SelectFeatureSetMlp(const HString& SelectionMethod, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  109. // Selects an optimal combination of features to classify the provided data.
  110. HClassMlp SelectFeatureSetMlp(const HString& SelectionMethod, const HString& GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  111. // Selects an optimal combination of features to classify the provided data.
  112. HClassMlp SelectFeatureSetMlp(const char* SelectionMethod, const char* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  113. #ifdef _WIN32
  114. // Selects an optimal combination of features to classify the provided data.
  115. HClassMlp SelectFeatureSetMlp(const wchar_t* SelectionMethod, const wchar_t* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  116. #endif
  117. // Selects an optimal combination of features to classify the provided data.
  118. HClassSvm SelectFeatureSetSvm(const HString& SelectionMethod, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  119. // Selects an optimal combination of features to classify the provided data.
  120. HClassSvm SelectFeatureSetSvm(const HString& SelectionMethod, const HString& GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  121. // Selects an optimal combination of features to classify the provided data.
  122. HClassSvm SelectFeatureSetSvm(const char* SelectionMethod, const char* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  123. #ifdef _WIN32
  124. // Selects an optimal combination of features to classify the provided data.
  125. HClassSvm SelectFeatureSetSvm(const wchar_t* SelectionMethod, const wchar_t* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  126. #endif
  127. // Selects an optimal combination from a set of features to classify the provided data.
  128. HClassGmm SelectFeatureSetGmm(const HString& SelectionMethod, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  129. // Selects an optimal combination from a set of features to classify the provided data.
  130. HClassGmm SelectFeatureSetGmm(const HString& SelectionMethod, const HString& GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  131. // Selects an optimal combination from a set of features to classify the provided data.
  132. HClassGmm SelectFeatureSetGmm(const char* SelectionMethod, const char* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  133. #ifdef _WIN32
  134. // Selects an optimal combination from a set of features to classify the provided data.
  135. HClassGmm SelectFeatureSetGmm(const wchar_t* SelectionMethod, const wchar_t* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  136. #endif
  137. // Selects an optimal subset from a set of features to solve a certain classification problem.
  138. HClassKnn SelectFeatureSetKnn(const HString& SelectionMethod, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  139. // Selects an optimal subset from a set of features to solve a certain classification problem.
  140. HClassKnn SelectFeatureSetKnn(const HString& SelectionMethod, const HString& GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  141. // Selects an optimal subset from a set of features to solve a certain classification problem.
  142. HClassKnn SelectFeatureSetKnn(const char* SelectionMethod, const char* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  143. #ifdef _WIN32
  144. // Selects an optimal subset from a set of features to solve a certain classification problem.
  145. HClassKnn SelectFeatureSetKnn(const wchar_t* SelectionMethod, const wchar_t* GenParamName, double GenParamValue, HTuple* SelectedFeatureIndices, HTuple* Score) const;
  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<HClassTrainData> HClassTrainDataArrayRef;
  152. typedef HSmartPtr< HClassTrainDataArrayRef > HClassTrainDataArrayPtr;
  153. // Represents multiple tool instances
  154. class LIntExport HClassTrainDataArray : public HHandleBaseArray
  155. {
  156. public:
  157. // Create empty array
  158. HClassTrainDataArray();
  159. // Create array from native array of tool instances
  160. HClassTrainDataArray(HClassTrainData* classes, Hlong length);
  161. // Copy constructor
  162. HClassTrainDataArray(const HClassTrainDataArray &tool_array);
  163. // Destructor
  164. virtual ~HClassTrainDataArray();
  165. // Assignment operator
  166. HClassTrainDataArray &operator=(const HClassTrainDataArray &tool_array);
  167. // Clears array and all tool instances
  168. virtual void Clear();
  169. // Get array of native tool instances
  170. const HClassTrainData* 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. HClassTrainDataArrayPtr *mArrayPtr;
  180. };
  181. }
  182. #endif