Board.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 Board
  10. //javadoc: Board
  11. public class Board : 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. aruco_Board_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal Board (IntPtr addr) : base (addr) { }
  32. public IntPtr getNativeObjAddr () { return nativeObj; }
  33. // internal usage only
  34. public static Board __fromPtr__ (IntPtr addr) { return new Board (addr); }
  35. //
  36. // C++: static Ptr_Board cv::aruco::Board::create(vector_Mat objPoints, Ptr_Dictionary dictionary, Mat ids)
  37. //
  38. //javadoc: Board::create(objPoints, dictionary, ids)
  39. public static Board create (List<Mat> objPoints, Dictionary dictionary, Mat ids)
  40. {
  41. if (dictionary != null) dictionary.ThrowIfDisposed ();
  42. if (ids != null) ids.ThrowIfDisposed ();
  43. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  44. Mat objPoints_mat = Converters.vector_Mat_to_Mat(objPoints);
  45. Board retVal = Board.__fromPtr__(aruco_Board_create_10(objPoints_mat.nativeObj, dictionary.getNativeObjAddr(), ids.nativeObj));
  46. return retVal;
  47. #else
  48. return null;
  49. #endif
  50. }
  51. //
  52. // C++: vector_vector_Point3f Board::objPoints
  53. //
  54. //javadoc: Board::get_objPoints()
  55. public List<MatOfPoint3f> get_objPoints ()
  56. {
  57. ThrowIfDisposed ();
  58. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  59. List<MatOfPoint3f> retVal = new List<MatOfPoint3f>();
  60. Mat retValMat = new Mat(aruco_Board_get_1objPoints_10(nativeObj));
  61. Converters.Mat_to_vector_vector_Point3f(retValMat, retVal);
  62. return retVal;
  63. #else
  64. return null;
  65. #endif
  66. }
  67. //
  68. // C++: Ptr_Dictionary Board::dictionary
  69. //
  70. //javadoc: Board::get_dictionary()
  71. public Dictionary get_dictionary ()
  72. {
  73. ThrowIfDisposed ();
  74. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  75. Dictionary retVal = Dictionary.__fromPtr__(aruco_Board_get_1dictionary_10(nativeObj));
  76. return retVal;
  77. #else
  78. return null;
  79. #endif
  80. }
  81. //
  82. // C++: vector_int Board::ids
  83. //
  84. //javadoc: Board::get_ids()
  85. public MatOfInt get_ids ()
  86. {
  87. ThrowIfDisposed ();
  88. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  89. MatOfInt retVal = MatOfInt.fromNativeAddr(aruco_Board_get_1ids_10(nativeObj));
  90. return retVal;
  91. #else
  92. return null;
  93. #endif
  94. }
  95. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  96. const string LIBNAME = "__Internal";
  97. #else
  98. const string LIBNAME = "opencvforunity";
  99. #endif
  100. // C++: static Ptr_Board cv::aruco::Board::create(vector_Mat objPoints, Ptr_Dictionary dictionary, Mat ids)
  101. [DllImport (LIBNAME)]
  102. private static extern IntPtr aruco_Board_create_10 (IntPtr objPoints_mat_nativeObj, IntPtr dictionary_nativeObj, IntPtr ids_nativeObj);
  103. // C++: vector_vector_Point3f Board::objPoints
  104. [DllImport (LIBNAME)]
  105. private static extern IntPtr aruco_Board_get_1objPoints_10 (IntPtr nativeObj);
  106. // C++: Ptr_Dictionary Board::dictionary
  107. [DllImport (LIBNAME)]
  108. private static extern IntPtr aruco_Board_get_1dictionary_10 (IntPtr nativeObj);
  109. // C++: vector_int Board::ids
  110. [DllImport (LIBNAME)]
  111. private static extern IntPtr aruco_Board_get_1ids_10 (IntPtr nativeObj);
  112. // native support for java finalize()
  113. [DllImport (LIBNAME)]
  114. private static extern void aruco_Board_delete (IntPtr nativeObj);
  115. }
  116. }