DictValue.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. #if !UNITY_WSA_10_0
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.DnnModule {
  8. // C++: class DictValue
  9. //javadoc: DictValue
  10. public class DictValue : DisposableOpenCVObject {
  11. protected override void Dispose(bool disposing) {
  12. #if (UNITY_ANDROID && !UNITY_EDITOR)
  13. try {
  14. if (disposing) {
  15. }
  16. if (IsEnabledDispose) {
  17. if (nativeObj != IntPtr.Zero)
  18. dnn_DictValue_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal DictValue(IntPtr addr)
  29. : base(addr) {
  30. }
  31. public IntPtr getNativeObjAddr() {
  32. return nativeObj;
  33. }
  34. // internal usage only
  35. public static DictValue __fromPtr__(IntPtr addr) {
  36. return new DictValue(addr);
  37. }
  38. //
  39. // C++: cv::dnn::DictValue::DictValue(String s)
  40. //
  41. //javadoc: DictValue::DictValue(s)
  42. public DictValue(string s) {
  43. #if (UNITY_ANDROID && !UNITY_EDITOR)
  44. nativeObj = dnn_DictValue_DictValue_10(s);
  45. return;
  46. #else
  47. return;
  48. #endif
  49. }
  50. //
  51. // C++: cv::dnn::DictValue::DictValue(double p)
  52. //
  53. //javadoc: DictValue::DictValue(p)
  54. public DictValue(double p) {
  55. #if (UNITY_ANDROID && !UNITY_EDITOR)
  56. nativeObj = dnn_DictValue_DictValue_11(p);
  57. return;
  58. #else
  59. return;
  60. #endif
  61. }
  62. //
  63. // C++: cv::dnn::DictValue::DictValue(int i)
  64. //
  65. //javadoc: DictValue::DictValue(i)
  66. public DictValue(int i) {
  67. #if (UNITY_ANDROID && !UNITY_EDITOR)
  68. nativeObj = dnn_DictValue_DictValue_12(i);
  69. return;
  70. #else
  71. return;
  72. #endif
  73. }
  74. //
  75. // C++: String cv::dnn::DictValue::getStringValue(int idx = -1)
  76. //
  77. //javadoc: DictValue::getStringValue(idx)
  78. public string getStringValue(int idx) {
  79. ThrowIfDisposed();
  80. #if (UNITY_ANDROID && !UNITY_EDITOR)
  81. string retVal = Marshal.PtrToStringAnsi(dnn_DictValue_getStringValue_10(nativeObj, idx));
  82. return retVal;
  83. #else
  84. return null;
  85. #endif
  86. }
  87. //javadoc: DictValue::getStringValue()
  88. public string getStringValue() {
  89. ThrowIfDisposed();
  90. #if (UNITY_ANDROID && !UNITY_EDITOR)
  91. string retVal = Marshal.PtrToStringAnsi(dnn_DictValue_getStringValue_11(nativeObj));
  92. return retVal;
  93. #else
  94. return null;
  95. #endif
  96. }
  97. //
  98. // C++: bool cv::dnn::DictValue::isInt()
  99. //
  100. //javadoc: DictValue::isInt()
  101. public bool isInt() {
  102. ThrowIfDisposed();
  103. #if (UNITY_ANDROID && !UNITY_EDITOR)
  104. bool retVal = dnn_DictValue_isInt_10(nativeObj);
  105. return retVal;
  106. #else
  107. return false;
  108. #endif
  109. }
  110. //
  111. // C++: bool cv::dnn::DictValue::isReal()
  112. //
  113. //javadoc: DictValue::isReal()
  114. public bool isReal() {
  115. ThrowIfDisposed();
  116. #if (UNITY_ANDROID && !UNITY_EDITOR)
  117. bool retVal = dnn_DictValue_isReal_10(nativeObj);
  118. return retVal;
  119. #else
  120. return false;
  121. #endif
  122. }
  123. //
  124. // C++: bool cv::dnn::DictValue::isString()
  125. //
  126. //javadoc: DictValue::isString()
  127. public bool isString() {
  128. ThrowIfDisposed();
  129. #if (UNITY_ANDROID && !UNITY_EDITOR)
  130. bool retVal = dnn_DictValue_isString_10(nativeObj);
  131. return retVal;
  132. #else
  133. return false;
  134. #endif
  135. }
  136. //
  137. // C++: double cv::dnn::DictValue::getRealValue(int idx = -1)
  138. //
  139. //javadoc: DictValue::getRealValue(idx)
  140. public double getRealValue(int idx) {
  141. ThrowIfDisposed();
  142. #if (UNITY_ANDROID && !UNITY_EDITOR)
  143. double retVal = dnn_DictValue_getRealValue_10(nativeObj, idx);
  144. return retVal;
  145. #else
  146. return -1;
  147. #endif
  148. }
  149. //javadoc: DictValue::getRealValue()
  150. public double getRealValue() {
  151. ThrowIfDisposed();
  152. #if (UNITY_ANDROID && !UNITY_EDITOR)
  153. double retVal = dnn_DictValue_getRealValue_11(nativeObj);
  154. return retVal;
  155. #else
  156. return -1;
  157. #endif
  158. }
  159. //
  160. // C++: int cv::dnn::DictValue::getIntValue(int idx = -1)
  161. //
  162. //javadoc: DictValue::getIntValue(idx)
  163. public int getIntValue(int idx) {
  164. ThrowIfDisposed();
  165. #if (UNITY_ANDROID && !UNITY_EDITOR)
  166. int retVal = dnn_DictValue_getIntValue_10(nativeObj, idx);
  167. return retVal;
  168. #else
  169. return -1;
  170. #endif
  171. }
  172. //javadoc: DictValue::getIntValue()
  173. public int getIntValue() {
  174. ThrowIfDisposed();
  175. #if (UNITY_ANDROID && !UNITY_EDITOR)
  176. int retVal = dnn_DictValue_getIntValue_11(nativeObj);
  177. return retVal;
  178. #else
  179. return -1;
  180. #endif
  181. }
  182. #if (UNITY_ANDROID && !UNITY_EDITOR)
  183. const string LIBNAME = "opencvforunity";
  184. // C++: cv::dnn::DictValue::DictValue(String s)
  185. [DllImport(LIBNAME)]
  186. private static extern IntPtr dnn_DictValue_DictValue_10(string s);
  187. // C++: cv::dnn::DictValue::DictValue(double p)
  188. [DllImport(LIBNAME)]
  189. private static extern IntPtr dnn_DictValue_DictValue_11(double p);
  190. // C++: cv::dnn::DictValue::DictValue(int i)
  191. [DllImport(LIBNAME)]
  192. private static extern IntPtr dnn_DictValue_DictValue_12(int i);
  193. // C++: String cv::dnn::DictValue::getStringValue(int idx = -1)
  194. [DllImport(LIBNAME)]
  195. private static extern IntPtr dnn_DictValue_getStringValue_10(IntPtr nativeObj, int idx);
  196. [DllImport(LIBNAME)]
  197. private static extern IntPtr dnn_DictValue_getStringValue_11(IntPtr nativeObj);
  198. // C++: bool cv::dnn::DictValue::isInt()
  199. [DllImport(LIBNAME)]
  200. private static extern bool dnn_DictValue_isInt_10(IntPtr nativeObj);
  201. // C++: bool cv::dnn::DictValue::isReal()
  202. [DllImport(LIBNAME)]
  203. private static extern bool dnn_DictValue_isReal_10(IntPtr nativeObj);
  204. // C++: bool cv::dnn::DictValue::isString()
  205. [DllImport(LIBNAME)]
  206. private static extern bool dnn_DictValue_isString_10(IntPtr nativeObj);
  207. // C++: double cv::dnn::DictValue::getRealValue(int idx = -1)
  208. [DllImport(LIBNAME)]
  209. private static extern double dnn_DictValue_getRealValue_10(IntPtr nativeObj, int idx);
  210. [DllImport(LIBNAME)]
  211. private static extern double dnn_DictValue_getRealValue_11(IntPtr nativeObj);
  212. // C++: int cv::dnn::DictValue::getIntValue(int idx = -1)
  213. [DllImport(LIBNAME)]
  214. private static extern int dnn_DictValue_getIntValue_10(IntPtr nativeObj, int idx);
  215. [DllImport(LIBNAME)]
  216. private static extern int dnn_DictValue_getIntValue_11(IntPtr nativeObj);
  217. // native support for java finalize()
  218. [DllImport(LIBNAME)]
  219. private static extern void dnn_DictValue_delete(IntPtr nativeObj);
  220. #endif
  221. }
  222. }
  223. #endif