GridBoard.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.ObjdetectModule
  7. {
  8. // C++: class GridBoard
  9. /**
  10. * Planar board with grid arrangement of markers
  11. *
  12. * More common type of board. All markers are placed in the same plane in a grid arrangement.
  13. * The board image can be drawn using generateImage() method.
  14. */
  15. public class GridBoard : Board
  16. {
  17. protected override void Dispose(bool disposing)
  18. {
  19. try
  20. {
  21. if (disposing)
  22. {
  23. }
  24. if (IsEnabledDispose)
  25. {
  26. if (nativeObj != IntPtr.Zero)
  27. objdetect_GridBoard_delete(nativeObj);
  28. nativeObj = IntPtr.Zero;
  29. }
  30. }
  31. finally
  32. {
  33. base.Dispose(disposing);
  34. }
  35. }
  36. protected internal GridBoard(IntPtr addr) : base(addr) { }
  37. // internal usage only
  38. public static new GridBoard __fromPtr__(IntPtr addr) { return new GridBoard(addr); }
  39. //
  40. // C++: cv::aruco::GridBoard::GridBoard(Size size, float markerLength, float markerSeparation, Dictionary dictionary, Mat ids = Mat())
  41. //
  42. /**
  43. * GridBoard constructor
  44. *
  45. * param size number of markers in x and y directions
  46. * param markerLength marker side length (normally in meters)
  47. * param markerSeparation separation between two markers (same unit as markerLength)
  48. * param dictionary dictionary of markers indicating the type of markers
  49. * param ids set of marker ids in dictionary to use on board.
  50. */
  51. public GridBoard(Size size, float markerLength, float markerSeparation, Dictionary dictionary, Mat ids) :
  52. base(DisposableObject.ThrowIfNullIntPtr(objdetect_GridBoard_GridBoard_10(size.width, size.height, markerLength, markerSeparation, dictionary.nativeObj, ids.nativeObj)))
  53. {
  54. }
  55. /**
  56. * GridBoard constructor
  57. *
  58. * param size number of markers in x and y directions
  59. * param markerLength marker side length (normally in meters)
  60. * param markerSeparation separation between two markers (same unit as markerLength)
  61. * param dictionary dictionary of markers indicating the type of markers
  62. */
  63. public GridBoard(Size size, float markerLength, float markerSeparation, Dictionary dictionary) :
  64. base(DisposableObject.ThrowIfNullIntPtr(objdetect_GridBoard_GridBoard_11(size.width, size.height, markerLength, markerSeparation, dictionary.nativeObj)))
  65. {
  66. }
  67. //
  68. // C++: Size cv::aruco::GridBoard::getGridSize()
  69. //
  70. public Size getGridSize()
  71. {
  72. ThrowIfDisposed();
  73. double[] tmpArray = new double[2];
  74. objdetect_GridBoard_getGridSize_10(nativeObj, tmpArray);
  75. Size retVal = new Size(tmpArray);
  76. return retVal;
  77. }
  78. //
  79. // C++: float cv::aruco::GridBoard::getMarkerLength()
  80. //
  81. public float getMarkerLength()
  82. {
  83. ThrowIfDisposed();
  84. return objdetect_GridBoard_getMarkerLength_10(nativeObj);
  85. }
  86. //
  87. // C++: float cv::aruco::GridBoard::getMarkerSeparation()
  88. //
  89. public float getMarkerSeparation()
  90. {
  91. ThrowIfDisposed();
  92. return objdetect_GridBoard_getMarkerSeparation_10(nativeObj);
  93. }
  94. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  95. const string LIBNAME = "__Internal";
  96. #else
  97. const string LIBNAME = "opencvforunity";
  98. #endif
  99. // C++: cv::aruco::GridBoard::GridBoard(Size size, float markerLength, float markerSeparation, Dictionary dictionary, Mat ids = Mat())
  100. [DllImport(LIBNAME)]
  101. private static extern IntPtr objdetect_GridBoard_GridBoard_10(double size_width, double size_height, float markerLength, float markerSeparation, IntPtr dictionary_nativeObj, IntPtr ids_nativeObj);
  102. [DllImport(LIBNAME)]
  103. private static extern IntPtr objdetect_GridBoard_GridBoard_11(double size_width, double size_height, float markerLength, float markerSeparation, IntPtr dictionary_nativeObj);
  104. // C++: Size cv::aruco::GridBoard::getGridSize()
  105. [DllImport(LIBNAME)]
  106. private static extern void objdetect_GridBoard_getGridSize_10(IntPtr nativeObj, double[] retVal);
  107. // C++: float cv::aruco::GridBoard::getMarkerLength()
  108. [DllImport(LIBNAME)]
  109. private static extern float objdetect_GridBoard_getMarkerLength_10(IntPtr nativeObj);
  110. // C++: float cv::aruco::GridBoard::getMarkerSeparation()
  111. [DllImport(LIBNAME)]
  112. private static extern float objdetect_GridBoard_getMarkerSeparation_10(IntPtr nativeObj);
  113. // native support for java finalize()
  114. [DllImport(LIBNAME)]
  115. private static extern void objdetect_GridBoard_delete(IntPtr nativeObj);
  116. }
  117. }