HOCRSvm.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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_HOCRSVM
  8. #define HCPP_HOCRSVM
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a SVM OCR classifier.
  12. class LIntExport HOCRSvm : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HOCRSvm():HHandle() {}
  17. // Copy constructor
  18. HOCRSvm(const HOCRSvm& source) : HHandle(source) {}
  19. // Copy constructor
  20. HOCRSvm(const HHandle& handle);
  21. // Create HOCRSvm from handle, taking ownership
  22. explicit HOCRSvm(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_svm')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. // Deep copy of all data represented by this object instance
  36. HOCRSvm Clone() const;
  37. /*****************************************************************************
  38. * Operator-based class constructors
  39. *****************************************************************************/
  40. // read_ocr_class_svm: Read a SVM-based OCR classifier from a file.
  41. explicit HOCRSvm(const HString& FileName);
  42. // read_ocr_class_svm: Read a SVM-based OCR classifier from a file.
  43. explicit HOCRSvm(const char* FileName);
  44. #ifdef _WIN32
  45. // read_ocr_class_svm: Read a SVM-based OCR classifier from a file.
  46. explicit HOCRSvm(const wchar_t* FileName);
  47. #endif
  48. // create_ocr_class_svm: Create an OCR classifier using a support vector machine.
  49. explicit HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents);
  50. // create_ocr_class_svm: Create an OCR classifier using a support vector machine.
  51. explicit HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents);
  52. // create_ocr_class_svm: Create an OCR classifier using a support vector machine.
  53. explicit HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, const char* KernelType, double KernelParam, double Nu, const char* Mode, const char* Preprocessing, Hlong NumComponents);
  54. #ifdef _WIN32
  55. // create_ocr_class_svm: Create an OCR classifier using a support vector machine.
  56. explicit HOCRSvm(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, const wchar_t* KernelType, double KernelParam, double Nu, const wchar_t* Mode, const wchar_t* Preprocessing, Hlong NumComponents);
  57. #endif
  58. /***************************************************************************
  59. * Operators *
  60. ***************************************************************************/
  61. // Select an optimal combination of features to classify OCR data from a (protected) training file.
  62. HTuple SelectFeatureSetTrainfSvmProtected(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 SelectFeatureSetTrainfSvmProtected(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 SelectFeatureSetTrainfSvmProtected(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 SelectFeatureSetTrainfSvmProtected(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 SelectFeatureSetTrainfSvm(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 SelectFeatureSetTrainfSvm(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 SelectFeatureSetTrainfSvm(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 SelectFeatureSetTrainfSvm(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 SVM-based OCR classifier.
  82. static void ClearOcrClassSvm(const HOCRSvmArray& OCRHandle);
  83. // Clear an SVM-based OCR classifier.
  84. void ClearOcrClassSvm() const;
  85. // Deserialize a serialized SVM-based OCR classifier.
  86. void DeserializeOcrClassSvm(const HSerializedItem& SerializedItemHandle);
  87. // Serialize a SVM-based OCR classifier
  88. HSerializedItem SerializeOcrClassSvm() const;
  89. // Read a SVM-based OCR classifier from a file.
  90. void ReadOcrClassSvm(const HString& FileName);
  91. // Read a SVM-based OCR classifier from a file.
  92. void ReadOcrClassSvm(const char* FileName);
  93. #ifdef _WIN32
  94. // Read a SVM-based OCR classifier from a file.
  95. void ReadOcrClassSvm(const wchar_t* FileName);
  96. #endif
  97. // Write an OCR classifier to a file.
  98. void WriteOcrClassSvm(const HString& FileName) const;
  99. // Write an OCR classifier to a file.
  100. void WriteOcrClassSvm(const char* FileName) const;
  101. #ifdef _WIN32
  102. // Write an OCR classifier to a file.
  103. void WriteOcrClassSvm(const wchar_t* FileName) const;
  104. #endif
  105. // Compute the features of a character.
  106. HTuple GetFeaturesOcrClassSvm(const HImage& Character, const HString& Transform) const;
  107. // Compute the features of a character.
  108. HTuple GetFeaturesOcrClassSvm(const HImage& Character, const char* Transform) const;
  109. #ifdef _WIN32
  110. // Compute the features of a character.
  111. HTuple GetFeaturesOcrClassSvm(const HImage& Character, const wchar_t* Transform) const;
  112. #endif
  113. // Classify a related group of characters with an OCR classifier.
  114. HTuple DoOcrWordSvm(const HRegion& Character, const HImage& Image, const HString& Expression, Hlong NumAlternatives, Hlong NumCorrections, HString* Word, double* Score) const;
  115. // Classify a related group of characters with an OCR classifier.
  116. HTuple DoOcrWordSvm(const HRegion& Character, const HImage& Image, const char* Expression, Hlong NumAlternatives, Hlong NumCorrections, HString* Word, double* Score) const;
  117. #ifdef _WIN32
  118. // Classify a related group of characters with an OCR classifier.
  119. HTuple DoOcrWordSvm(const HRegion& Character, const HImage& Image, const wchar_t* Expression, Hlong NumAlternatives, Hlong NumCorrections, HString* Word, double* Score) const;
  120. #endif
  121. // Classify multiple characters with an SVM-based OCR classifier.
  122. HTuple DoOcrMultiClassSvm(const HRegion& Character, const HImage& Image) const;
  123. // Classify a single character with an SVM-based OCR classifier.
  124. HTuple DoOcrSingleClassSvm(const HRegion& Character, const HImage& Image, const HTuple& Num) const;
  125. // Approximate a trained SVM-based OCR classifier by a reduced SVM.
  126. HOCRSvm ReduceOcrClassSvm(const HString& Method, Hlong MinRemainingSV, double MaxError) const;
  127. // Approximate a trained SVM-based OCR classifier by a reduced SVM.
  128. HOCRSvm ReduceOcrClassSvm(const char* Method, Hlong MinRemainingSV, double MaxError) const;
  129. #ifdef _WIN32
  130. // Approximate a trained SVM-based OCR classifier by a reduced SVM.
  131. HOCRSvm ReduceOcrClassSvm(const wchar_t* Method, Hlong MinRemainingSV, double MaxError) const;
  132. #endif
  133. // Train an OCR classifier with data from a (protected) training file.
  134. void TrainfOcrClassSvmProtected(const HTuple& TrainingFile, const HTuple& Password, double Epsilon, const HTuple& TrainMode) const;
  135. // Train an OCR classifier with data from a (protected) training file.
  136. void TrainfOcrClassSvmProtected(const HString& TrainingFile, const HString& Password, double Epsilon, const HString& TrainMode) const;
  137. // Train an OCR classifier with data from a (protected) training file.
  138. void TrainfOcrClassSvmProtected(const char* TrainingFile, const char* Password, double Epsilon, const char* TrainMode) const;
  139. #ifdef _WIN32
  140. // Train an OCR classifier with data from a (protected) training file.
  141. void TrainfOcrClassSvmProtected(const wchar_t* TrainingFile, const wchar_t* Password, double Epsilon, const wchar_t* TrainMode) const;
  142. #endif
  143. // Train an OCR classifier.
  144. void TrainfOcrClassSvm(const HTuple& TrainingFile, double Epsilon, const HTuple& TrainMode) const;
  145. // Train an OCR classifier.
  146. void TrainfOcrClassSvm(const HString& TrainingFile, double Epsilon, const HString& TrainMode) const;
  147. // Train an OCR classifier.
  148. void TrainfOcrClassSvm(const char* TrainingFile, double Epsilon, const char* TrainMode) const;
  149. #ifdef _WIN32
  150. // Train an OCR classifier.
  151. void TrainfOcrClassSvm(const wchar_t* TrainingFile, double Epsilon, const wchar_t* TrainMode) const;
  152. #endif
  153. // Compute the information content of the preprocessed feature vectors of an SVM-based OCR classifier.
  154. HTuple GetPrepInfoOcrClassSvm(const HTuple& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const;
  155. // Compute the information content of the preprocessed feature vectors of an SVM-based OCR classifier.
  156. HTuple GetPrepInfoOcrClassSvm(const HString& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const;
  157. // Compute the information content of the preprocessed feature vectors of an SVM-based OCR classifier.
  158. HTuple GetPrepInfoOcrClassSvm(const char* TrainingFile, const char* Preprocessing, HTuple* CumInformationCont) const;
  159. #ifdef _WIN32
  160. // Compute the information content of the preprocessed feature vectors of an SVM-based OCR classifier.
  161. HTuple GetPrepInfoOcrClassSvm(const wchar_t* TrainingFile, const wchar_t* Preprocessing, HTuple* CumInformationCont) const;
  162. #endif
  163. // Return the number of support vectors of an OCR classifier.
  164. Hlong GetSupportVectorNumOcrClassSvm(HTuple* NumSVPerSVM) const;
  165. // Return the index of a support vector from a trained OCR classifier that is based on support vector machines.
  166. double GetSupportVectorOcrClassSvm(const HTuple& IndexSupportVector) const;
  167. // Return the parameters of an OCR classifier.
  168. void GetParamsOcrClassSvm(Hlong* WidthCharacter, Hlong* HeightCharacter, HString* Interpolation, HTuple* Features, HTuple* Characters, HString* KernelType, double* KernelParam, double* Nu, HString* Mode, HString* Preprocessing, Hlong* NumComponents) const;
  169. // Return the parameters of an OCR classifier.
  170. void GetParamsOcrClassSvm(Hlong* WidthCharacter, Hlong* HeightCharacter, HString* Interpolation, HString* Features, HTuple* Characters, HString* KernelType, double* KernelParam, double* Nu, HString* Mode, HString* Preprocessing, Hlong* NumComponents) const;
  171. // Create an OCR classifier using a support vector machine.
  172. void CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HTuple& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents);
  173. // Create an OCR classifier using a support vector machine.
  174. void CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const HString& Interpolation, const HString& Features, const HTuple& Characters, const HString& KernelType, double KernelParam, double Nu, const HString& Mode, const HString& Preprocessing, Hlong NumComponents);
  175. // Create an OCR classifier using a support vector machine.
  176. void CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const char* Interpolation, const char* Features, const HTuple& Characters, const char* KernelType, double KernelParam, double Nu, const char* Mode, const char* Preprocessing, Hlong NumComponents);
  177. #ifdef _WIN32
  178. // Create an OCR classifier using a support vector machine.
  179. void CreateOcrClassSvm(Hlong WidthCharacter, Hlong HeightCharacter, const wchar_t* Interpolation, const wchar_t* Features, const HTuple& Characters, const wchar_t* KernelType, double KernelParam, double Nu, const wchar_t* Mode, const wchar_t* Preprocessing, Hlong NumComponents);
  180. #endif
  181. };
  182. // forward declarations and types for internal array implementation
  183. template<class T> class HSmartPtr;
  184. template<class T> class HHandleBaseArrayRef;
  185. typedef HHandleBaseArrayRef<HOCRSvm> HOCRSvmArrayRef;
  186. typedef HSmartPtr< HOCRSvmArrayRef > HOCRSvmArrayPtr;
  187. // Represents multiple tool instances
  188. class LIntExport HOCRSvmArray : public HHandleBaseArray
  189. {
  190. public:
  191. // Create empty array
  192. HOCRSvmArray();
  193. // Create array from native array of tool instances
  194. HOCRSvmArray(HOCRSvm* classes, Hlong length);
  195. // Copy constructor
  196. HOCRSvmArray(const HOCRSvmArray &tool_array);
  197. // Destructor
  198. virtual ~HOCRSvmArray();
  199. // Assignment operator
  200. HOCRSvmArray &operator=(const HOCRSvmArray &tool_array);
  201. // Clears array and all tool instances
  202. virtual void Clear();
  203. // Get array of native tool instances
  204. const HOCRSvm* Tools() const;
  205. // Get number of tools
  206. virtual Hlong Length() const;
  207. // Create tool array from tuple of handles
  208. virtual void SetFromTuple(const HTuple& handles);
  209. // Get tuple of handles for tool array
  210. virtual HTuple ConvertToTuple() const;
  211. protected:
  212. // Smart pointer to internal data container
  213. HOCRSvmArrayPtr *mArrayPtr;
  214. };
  215. }
  216. #endif