HOCRBox.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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_HOCRBOX
  8. #define HCPP_HOCRBOX
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of an OCR box classifier.
  12. class LIntExport HOCRBox : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HOCRBox():HHandle() {}
  17. // Copy constructor
  18. HOCRBox(const HOCRBox& source) : HHandle(source) {}
  19. // Copy constructor
  20. HOCRBox(const HHandle& handle);
  21. // Create HOCRBox from handle, taking ownership
  22. explicit HOCRBox(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_box')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. // Deep copy of all data represented by this object instance
  36. HOCRBox Clone() const;
  37. /*****************************************************************************
  38. * Operator-based class constructors
  39. *****************************************************************************/
  40. // read_ocr: Read an OCR classifier from a file.
  41. explicit HOCRBox(const HString& FileName);
  42. // read_ocr: Read an OCR classifier from a file.
  43. explicit HOCRBox(const char* FileName);
  44. #ifdef _WIN32
  45. // read_ocr: Read an OCR classifier from a file.
  46. explicit HOCRBox(const wchar_t* FileName);
  47. #endif
  48. // create_ocr_class_box: Create a new OCR-classifier.
  49. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HTuple& Features, const HTuple& Character);
  50. // create_ocr_class_box: Create a new OCR-classifier.
  51. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HString& Features, const HTuple& Character);
  52. // create_ocr_class_box: Create a new OCR-classifier.
  53. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const char* Features, const HTuple& Character);
  54. #ifdef _WIN32
  55. // create_ocr_class_box: Create a new OCR-classifier.
  56. explicit HOCRBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const wchar_t* Features, const HTuple& Character);
  57. #endif
  58. /***************************************************************************
  59. * Operators *
  60. ***************************************************************************/
  61. // Serialize an OCR classifier.
  62. HSerializedItem SerializeOcr() const;
  63. // Deserialize a serialized OCR classifier.
  64. void DeserializeOcr(const HSerializedItem& SerializedItemHandle);
  65. // Writing an OCR classifier into a file.
  66. void WriteOcr(const HString& FileName) const;
  67. // Writing an OCR classifier into a file.
  68. void WriteOcr(const char* FileName) const;
  69. #ifdef _WIN32
  70. // Writing an OCR classifier into a file.
  71. void WriteOcr(const wchar_t* FileName) const;
  72. #endif
  73. // Read an OCR classifier from a file.
  74. void ReadOcr(const HString& FileName);
  75. // Read an OCR classifier from a file.
  76. void ReadOcr(const char* FileName);
  77. #ifdef _WIN32
  78. // Read an OCR classifier from a file.
  79. void ReadOcr(const wchar_t* FileName);
  80. #endif
  81. // Classify one character.
  82. HTuple DoOcrSingle(const HRegion& Character, const HImage& Image, HTuple* Confidences) const;
  83. // Classify characters.
  84. HTuple DoOcrMulti(const HRegion& Character, const HImage& Image, HTuple* Confidence) const;
  85. // Classify characters.
  86. HString DoOcrMulti(const HRegion& Character, const HImage& Image, double* Confidence) const;
  87. // Get information about an OCR classifier.
  88. void InfoOcrClassBox(Hlong* WidthPattern, Hlong* HeightPattern, Hlong* Interpolation, Hlong* WidthMaxChar, Hlong* HeightMaxChar, HTuple* Features, HTuple* Characters) const;
  89. // Create a new OCR-classifier.
  90. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HTuple& Features, const HTuple& Character);
  91. // Create a new OCR-classifier.
  92. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const HString& Features, const HTuple& Character);
  93. // Create a new OCR-classifier.
  94. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const char* Features, const HTuple& Character);
  95. #ifdef _WIN32
  96. // Create a new OCR-classifier.
  97. void CreateOcrClassBox(Hlong WidthPattern, Hlong HeightPattern, Hlong Interpolation, const wchar_t* Features, const HTuple& Character);
  98. #endif
  99. // Train an OCR classifier by the input of regions.
  100. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const HTuple& Class) const;
  101. // Train an OCR classifier by the input of regions.
  102. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const HString& Class) const;
  103. // Train an OCR classifier by the input of regions.
  104. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const char* Class) const;
  105. #ifdef _WIN32
  106. // Train an OCR classifier by the input of regions.
  107. double TraindOcrClassBox(const HRegion& Character, const HImage& Image, const wchar_t* Class) const;
  108. #endif
  109. // Train an OCR classifier with the help of a training file.
  110. double TrainfOcrClassBox(const HTuple& TrainingFile) const;
  111. // Train an OCR classifier with the help of a training file.
  112. double TrainfOcrClassBox(const HString& TrainingFile) const;
  113. // Train an OCR classifier with the help of a training file.
  114. double TrainfOcrClassBox(const char* TrainingFile) const;
  115. #ifdef _WIN32
  116. // Train an OCR classifier with the help of a training file.
  117. double TrainfOcrClassBox(const wchar_t* TrainingFile) const;
  118. #endif
  119. // Define a new conversion table for the characters.
  120. void OcrChangeChar(const HTuple& Character) const;
  121. // Deallocation of the memory of an OCR classifier.
  122. void CloseOcr() const;
  123. // Test an OCR classifier.
  124. HTuple TestdOcrClassBox(const HRegion& Character, const HImage& Image, const HTuple& Class) const;
  125. // Test an OCR classifier.
  126. double TestdOcrClassBox(const HRegion& Character, const HImage& Image, const HString& Class) const;
  127. // Test an OCR classifier.
  128. double TestdOcrClassBox(const HRegion& Character, const HImage& Image, const char* Class) const;
  129. #ifdef _WIN32
  130. // Test an OCR classifier.
  131. double TestdOcrClassBox(const HRegion& Character, const HImage& Image, const wchar_t* Class) const;
  132. #endif
  133. // Access the features which correspond to a character.
  134. HTuple OcrGetFeatures(const HImage& Character) const;
  135. };
  136. // forward declarations and types for internal array implementation
  137. template<class T> class HSmartPtr;
  138. template<class T> class HHandleBaseArrayRef;
  139. typedef HHandleBaseArrayRef<HOCRBox> HOCRBoxArrayRef;
  140. typedef HSmartPtr< HOCRBoxArrayRef > HOCRBoxArrayPtr;
  141. // Represents multiple tool instances
  142. class LIntExport HOCRBoxArray : public HHandleBaseArray
  143. {
  144. public:
  145. // Create empty array
  146. HOCRBoxArray();
  147. // Create array from native array of tool instances
  148. HOCRBoxArray(HOCRBox* classes, Hlong length);
  149. // Copy constructor
  150. HOCRBoxArray(const HOCRBoxArray &tool_array);
  151. // Destructor
  152. virtual ~HOCRBoxArray();
  153. // Assignment operator
  154. HOCRBoxArray &operator=(const HOCRBoxArray &tool_array);
  155. // Clears array and all tool instances
  156. virtual void Clear();
  157. // Get array of native tool instances
  158. const HOCRBox* Tools() const;
  159. // Get number of tools
  160. virtual Hlong Length() const;
  161. // Create tool array from tuple of handles
  162. virtual void SetFromTuple(const HTuple& handles);
  163. // Get tuple of handles for tool array
  164. virtual HTuple ConvertToTuple() const;
  165. protected:
  166. // Smart pointer to internal data container
  167. HOCRBoxArrayPtr *mArrayPtr;
  168. };
  169. }
  170. #endif