GridBoard.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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.ArucoModule
  8. {
  9. // C++: class GridBoard
  10. //javadoc: GridBoard
  11. public class GridBoard : Board
  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. aruco_GridBoard_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal GridBoard (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new GridBoard __fromPtr__ (IntPtr addr) { return new GridBoard (addr); }
  34. //
  35. // C++: static Ptr_GridBoard cv::aruco::GridBoard::create(int markersX, int markersY, float markerLength, float markerSeparation, Ptr_Dictionary dictionary, int firstMarker = 0)
  36. //
  37. //javadoc: GridBoard::create(markersX, markersY, markerLength, markerSeparation, dictionary, firstMarker)
  38. public static GridBoard create (int markersX, int markersY, float markerLength, float markerSeparation, Dictionary dictionary, int firstMarker)
  39. {
  40. if (dictionary != null) dictionary.ThrowIfDisposed ();
  41. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  42. GridBoard retVal = GridBoard.__fromPtr__(aruco_GridBoard_create_10(markersX, markersY, markerLength, markerSeparation, dictionary.getNativeObjAddr(), firstMarker));
  43. return retVal;
  44. #else
  45. return null;
  46. #endif
  47. }
  48. //javadoc: GridBoard::create(markersX, markersY, markerLength, markerSeparation, dictionary)
  49. public static GridBoard create (int markersX, int markersY, float markerLength, float markerSeparation, Dictionary dictionary)
  50. {
  51. if (dictionary != null) dictionary.ThrowIfDisposed ();
  52. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  53. GridBoard retVal = GridBoard.__fromPtr__(aruco_GridBoard_create_11(markersX, markersY, markerLength, markerSeparation, dictionary.getNativeObjAddr()));
  54. return retVal;
  55. #else
  56. return null;
  57. #endif
  58. }
  59. //
  60. // C++: Size cv::aruco::GridBoard::getGridSize()
  61. //
  62. //javadoc: GridBoard::getGridSize()
  63. public Size getGridSize ()
  64. {
  65. ThrowIfDisposed ();
  66. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  67. double[] tmpArray = new double[2];
  68. aruco_GridBoard_getGridSize_10(nativeObj, tmpArray);
  69. Size retVal = new Size (tmpArray);
  70. return retVal;
  71. #else
  72. return null;
  73. #endif
  74. }
  75. //
  76. // C++: float cv::aruco::GridBoard::getMarkerLength()
  77. //
  78. //javadoc: GridBoard::getMarkerLength()
  79. public float getMarkerLength ()
  80. {
  81. ThrowIfDisposed ();
  82. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  83. float retVal = aruco_GridBoard_getMarkerLength_10(nativeObj);
  84. return retVal;
  85. #else
  86. return -1;
  87. #endif
  88. }
  89. //
  90. // C++: float cv::aruco::GridBoard::getMarkerSeparation()
  91. //
  92. //javadoc: GridBoard::getMarkerSeparation()
  93. public float getMarkerSeparation ()
  94. {
  95. ThrowIfDisposed ();
  96. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  97. float retVal = aruco_GridBoard_getMarkerSeparation_10(nativeObj);
  98. return retVal;
  99. #else
  100. return -1;
  101. #endif
  102. }
  103. //
  104. // C++: void cv::aruco::GridBoard::draw(Size outSize, Mat& img, int marginSize = 0, int borderBits = 1)
  105. //
  106. //javadoc: GridBoard::draw(outSize, img, marginSize, borderBits)
  107. public void draw (Size outSize, Mat img, int marginSize, int borderBits)
  108. {
  109. ThrowIfDisposed ();
  110. if (img != null) img.ThrowIfDisposed ();
  111. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  112. aruco_GridBoard_draw_10(nativeObj, outSize.width, outSize.height, img.nativeObj, marginSize, borderBits);
  113. return;
  114. #else
  115. return;
  116. #endif
  117. }
  118. //javadoc: GridBoard::draw(outSize, img, marginSize)
  119. public void draw (Size outSize, Mat img, int marginSize)
  120. {
  121. ThrowIfDisposed ();
  122. if (img != null) img.ThrowIfDisposed ();
  123. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  124. aruco_GridBoard_draw_11(nativeObj, outSize.width, outSize.height, img.nativeObj, marginSize);
  125. return;
  126. #else
  127. return;
  128. #endif
  129. }
  130. //javadoc: GridBoard::draw(outSize, img)
  131. public void draw (Size outSize, Mat img)
  132. {
  133. ThrowIfDisposed ();
  134. if (img != null) img.ThrowIfDisposed ();
  135. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  136. aruco_GridBoard_draw_12(nativeObj, outSize.width, outSize.height, img.nativeObj);
  137. return;
  138. #else
  139. return;
  140. #endif
  141. }
  142. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  143. const string LIBNAME = "__Internal";
  144. #else
  145. const string LIBNAME = "opencvforunity";
  146. #endif
  147. // C++: static Ptr_GridBoard cv::aruco::GridBoard::create(int markersX, int markersY, float markerLength, float markerSeparation, Ptr_Dictionary dictionary, int firstMarker = 0)
  148. [DllImport (LIBNAME)]
  149. private static extern IntPtr aruco_GridBoard_create_10 (int markersX, int markersY, float markerLength, float markerSeparation, IntPtr dictionary_nativeObj, int firstMarker);
  150. [DllImport (LIBNAME)]
  151. private static extern IntPtr aruco_GridBoard_create_11 (int markersX, int markersY, float markerLength, float markerSeparation, IntPtr dictionary_nativeObj);
  152. // C++: Size cv::aruco::GridBoard::getGridSize()
  153. [DllImport (LIBNAME)]
  154. private static extern void aruco_GridBoard_getGridSize_10 (IntPtr nativeObj, double[] retVal);
  155. // C++: float cv::aruco::GridBoard::getMarkerLength()
  156. [DllImport (LIBNAME)]
  157. private static extern float aruco_GridBoard_getMarkerLength_10 (IntPtr nativeObj);
  158. // C++: float cv::aruco::GridBoard::getMarkerSeparation()
  159. [DllImport (LIBNAME)]
  160. private static extern float aruco_GridBoard_getMarkerSeparation_10 (IntPtr nativeObj);
  161. // C++: void cv::aruco::GridBoard::draw(Size outSize, Mat& img, int marginSize = 0, int borderBits = 1)
  162. [DllImport (LIBNAME)]
  163. private static extern void aruco_GridBoard_draw_10 (IntPtr nativeObj, double outSize_width, double outSize_height, IntPtr img_nativeObj, int marginSize, int borderBits);
  164. [DllImport (LIBNAME)]
  165. private static extern void aruco_GridBoard_draw_11 (IntPtr nativeObj, double outSize_width, double outSize_height, IntPtr img_nativeObj, int marginSize);
  166. [DllImport (LIBNAME)]
  167. private static extern void aruco_GridBoard_draw_12 (IntPtr nativeObj, double outSize_width, double outSize_height, IntPtr img_nativeObj);
  168. // native support for java finalize()
  169. [DllImport (LIBNAME)]
  170. private static extern void aruco_GridBoard_delete (IntPtr nativeObj);
  171. }
  172. }