OCRHMMDecoder.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #if !UNITY_WSA_10_0
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.TextModule
  8. {
  9. // C++: class OCRHMMDecoder
  10. //javadoc: OCRHMMDecoder
  11. public class OCRHMMDecoder : BaseOCR
  12. {
  13. protected override void Dispose (bool disposing)
  14. {
  15. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  16. try {
  17. if (disposing) {
  18. }
  19. if (IsEnabledDispose) {
  20. if (nativeObj != IntPtr.Zero)
  21. text_OCRHMMDecoder_delete (nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal OCRHMMDecoder (IntPtr addr)
  32. : base (addr)
  33. {
  34. }
  35. // internal usage only
  36. public static new OCRHMMDecoder __fromPtr__ (IntPtr addr)
  37. {
  38. return new OCRHMMDecoder (addr);
  39. }
  40. //
  41. // C++: static Ptr_OCRHMMDecoder cv::text::OCRHMMDecoder::create(Ptr_OCRHMMDecoder_ClassifierCallback classifier, String vocabulary, Mat transition_probabilities_table, Mat emission_probabilities_table, int mode = OCR_DECODER_VITERBI)
  42. //
  43. // Unknown type 'Ptr_OCRHMMDecoder_ClassifierCallback' (I), skipping the function
  44. //
  45. // C++: static Ptr_OCRHMMDecoder cv::text::OCRHMMDecoder::create(String filename, String vocabulary, Mat transition_probabilities_table, Mat emission_probabilities_table, int mode = OCR_DECODER_VITERBI, int classifier = OCR_KNN_CLASSIFIER)
  46. //
  47. //javadoc: OCRHMMDecoder::create(filename, vocabulary, transition_probabilities_table, emission_probabilities_table, mode, classifier)
  48. public static OCRHMMDecoder create (string filename, string vocabulary, Mat transition_probabilities_table, Mat emission_probabilities_table, int mode, int classifier)
  49. {
  50. if (transition_probabilities_table != null)
  51. transition_probabilities_table.ThrowIfDisposed ();
  52. if (emission_probabilities_table != null)
  53. emission_probabilities_table.ThrowIfDisposed ();
  54. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  55. OCRHMMDecoder retVal = OCRHMMDecoder.__fromPtr__ (text_OCRHMMDecoder_create_10 (filename, vocabulary, transition_probabilities_table.nativeObj, emission_probabilities_table.nativeObj, mode, classifier));
  56. return retVal;
  57. #else
  58. return null;
  59. #endif
  60. }
  61. //javadoc: OCRHMMDecoder::create(filename, vocabulary, transition_probabilities_table, emission_probabilities_table, mode)
  62. public static OCRHMMDecoder create (string filename, string vocabulary, Mat transition_probabilities_table, Mat emission_probabilities_table, int mode)
  63. {
  64. if (transition_probabilities_table != null)
  65. transition_probabilities_table.ThrowIfDisposed ();
  66. if (emission_probabilities_table != null)
  67. emission_probabilities_table.ThrowIfDisposed ();
  68. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  69. OCRHMMDecoder retVal = OCRHMMDecoder.__fromPtr__ (text_OCRHMMDecoder_create_11 (filename, vocabulary, transition_probabilities_table.nativeObj, emission_probabilities_table.nativeObj, mode));
  70. return retVal;
  71. #else
  72. return null;
  73. #endif
  74. }
  75. //javadoc: OCRHMMDecoder::create(filename, vocabulary, transition_probabilities_table, emission_probabilities_table)
  76. public static OCRHMMDecoder create (string filename, string vocabulary, Mat transition_probabilities_table, Mat emission_probabilities_table)
  77. {
  78. if (transition_probabilities_table != null)
  79. transition_probabilities_table.ThrowIfDisposed ();
  80. if (emission_probabilities_table != null)
  81. emission_probabilities_table.ThrowIfDisposed ();
  82. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  83. OCRHMMDecoder retVal = OCRHMMDecoder.__fromPtr__ (text_OCRHMMDecoder_create_12 (filename, vocabulary, transition_probabilities_table.nativeObj, emission_probabilities_table.nativeObj));
  84. return retVal;
  85. #else
  86. return null;
  87. #endif
  88. }
  89. //
  90. // C++: String cv::text::OCRHMMDecoder::run(Mat image, Mat mask, int min_confidence, int component_level = 0)
  91. //
  92. //javadoc: OCRHMMDecoder::run(image, mask, min_confidence, component_level)
  93. public string run (Mat image, Mat mask, int min_confidence, int component_level)
  94. {
  95. ThrowIfDisposed ();
  96. if (image != null)
  97. image.ThrowIfDisposed ();
  98. if (mask != null)
  99. mask.ThrowIfDisposed ();
  100. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  101. string retVal = Marshal.PtrToStringAnsi (text_OCRHMMDecoder_run_10 (nativeObj, image.nativeObj, mask.nativeObj, min_confidence, component_level));
  102. return retVal;
  103. #else
  104. return null;
  105. #endif
  106. }
  107. //javadoc: OCRHMMDecoder::run(image, mask, min_confidence)
  108. public string run (Mat image, Mat mask, int min_confidence)
  109. {
  110. ThrowIfDisposed ();
  111. if (image != null)
  112. image.ThrowIfDisposed ();
  113. if (mask != null)
  114. mask.ThrowIfDisposed ();
  115. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  116. string retVal = Marshal.PtrToStringAnsi (text_OCRHMMDecoder_run_11 (nativeObj, image.nativeObj, mask.nativeObj, min_confidence));
  117. return retVal;
  118. #else
  119. return null;
  120. #endif
  121. }
  122. //
  123. // C++: String cv::text::OCRHMMDecoder::run(Mat image, int min_confidence, int component_level = 0)
  124. //
  125. //javadoc: OCRHMMDecoder::run(image, min_confidence, component_level)
  126. public string run (Mat image, int min_confidence, int component_level)
  127. {
  128. ThrowIfDisposed ();
  129. if (image != null)
  130. image.ThrowIfDisposed ();
  131. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  132. string retVal = Marshal.PtrToStringAnsi (text_OCRHMMDecoder_run_12 (nativeObj, image.nativeObj, min_confidence, component_level));
  133. return retVal;
  134. #else
  135. return null;
  136. #endif
  137. }
  138. //javadoc: OCRHMMDecoder::run(image, min_confidence)
  139. public string run (Mat image, int min_confidence)
  140. {
  141. ThrowIfDisposed ();
  142. if (image != null)
  143. image.ThrowIfDisposed ();
  144. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  145. string retVal = Marshal.PtrToStringAnsi (text_OCRHMMDecoder_run_13 (nativeObj, image.nativeObj, min_confidence));
  146. return retVal;
  147. #else
  148. return null;
  149. #endif
  150. }
  151. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  152. const string LIBNAME = "__Internal";
  153. #else
  154. const string LIBNAME = "opencvforunity";
  155. #endif
  156. // C++: static Ptr_OCRHMMDecoder cv::text::OCRHMMDecoder::create(String filename, String vocabulary, Mat transition_probabilities_table, Mat emission_probabilities_table, int mode = OCR_DECODER_VITERBI, int classifier = OCR_KNN_CLASSIFIER)
  157. [DllImport (LIBNAME)]
  158. private static extern IntPtr text_OCRHMMDecoder_create_10 (string filename, string vocabulary, IntPtr transition_probabilities_table_nativeObj, IntPtr emission_probabilities_table_nativeObj, int mode, int classifier);
  159. [DllImport (LIBNAME)]
  160. private static extern IntPtr text_OCRHMMDecoder_create_11 (string filename, string vocabulary, IntPtr transition_probabilities_table_nativeObj, IntPtr emission_probabilities_table_nativeObj, int mode);
  161. [DllImport (LIBNAME)]
  162. private static extern IntPtr text_OCRHMMDecoder_create_12 (string filename, string vocabulary, IntPtr transition_probabilities_table_nativeObj, IntPtr emission_probabilities_table_nativeObj);
  163. // C++: String cv::text::OCRHMMDecoder::run(Mat image, Mat mask, int min_confidence, int component_level = 0)
  164. [DllImport (LIBNAME)]
  165. private static extern IntPtr text_OCRHMMDecoder_run_10 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr mask_nativeObj, int min_confidence, int component_level);
  166. [DllImport (LIBNAME)]
  167. private static extern IntPtr text_OCRHMMDecoder_run_11 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr mask_nativeObj, int min_confidence);
  168. // C++: String cv::text::OCRHMMDecoder::run(Mat image, int min_confidence, int component_level = 0)
  169. [DllImport (LIBNAME)]
  170. private static extern IntPtr text_OCRHMMDecoder_run_12 (IntPtr nativeObj, IntPtr image_nativeObj, int min_confidence, int component_level);
  171. [DllImport (LIBNAME)]
  172. private static extern IntPtr text_OCRHMMDecoder_run_13 (IntPtr nativeObj, IntPtr image_nativeObj, int min_confidence);
  173. // native support for java finalize()
  174. [DllImport (LIBNAME)]
  175. private static extern void text_OCRHMMDecoder_delete (IntPtr nativeObj);
  176. }
  177. }
  178. #endif