QRCodeDetector.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. 
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.ObjdetectModule
  8. {
  9. // C++: class QRCodeDetector
  10. //javadoc: QRCodeDetector
  11. public class QRCodeDetector : DisposableOpenCVObject
  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. objdetect_QRCodeDetector_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal QRCodeDetector (IntPtr addr) : base (addr) { }
  32. public IntPtr getNativeObjAddr () { return nativeObj; }
  33. // internal usage only
  34. public static QRCodeDetector __fromPtr__ (IntPtr addr) { return new QRCodeDetector (addr); }
  35. //
  36. // C++: cv::QRCodeDetector::QRCodeDetector()
  37. //
  38. //javadoc: QRCodeDetector::QRCodeDetector()
  39. public QRCodeDetector ()
  40. {
  41. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  42. nativeObj = objdetect_QRCodeDetector_QRCodeDetector_10();
  43. return;
  44. #else
  45. return null;
  46. #endif
  47. }
  48. //
  49. // C++: bool cv::QRCodeDetector::detect(Mat img, Mat& points)
  50. //
  51. //javadoc: QRCodeDetector::detect(img, points)
  52. public bool detect (Mat img, Mat points)
  53. {
  54. ThrowIfDisposed ();
  55. if (img != null) img.ThrowIfDisposed ();
  56. if (points != null) points.ThrowIfDisposed ();
  57. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  58. bool retVal = objdetect_QRCodeDetector_detect_10(nativeObj, img.nativeObj, points.nativeObj);
  59. return retVal;
  60. #else
  61. return false;
  62. #endif
  63. }
  64. //
  65. // C++: string cv::QRCodeDetector::decode(Mat img, Mat points, Mat& straight_qrcode = Mat())
  66. //
  67. //javadoc: QRCodeDetector::decode(img, points, straight_qrcode)
  68. public string decode (Mat img, Mat points, Mat straight_qrcode)
  69. {
  70. ThrowIfDisposed ();
  71. if (img != null) img.ThrowIfDisposed ();
  72. if (points != null) points.ThrowIfDisposed ();
  73. if (straight_qrcode != null) straight_qrcode.ThrowIfDisposed ();
  74. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  75. string retVal = Marshal.PtrToStringAnsi (objdetect_QRCodeDetector_decode_10(nativeObj, img.nativeObj, points.nativeObj, straight_qrcode.nativeObj));
  76. return retVal;
  77. #else
  78. return null;
  79. #endif
  80. }
  81. //javadoc: QRCodeDetector::decode(img, points)
  82. public string decode (Mat img, Mat points)
  83. {
  84. ThrowIfDisposed ();
  85. if (img != null) img.ThrowIfDisposed ();
  86. if (points != null) points.ThrowIfDisposed ();
  87. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  88. string retVal = Marshal.PtrToStringAnsi (objdetect_QRCodeDetector_decode_11(nativeObj, img.nativeObj, points.nativeObj));
  89. return retVal;
  90. #else
  91. return null;
  92. #endif
  93. }
  94. //
  95. // C++: string cv::QRCodeDetector::detectAndDecode(Mat img, Mat& points = Mat(), Mat& straight_qrcode = Mat())
  96. //
  97. //javadoc: QRCodeDetector::detectAndDecode(img, points, straight_qrcode)
  98. public string detectAndDecode (Mat img, Mat points, Mat straight_qrcode)
  99. {
  100. ThrowIfDisposed ();
  101. if (img != null) img.ThrowIfDisposed ();
  102. if (points != null) points.ThrowIfDisposed ();
  103. if (straight_qrcode != null) straight_qrcode.ThrowIfDisposed ();
  104. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  105. string retVal = Marshal.PtrToStringAnsi (objdetect_QRCodeDetector_detectAndDecode_10(nativeObj, img.nativeObj, points.nativeObj, straight_qrcode.nativeObj));
  106. return retVal;
  107. #else
  108. return null;
  109. #endif
  110. }
  111. //javadoc: QRCodeDetector::detectAndDecode(img, points)
  112. public string detectAndDecode (Mat img, Mat points)
  113. {
  114. ThrowIfDisposed ();
  115. if (img != null) img.ThrowIfDisposed ();
  116. if (points != null) points.ThrowIfDisposed ();
  117. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  118. string retVal = Marshal.PtrToStringAnsi (objdetect_QRCodeDetector_detectAndDecode_11(nativeObj, img.nativeObj, points.nativeObj));
  119. return retVal;
  120. #else
  121. return null;
  122. #endif
  123. }
  124. //javadoc: QRCodeDetector::detectAndDecode(img)
  125. public string detectAndDecode (Mat img)
  126. {
  127. ThrowIfDisposed ();
  128. if (img != null) img.ThrowIfDisposed ();
  129. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  130. string retVal = Marshal.PtrToStringAnsi (objdetect_QRCodeDetector_detectAndDecode_12(nativeObj, img.nativeObj));
  131. return retVal;
  132. #else
  133. return null;
  134. #endif
  135. }
  136. //
  137. // C++: void cv::QRCodeDetector::setEpsX(double epsX)
  138. //
  139. //javadoc: QRCodeDetector::setEpsX(epsX)
  140. public void setEpsX (double epsX)
  141. {
  142. ThrowIfDisposed ();
  143. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  144. objdetect_QRCodeDetector_setEpsX_10(nativeObj, epsX);
  145. return;
  146. #else
  147. return;
  148. #endif
  149. }
  150. //
  151. // C++: void cv::QRCodeDetector::setEpsY(double epsY)
  152. //
  153. //javadoc: QRCodeDetector::setEpsY(epsY)
  154. public void setEpsY (double epsY)
  155. {
  156. ThrowIfDisposed ();
  157. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  158. objdetect_QRCodeDetector_setEpsY_10(nativeObj, epsY);
  159. return;
  160. #else
  161. return;
  162. #endif
  163. }
  164. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  165. const string LIBNAME = "__Internal";
  166. #else
  167. const string LIBNAME = "opencvforunity";
  168. #endif
  169. // C++: cv::QRCodeDetector::QRCodeDetector()
  170. [DllImport (LIBNAME)]
  171. private static extern IntPtr objdetect_QRCodeDetector_QRCodeDetector_10 ();
  172. // C++: bool cv::QRCodeDetector::detect(Mat img, Mat& points)
  173. [DllImport (LIBNAME)]
  174. private static extern bool objdetect_QRCodeDetector_detect_10 (IntPtr nativeObj, IntPtr img_nativeObj, IntPtr points_nativeObj);
  175. // C++: string cv::QRCodeDetector::decode(Mat img, Mat points, Mat& straight_qrcode = Mat())
  176. [DllImport (LIBNAME)]
  177. private static extern IntPtr objdetect_QRCodeDetector_decode_10 (IntPtr nativeObj, IntPtr img_nativeObj, IntPtr points_nativeObj, IntPtr straight_qrcode_nativeObj);
  178. [DllImport (LIBNAME)]
  179. private static extern IntPtr objdetect_QRCodeDetector_decode_11 (IntPtr nativeObj, IntPtr img_nativeObj, IntPtr points_nativeObj);
  180. // C++: string cv::QRCodeDetector::detectAndDecode(Mat img, Mat& points = Mat(), Mat& straight_qrcode = Mat())
  181. [DllImport (LIBNAME)]
  182. private static extern IntPtr objdetect_QRCodeDetector_detectAndDecode_10 (IntPtr nativeObj, IntPtr img_nativeObj, IntPtr points_nativeObj, IntPtr straight_qrcode_nativeObj);
  183. [DllImport (LIBNAME)]
  184. private static extern IntPtr objdetect_QRCodeDetector_detectAndDecode_11 (IntPtr nativeObj, IntPtr img_nativeObj, IntPtr points_nativeObj);
  185. [DllImport (LIBNAME)]
  186. private static extern IntPtr objdetect_QRCodeDetector_detectAndDecode_12 (IntPtr nativeObj, IntPtr img_nativeObj);
  187. // C++: void cv::QRCodeDetector::setEpsX(double epsX)
  188. [DllImport (LIBNAME)]
  189. private static extern void objdetect_QRCodeDetector_setEpsX_10 (IntPtr nativeObj, double epsX);
  190. // C++: void cv::QRCodeDetector::setEpsY(double epsY)
  191. [DllImport (LIBNAME)]
  192. private static extern void objdetect_QRCodeDetector_setEpsY_10 (IntPtr nativeObj, double epsY);
  193. // native support for java finalize()
  194. [DllImport (LIBNAME)]
  195. private static extern void objdetect_QRCodeDetector_delete (IntPtr nativeObj);
  196. }
  197. }