Dictionary.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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 Dictionary
  10. //javadoc: Dictionary
  11. public class Dictionary : 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_Dictionary_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal Dictionary (IntPtr addr) : base (addr) { }
  32. public IntPtr getNativeObjAddr () { return nativeObj; }
  33. // internal usage only
  34. public static Dictionary __fromPtr__ (IntPtr addr) { return new Dictionary (addr); }
  35. //
  36. // C++: static Mat cv::aruco::Dictionary::getBitsFromByteList(Mat byteList, int markerSize)
  37. //
  38. //javadoc: Dictionary::getBitsFromByteList(byteList, markerSize)
  39. public static Mat getBitsFromByteList (Mat byteList, int markerSize)
  40. {
  41. if (byteList != null) byteList.ThrowIfDisposed ();
  42. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  43. Mat retVal = new Mat(aruco_Dictionary_getBitsFromByteList_10(byteList.nativeObj, markerSize));
  44. return retVal;
  45. #else
  46. return null;
  47. #endif
  48. }
  49. //
  50. // C++: static Mat cv::aruco::Dictionary::getByteListFromBits(Mat bits)
  51. //
  52. //javadoc: Dictionary::getByteListFromBits(bits)
  53. public static Mat getByteListFromBits (Mat bits)
  54. {
  55. if (bits != null) bits.ThrowIfDisposed ();
  56. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  57. Mat retVal = new Mat(aruco_Dictionary_getByteListFromBits_10(bits.nativeObj));
  58. return retVal;
  59. #else
  60. return null;
  61. #endif
  62. }
  63. //
  64. // C++: static Ptr_Dictionary cv::aruco::Dictionary::create(int nMarkers, int markerSize, Ptr_Dictionary baseDictionary, int randomSeed = 0)
  65. //
  66. //javadoc: Dictionary::create_from(nMarkers, markerSize, baseDictionary, randomSeed)
  67. public static Dictionary create_from (int nMarkers, int markerSize, Dictionary baseDictionary, int randomSeed)
  68. {
  69. if (baseDictionary != null) baseDictionary.ThrowIfDisposed ();
  70. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  71. Dictionary retVal = Dictionary.__fromPtr__(aruco_Dictionary_create_1from_10(nMarkers, markerSize, baseDictionary.getNativeObjAddr(), randomSeed));
  72. return retVal;
  73. #else
  74. return null;
  75. #endif
  76. }
  77. //javadoc: Dictionary::create_from(nMarkers, markerSize, baseDictionary)
  78. public static Dictionary create_from (int nMarkers, int markerSize, Dictionary baseDictionary)
  79. {
  80. if (baseDictionary != null) baseDictionary.ThrowIfDisposed ();
  81. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  82. Dictionary retVal = Dictionary.__fromPtr__(aruco_Dictionary_create_1from_11(nMarkers, markerSize, baseDictionary.getNativeObjAddr()));
  83. return retVal;
  84. #else
  85. return null;
  86. #endif
  87. }
  88. //
  89. // C++: static Ptr_Dictionary cv::aruco::Dictionary::create(int nMarkers, int markerSize, int randomSeed = 0)
  90. //
  91. //javadoc: Dictionary::create(nMarkers, markerSize, randomSeed)
  92. public static Dictionary create (int nMarkers, int markerSize, int randomSeed)
  93. {
  94. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  95. Dictionary retVal = Dictionary.__fromPtr__(aruco_Dictionary_create_10(nMarkers, markerSize, randomSeed));
  96. return retVal;
  97. #else
  98. return null;
  99. #endif
  100. }
  101. //javadoc: Dictionary::create(nMarkers, markerSize)
  102. public static Dictionary create (int nMarkers, int markerSize)
  103. {
  104. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  105. Dictionary retVal = Dictionary.__fromPtr__(aruco_Dictionary_create_11(nMarkers, markerSize));
  106. return retVal;
  107. #else
  108. return null;
  109. #endif
  110. }
  111. //
  112. // C++: static Ptr_Dictionary cv::aruco::Dictionary::get(int dict)
  113. //
  114. //javadoc: Dictionary::get(dict)
  115. public static Dictionary get (int dict)
  116. {
  117. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  118. Dictionary retVal = Dictionary.__fromPtr__(aruco_Dictionary_get_10(dict));
  119. return retVal;
  120. #else
  121. return null;
  122. #endif
  123. }
  124. //
  125. // C++: void cv::aruco::Dictionary::drawMarker(int id, int sidePixels, Mat& _img, int borderBits = 1)
  126. //
  127. //javadoc: Dictionary::drawMarker(id, sidePixels, _img, borderBits)
  128. public void drawMarker (int id, int sidePixels, Mat _img, int borderBits)
  129. {
  130. ThrowIfDisposed ();
  131. if (_img != null) _img.ThrowIfDisposed ();
  132. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  133. aruco_Dictionary_drawMarker_10(nativeObj, id, sidePixels, _img.nativeObj, borderBits);
  134. return;
  135. #else
  136. return;
  137. #endif
  138. }
  139. //javadoc: Dictionary::drawMarker(id, sidePixels, _img)
  140. public void drawMarker (int id, int sidePixels, Mat _img)
  141. {
  142. ThrowIfDisposed ();
  143. if (_img != null) _img.ThrowIfDisposed ();
  144. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  145. aruco_Dictionary_drawMarker_11(nativeObj, id, sidePixels, _img.nativeObj);
  146. return;
  147. #else
  148. return;
  149. #endif
  150. }
  151. //
  152. // C++: Mat Dictionary::bytesList
  153. //
  154. //javadoc: Dictionary::get_bytesList()
  155. public Mat get_bytesList ()
  156. {
  157. ThrowIfDisposed ();
  158. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  159. Mat retVal = new Mat(aruco_Dictionary_get_1bytesList_10(nativeObj));
  160. return retVal;
  161. #else
  162. return null;
  163. #endif
  164. }
  165. //
  166. // C++: void Dictionary::bytesList
  167. //
  168. //javadoc: Dictionary::set_bytesList(bytesList)
  169. public void set_bytesList (Mat bytesList)
  170. {
  171. ThrowIfDisposed ();
  172. if (bytesList != null) bytesList.ThrowIfDisposed ();
  173. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  174. aruco_Dictionary_set_1bytesList_10(nativeObj, bytesList.nativeObj);
  175. return;
  176. #else
  177. return;
  178. #endif
  179. }
  180. //
  181. // C++: int Dictionary::markerSize
  182. //
  183. //javadoc: Dictionary::get_markerSize()
  184. public int get_markerSize ()
  185. {
  186. ThrowIfDisposed ();
  187. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  188. int retVal = aruco_Dictionary_get_1markerSize_10(nativeObj);
  189. return retVal;
  190. #else
  191. return -1;
  192. #endif
  193. }
  194. //
  195. // C++: void Dictionary::markerSize
  196. //
  197. //javadoc: Dictionary::set_markerSize(markerSize)
  198. public void set_markerSize (int markerSize)
  199. {
  200. ThrowIfDisposed ();
  201. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  202. aruco_Dictionary_set_1markerSize_10(nativeObj, markerSize);
  203. return;
  204. #else
  205. return;
  206. #endif
  207. }
  208. //
  209. // C++: int Dictionary::maxCorrectionBits
  210. //
  211. //javadoc: Dictionary::get_maxCorrectionBits()
  212. public int get_maxCorrectionBits ()
  213. {
  214. ThrowIfDisposed ();
  215. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  216. int retVal = aruco_Dictionary_get_1maxCorrectionBits_10(nativeObj);
  217. return retVal;
  218. #else
  219. return -1;
  220. #endif
  221. }
  222. //
  223. // C++: void Dictionary::maxCorrectionBits
  224. //
  225. //javadoc: Dictionary::set_maxCorrectionBits(maxCorrectionBits)
  226. public void set_maxCorrectionBits (int maxCorrectionBits)
  227. {
  228. ThrowIfDisposed ();
  229. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  230. aruco_Dictionary_set_1maxCorrectionBits_10(nativeObj, maxCorrectionBits);
  231. return;
  232. #else
  233. return;
  234. #endif
  235. }
  236. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  237. const string LIBNAME = "__Internal";
  238. #else
  239. const string LIBNAME = "opencvforunity";
  240. #endif
  241. // C++: static Mat cv::aruco::Dictionary::getBitsFromByteList(Mat byteList, int markerSize)
  242. [DllImport (LIBNAME)]
  243. private static extern IntPtr aruco_Dictionary_getBitsFromByteList_10 (IntPtr byteList_nativeObj, int markerSize);
  244. // C++: static Mat cv::aruco::Dictionary::getByteListFromBits(Mat bits)
  245. [DllImport (LIBNAME)]
  246. private static extern IntPtr aruco_Dictionary_getByteListFromBits_10 (IntPtr bits_nativeObj);
  247. // C++: static Ptr_Dictionary cv::aruco::Dictionary::create(int nMarkers, int markerSize, Ptr_Dictionary baseDictionary, int randomSeed = 0)
  248. [DllImport (LIBNAME)]
  249. private static extern IntPtr aruco_Dictionary_create_1from_10 (int nMarkers, int markerSize, IntPtr baseDictionary_nativeObj, int randomSeed);
  250. [DllImport (LIBNAME)]
  251. private static extern IntPtr aruco_Dictionary_create_1from_11 (int nMarkers, int markerSize, IntPtr baseDictionary_nativeObj);
  252. // C++: static Ptr_Dictionary cv::aruco::Dictionary::create(int nMarkers, int markerSize, int randomSeed = 0)
  253. [DllImport (LIBNAME)]
  254. private static extern IntPtr aruco_Dictionary_create_10 (int nMarkers, int markerSize, int randomSeed);
  255. [DllImport (LIBNAME)]
  256. private static extern IntPtr aruco_Dictionary_create_11 (int nMarkers, int markerSize);
  257. // C++: static Ptr_Dictionary cv::aruco::Dictionary::get(int dict)
  258. [DllImport (LIBNAME)]
  259. private static extern IntPtr aruco_Dictionary_get_10 (int dict);
  260. // C++: void cv::aruco::Dictionary::drawMarker(int id, int sidePixels, Mat& _img, int borderBits = 1)
  261. [DllImport (LIBNAME)]
  262. private static extern void aruco_Dictionary_drawMarker_10 (IntPtr nativeObj, int id, int sidePixels, IntPtr _img_nativeObj, int borderBits);
  263. [DllImport (LIBNAME)]
  264. private static extern void aruco_Dictionary_drawMarker_11 (IntPtr nativeObj, int id, int sidePixels, IntPtr _img_nativeObj);
  265. // C++: Mat Dictionary::bytesList
  266. [DllImport (LIBNAME)]
  267. private static extern IntPtr aruco_Dictionary_get_1bytesList_10 (IntPtr nativeObj);
  268. // C++: void Dictionary::bytesList
  269. [DllImport (LIBNAME)]
  270. private static extern void aruco_Dictionary_set_1bytesList_10 (IntPtr nativeObj, IntPtr bytesList_nativeObj);
  271. // C++: int Dictionary::markerSize
  272. [DllImport (LIBNAME)]
  273. private static extern int aruco_Dictionary_get_1markerSize_10 (IntPtr nativeObj);
  274. // C++: void Dictionary::markerSize
  275. [DllImport (LIBNAME)]
  276. private static extern void aruco_Dictionary_set_1markerSize_10 (IntPtr nativeObj, int markerSize);
  277. // C++: int Dictionary::maxCorrectionBits
  278. [DllImport (LIBNAME)]
  279. private static extern int aruco_Dictionary_get_1maxCorrectionBits_10 (IntPtr nativeObj);
  280. // C++: void Dictionary::maxCorrectionBits
  281. [DllImport (LIBNAME)]
  282. private static extern void aruco_Dictionary_set_1maxCorrectionBits_10 (IntPtr nativeObj, int maxCorrectionBits);
  283. // native support for java finalize()
  284. [DllImport (LIBNAME)]
  285. private static extern void aruco_Dictionary_delete (IntPtr nativeObj);
  286. }
  287. }