HOCRMlp.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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_HOCRMLP
  8. #define HCPP_HOCRMLP
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a MLP OCR classifier.
  12. class LIntExport HOCRMlp : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HOCRMlp():HHandle() {}
  17. // Copy constructor
  18. HOCRMlp(const HOCRMlp& source) : HHandle(source) {}
  19. // Copy constructor
  20. HOCRMlp(const HHandle& handle);
  21. // Create HOCRMlp from handle, taking ownership
  22. explicit HOCRMlp(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 ('ocr_mlp')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. // Deep copy of all data represented by this object instance
  36. HOCRMlp Clone() const;
  37. /*****************************************************************************
  38. * Operator-based class constructors
  39. *****************************************************************************/
  40. // read_ocr_class_mlp: Read an OCR classifier from a file.
  41. explicit HOCRMlp(const HString& FileName);
  42. // read_ocr_class_mlp: Read an OCR classifier from a file.
  43. explicit HOCRMlp(const char* FileName);
  44. #ifdef _WIN32
  45. // read_ocr_class_mlp: Read an OCR classifier from a file.
  46. explicit HOCRMlp(const wchar_t* FileName);
  47. #endif
  48. // create_ocr_class_mlp: Create an OCR classifier using a multilayer perceptron.
  49. explicit HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed);
  50. // create_ocr_class_mlp: Create an OCR classifier using a multilayer perceptron.
  51. explicit HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed);
  52. // create_ocr_class_mlp: Create an OCR classifier using a multilayer perceptron.
  53. explicit HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, Hlong NumHidden, const char* Preprocessing, Hlong NumComponents, Hlong RandSeed);
  54. #ifdef _WIN32
  55. // create_ocr_class_mlp: Create an OCR classifier using a multilayer perceptron.
  56. explicit HOCRMlp(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, Hlong NumHidden, const wchar_t* Preprocessing, Hlong NumComponents, Hlong RandSeed);
  57. #endif
  58. /***************************************************************************
  59. * Operators *
  60. ***************************************************************************/
  61. // Select an optimal combination of features to classify OCR data from a (protected) training file.
  62. HTuple SelectFeatureSetTrainfMlpProtected(const HTuple& TrainingFile, const HTuple& Password, const HTuple& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  63. // Select an optimal combination of features to classify OCR data from a (protected) training file.
  64. HTuple SelectFeatureSetTrainfMlpProtected(const HString& TrainingFile, const HString& Password, const HString& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  65. // Select an optimal combination of features to classify OCR data from a (protected) training file.
  66. HTuple SelectFeatureSetTrainfMlpProtected(const char* TrainingFile, const char* Password, const char* FeatureList, const char* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  67. #ifdef _WIN32
  68. // Select an optimal combination of features to classify OCR data from a (protected) training file.
  69. HTuple SelectFeatureSetTrainfMlpProtected(const wchar_t* TrainingFile, const wchar_t* Password, const wchar_t* FeatureList, const wchar_t* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  70. #endif
  71. // Selects an optimal combination of features to classify OCR data.
  72. HTuple SelectFeatureSetTrainfMlp(const HTuple& TrainingFile, const HTuple& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  73. // Selects an optimal combination of features to classify OCR data.
  74. HTuple SelectFeatureSetTrainfMlp(const HString& TrainingFile, const HString& FeatureList, const HString& SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  75. // Selects an optimal combination of features to classify OCR data.
  76. HTuple SelectFeatureSetTrainfMlp(const char* TrainingFile, const char* FeatureList, const char* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  77. #ifdef _WIN32
  78. // Selects an optimal combination of features to classify OCR data.
  79. HTuple SelectFeatureSetTrainfMlp(const wchar_t* TrainingFile, const wchar_t* FeatureList, const wchar_t* SelectionMethod, Hlong Width, Hlong Height, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* Score);
  80. #endif
  81. // Clear an OCR classifier.
  82. static void ClearOcrClassMlp(const HOCRMlpArray& OCRHandle);
  83. // Clear an OCR classifier.
  84. void ClearOcrClassMlp() const;
  85. // Deserialize a serialized MLP-based OCR classifier.
  86. void DeserializeOcrClassMlp(const HSerializedItem& SerializedItemHandle);
  87. // Serialize a MLP-based OCR classifier.
  88. HSerializedItem SerializeOcrClassMlp() const;
  89. // Read an OCR classifier from a file.
  90. void ReadOcrClassMlp(const HString& FileName);
  91. // Read an OCR classifier from a file.
  92. void ReadOcrClassMlp(const char* FileName);
  93. #ifdef _WIN32
  94. // Read an OCR classifier from a file.
  95. void ReadOcrClassMlp(const wchar_t* FileName);
  96. #endif
  97. // Write an OCR classifier to a file.
  98. void WriteOcrClassMlp(const HString& FileName) const;
  99. // Write an OCR classifier to a file.
  100. void WriteOcrClassMlp(const char* FileName) const;
  101. #ifdef _WIN32
  102. // Write an OCR classifier to a file.
  103. void WriteOcrClassMlp(const wchar_t* FileName) const;
  104. #endif
  105. // Compute the features of a character.
  106. HTuple GetFeaturesOcrClassMlp(const HImage& Character, const HString& Transform) const;
  107. // Compute the features of a character.
  108. HTuple GetFeaturesOcrClassMlp(const HImage& Character, const char* Transform) const;
  109. #ifdef _WIN32
  110. // Compute the features of a character.
  111. HTuple GetFeaturesOcrClassMlp(const HImage& Character, const wchar_t* Transform) const;
  112. #endif
  113. // Classify a related group of characters with an OCR classifier.
  114. HTuple DoOcrWordMlp(const HRegion& Character, const HImage& Image, const HString& Expression, Hlong NumAlternatives, Hlong NumCorrections, HTuple* Confidence, HString* Word, double* Score) const;
  115. // Classify a related group of characters with an OCR classifier.
  116. HString DoOcrWordMlp(const HRegion& Character, const HImage& Image, const HString& Expression, Hlong NumAlternatives, Hlong NumCorrections, double* Confidence, HString* Word, double* Score) const;
  117. // Classify a related group of characters with an OCR classifier.
  118. HString DoOcrWordMlp(const HRegion& Character, const HImage& Image, const char* Expression, Hlong NumAlternatives, Hlong NumCorrections, double* Confidence, HString* Word, double* Score) const;
  119. #ifdef _WIN32
  120. // Classify a related group of characters with an OCR classifier.
  121. HString DoOcrWordMlp(const HRegion& Character, const HImage& Image, const wchar_t* Expression, Hlong NumAlternatives, Hlong NumCorrections, double* Confidence, HString* Word, double* Score) const;
  122. #endif
  123. // Classify multiple characters with an OCR classifier.
  124. HTuple DoOcrMultiClassMlp(const HRegion& Character, const HImage& Image, HTuple* Confidence) const;
  125. // Classify multiple characters with an OCR classifier.
  126. HString DoOcrMultiClassMlp(const HRegion& Character, const HImage& Image, double* Confidence) const;
  127. // Classify a single character with an OCR classifier.
  128. HTuple DoOcrSingleClassMlp(const HRegion& Character, const HImage& Image, const HTuple& Num, HTuple* Confidence) const;
  129. // Classify a single character with an OCR classifier.
  130. HString DoOcrSingleClassMlp(const HRegion& Character, const HImage& Image, const HTuple& Num, double* Confidence) const;
  131. // Train an OCR classifier with data from a (protected) training file.
  132. double TrainfOcrClassMlpProtected(const HTuple& TrainingFile, const HTuple& Password, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  133. // Train an OCR classifier with data from a (protected) training file.
  134. double TrainfOcrClassMlpProtected(const HString& TrainingFile, const HString& Password, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  135. // Train an OCR classifier with data from a (protected) training file.
  136. double TrainfOcrClassMlpProtected(const char* TrainingFile, const char* Password, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  137. #ifdef _WIN32
  138. // Train an OCR classifier with data from a (protected) training file.
  139. double TrainfOcrClassMlpProtected(const wchar_t* TrainingFile, const wchar_t* Password, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  140. #endif
  141. // Train an OCR classifier.
  142. double TrainfOcrClassMlp(const HTuple& TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  143. // Train an OCR classifier.
  144. double TrainfOcrClassMlp(const HString& TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  145. // Train an OCR classifier.
  146. double TrainfOcrClassMlp(const char* TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  147. #ifdef _WIN32
  148. // Train an OCR classifier.
  149. double TrainfOcrClassMlp(const wchar_t* TrainingFile, Hlong MaxIterations, double WeightTolerance, double ErrorTolerance, HTuple* ErrorLog) const;
  150. #endif
  151. // Compute the information content of the preprocessed feature vectors of an OCR classifier.
  152. HTuple GetPrepInfoOcrClassMlp(const HTuple& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const;
  153. // Compute the information content of the preprocessed feature vectors of an OCR classifier.
  154. HTuple GetPrepInfoOcrClassMlp(const HString& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const;
  155. // Compute the information content of the preprocessed feature vectors of an OCR classifier.
  156. HTuple GetPrepInfoOcrClassMlp(const char* TrainingFile, const char* Preprocessing, HTuple* CumInformationCont) const;
  157. #ifdef _WIN32
  158. // Compute the information content of the preprocessed feature vectors of an OCR classifier.
  159. HTuple GetPrepInfoOcrClassMlp(const wchar_t* TrainingFile, const wchar_t* Preprocessing, HTuple* CumInformationCont) const;
  160. #endif
  161. // Return the rejection class parameters of an OCR classifier.
  162. HTuple GetRejectionParamsOcrClassMlp(const HTuple& GenParamName) const;
  163. // Return the rejection class parameters of an OCR classifier.
  164. HString GetRejectionParamsOcrClassMlp(const HString& GenParamName) const;
  165. // Return the rejection class parameters of an OCR classifier.
  166. HString GetRejectionParamsOcrClassMlp(const char* GenParamName) const;
  167. #ifdef _WIN32
  168. // Return the rejection class parameters of an OCR classifier.
  169. HString GetRejectionParamsOcrClassMlp(const wchar_t* GenParamName) const;
  170. #endif
  171. // Set the rejection class parameters of an OCR classifier.
  172. void SetRejectionParamsOcrClassMlp(const HTuple& GenParamName, const HTuple& GenParamValue) const;
  173. // Set the rejection class parameters of an OCR classifier.
  174. void SetRejectionParamsOcrClassMlp(const HString& GenParamName, const HString& GenParamValue) const;
  175. // Set the rejection class parameters of an OCR classifier.
  176. void SetRejectionParamsOcrClassMlp(const char* GenParamName, const char* GenParamValue) const;
  177. #ifdef _WIN32
  178. // Set the rejection class parameters of an OCR classifier.
  179. void SetRejectionParamsOcrClassMlp(const wchar_t* GenParamName, const wchar_t* GenParamValue) const;
  180. #endif
  181. // Return the regularization parameters of an OCR classifier.
  182. HTuple GetRegularizationParamsOcrClassMlp(const HString& GenParamName) const;
  183. // Return the regularization parameters of an OCR classifier.
  184. HTuple GetRegularizationParamsOcrClassMlp(const char* GenParamName) const;
  185. #ifdef _WIN32
  186. // Return the regularization parameters of an OCR classifier.
  187. HTuple GetRegularizationParamsOcrClassMlp(const wchar_t* GenParamName) const;
  188. #endif
  189. // Set the regularization parameters of an OCR classifier.
  190. void SetRegularizationParamsOcrClassMlp(const HString& GenParamName, const HTuple& GenParamValue) const;
  191. // Set the regularization parameters of an OCR classifier.
  192. void SetRegularizationParamsOcrClassMlp(const HString& GenParamName, double GenParamValue) const;
  193. // Set the regularization parameters of an OCR classifier.
  194. void SetRegularizationParamsOcrClassMlp(const char* GenParamName, double GenParamValue) const;
  195. #ifdef _WIN32
  196. // Set the regularization parameters of an OCR classifier.
  197. void SetRegularizationParamsOcrClassMlp(const wchar_t* GenParamName, double GenParamValue) const;
  198. #endif
  199. // Return the parameters of an OCR classifier.
  200. void GetParamsOcrClassMlp(Hlong* WidthCharacter, Hlong* HeightCharacter, HString* Interpolation, HTuple* Features, HTuple* Characters, Hlong* NumHidden, HString* Preprocessing, Hlong* NumComponents) const;
  201. // Return the parameters of an OCR classifier.
  202. void GetParamsOcrClassMlp(Hlong* WidthCharacter, Hlong* HeightCharacter, HString* Interpolation, HString* Features, HTuple* Characters, Hlong* NumHidden, HString* Preprocessing, Hlong* NumComponents) const;
  203. // Create an OCR classifier using a multilayer perceptron.
  204. void CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed);
  205. // Create an OCR classifier using a multilayer perceptron.
  206. void CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, Hlong NumHidden, const HString& Preprocessing, Hlong NumComponents, Hlong RandSeed);
  207. // Create an OCR classifier using a multilayer perceptron.
  208. void CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, Hlong NumHidden, const char* Preprocessing, Hlong NumComponents, Hlong RandSeed);
  209. #ifdef _WIN32
  210. // Create an OCR classifier using a multilayer perceptron.
  211. void CreateOcrClassMlp(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, Hlong NumHidden, const wchar_t* Preprocessing, Hlong NumComponents, Hlong RandSeed);
  212. #endif
  213. };
  214. // forward declarations and types for internal array implementation
  215. template<class T> class HSmartPtr;
  216. template<class T> class HHandleBaseArrayRef;
  217. typedef HHandleBaseArrayRef<HOCRMlp> HOCRMlpArrayRef;
  218. typedef HSmartPtr< HOCRMlpArrayRef > HOCRMlpArrayPtr;
  219. // Represents multiple tool instances
  220. class LIntExport HOCRMlpArray : public HHandleBaseArray
  221. {
  222. public:
  223. // Create empty array
  224. HOCRMlpArray();
  225. // Create array from native array of tool instances
  226. HOCRMlpArray(HOCRMlp* classes, Hlong length);
  227. // Copy constructor
  228. HOCRMlpArray(const HOCRMlpArray &tool_array);
  229. // Destructor
  230. virtual ~HOCRMlpArray();
  231. // Assignment operator
  232. HOCRMlpArray &operator=(const HOCRMlpArray &tool_array);
  233. // Clears array and all tool instances
  234. virtual void Clear();
  235. // Get array of native tool instances
  236. const HOCRMlp* Tools() const;
  237. // Get number of tools
  238. virtual Hlong Length() const;
  239. // Create tool array from tuple of handles
  240. virtual void SetFromTuple(const HTuple& handles);
  241. // Get tuple of handles for tool array
  242. virtual HTuple ConvertToTuple() const;
  243. protected:
  244. // Smart pointer to internal data container
  245. HOCRMlpArrayPtr *mArrayPtr;
  246. };
  247. }
  248. #endif