RTrees.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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.MlModule
  8. {
  9. // C++: class RTrees
  10. //javadoc: RTrees
  11. public class RTrees : DTrees
  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. ml_RTrees_delete (nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal RTrees (IntPtr addr)
  32. : base (addr)
  33. {
  34. }
  35. // internal usage only
  36. public static new RTrees __fromPtr__ (IntPtr addr)
  37. {
  38. return new RTrees (addr);
  39. }
  40. //
  41. // C++: Mat cv::ml::RTrees::getVarImportance()
  42. //
  43. //javadoc: RTrees::getVarImportance()
  44. public Mat getVarImportance ()
  45. {
  46. ThrowIfDisposed ();
  47. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  48. Mat retVal = new Mat (ml_RTrees_getVarImportance_10 (nativeObj));
  49. return retVal;
  50. #else
  51. return null;
  52. #endif
  53. }
  54. //
  55. // C++: static Ptr_RTrees cv::ml::RTrees::create()
  56. //
  57. //javadoc: RTrees::create()
  58. public static new RTrees create ()
  59. {
  60. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  61. RTrees retVal = RTrees.__fromPtr__ (ml_RTrees_create_10 ());
  62. return retVal;
  63. #else
  64. return null;
  65. #endif
  66. }
  67. //
  68. // C++: static Ptr_RTrees cv::ml::RTrees::load(String filepath, String nodeName = String())
  69. //
  70. //javadoc: RTrees::load(filepath, nodeName)
  71. public static new RTrees load (string filepath, string nodeName)
  72. {
  73. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  74. RTrees retVal = RTrees.__fromPtr__ (ml_RTrees_load_10 (filepath, nodeName));
  75. return retVal;
  76. #else
  77. return null;
  78. #endif
  79. }
  80. //javadoc: RTrees::load(filepath)
  81. public static new RTrees load (string filepath)
  82. {
  83. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  84. RTrees retVal = RTrees.__fromPtr__ (ml_RTrees_load_11 (filepath));
  85. return retVal;
  86. #else
  87. return null;
  88. #endif
  89. }
  90. //
  91. // C++: TermCriteria cv::ml::RTrees::getTermCriteria()
  92. //
  93. //javadoc: RTrees::getTermCriteria()
  94. public TermCriteria getTermCriteria ()
  95. {
  96. ThrowIfDisposed ();
  97. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  98. double[] tmpArray = new double[3];
  99. ml_RTrees_getTermCriteria_10 (nativeObj, tmpArray);
  100. TermCriteria retVal = new TermCriteria (tmpArray);
  101. return retVal;
  102. #else
  103. return null;
  104. #endif
  105. }
  106. //
  107. // C++: bool cv::ml::RTrees::getCalculateVarImportance()
  108. //
  109. //javadoc: RTrees::getCalculateVarImportance()
  110. public bool getCalculateVarImportance ()
  111. {
  112. ThrowIfDisposed ();
  113. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  114. bool retVal = ml_RTrees_getCalculateVarImportance_10 (nativeObj);
  115. return retVal;
  116. #else
  117. return false;
  118. #endif
  119. }
  120. //
  121. // C++: int cv::ml::RTrees::getActiveVarCount()
  122. //
  123. //javadoc: RTrees::getActiveVarCount()
  124. public int getActiveVarCount ()
  125. {
  126. ThrowIfDisposed ();
  127. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  128. int retVal = ml_RTrees_getActiveVarCount_10 (nativeObj);
  129. return retVal;
  130. #else
  131. return -1;
  132. #endif
  133. }
  134. //
  135. // C++: void cv::ml::RTrees::getVotes(Mat samples, Mat& results, int flags)
  136. //
  137. //javadoc: RTrees::getVotes(samples, results, flags)
  138. public void getVotes (Mat samples, Mat results, int flags)
  139. {
  140. ThrowIfDisposed ();
  141. if (samples != null)
  142. samples.ThrowIfDisposed ();
  143. if (results != null)
  144. results.ThrowIfDisposed ();
  145. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  146. ml_RTrees_getVotes_10 (nativeObj, samples.nativeObj, results.nativeObj, flags);
  147. return;
  148. #else
  149. return;
  150. #endif
  151. }
  152. //
  153. // C++: void cv::ml::RTrees::setActiveVarCount(int val)
  154. //
  155. //javadoc: RTrees::setActiveVarCount(val)
  156. public void setActiveVarCount (int val)
  157. {
  158. ThrowIfDisposed ();
  159. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  160. ml_RTrees_setActiveVarCount_10 (nativeObj, val);
  161. return;
  162. #else
  163. return;
  164. #endif
  165. }
  166. //
  167. // C++: void cv::ml::RTrees::setCalculateVarImportance(bool val)
  168. //
  169. //javadoc: RTrees::setCalculateVarImportance(val)
  170. public void setCalculateVarImportance (bool val)
  171. {
  172. ThrowIfDisposed ();
  173. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  174. ml_RTrees_setCalculateVarImportance_10 (nativeObj, val);
  175. return;
  176. #else
  177. return;
  178. #endif
  179. }
  180. //
  181. // C++: void cv::ml::RTrees::setTermCriteria(TermCriteria val)
  182. //
  183. //javadoc: RTrees::setTermCriteria(val)
  184. public void setTermCriteria (TermCriteria val)
  185. {
  186. ThrowIfDisposed ();
  187. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  188. ml_RTrees_setTermCriteria_10 (nativeObj, val.type, val.maxCount, val.epsilon);
  189. return;
  190. #else
  191. return;
  192. #endif
  193. }
  194. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  195. const string LIBNAME = "__Internal";
  196. #else
  197. const string LIBNAME = "opencvforunity";
  198. #endif
  199. // C++: Mat cv::ml::RTrees::getVarImportance()
  200. [DllImport (LIBNAME)]
  201. private static extern IntPtr ml_RTrees_getVarImportance_10 (IntPtr nativeObj);
  202. // C++: static Ptr_RTrees cv::ml::RTrees::create()
  203. [DllImport (LIBNAME)]
  204. private static extern IntPtr ml_RTrees_create_10 ();
  205. // C++: static Ptr_RTrees cv::ml::RTrees::load(String filepath, String nodeName = String())
  206. [DllImport (LIBNAME)]
  207. private static extern IntPtr ml_RTrees_load_10 (string filepath, string nodeName);
  208. [DllImport (LIBNAME)]
  209. private static extern IntPtr ml_RTrees_load_11 (string filepath);
  210. // C++: TermCriteria cv::ml::RTrees::getTermCriteria()
  211. [DllImport (LIBNAME)]
  212. private static extern void ml_RTrees_getTermCriteria_10 (IntPtr nativeObj, double[] retVal);
  213. // C++: bool cv::ml::RTrees::getCalculateVarImportance()
  214. [DllImport (LIBNAME)]
  215. private static extern bool ml_RTrees_getCalculateVarImportance_10 (IntPtr nativeObj);
  216. // C++: int cv::ml::RTrees::getActiveVarCount()
  217. [DllImport (LIBNAME)]
  218. private static extern int ml_RTrees_getActiveVarCount_10 (IntPtr nativeObj);
  219. // C++: void cv::ml::RTrees::getVotes(Mat samples, Mat& results, int flags)
  220. [DllImport (LIBNAME)]
  221. private static extern void ml_RTrees_getVotes_10 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr results_nativeObj, int flags);
  222. // C++: void cv::ml::RTrees::setActiveVarCount(int val)
  223. [DllImport (LIBNAME)]
  224. private static extern void ml_RTrees_setActiveVarCount_10 (IntPtr nativeObj, int val);
  225. // C++: void cv::ml::RTrees::setCalculateVarImportance(bool val)
  226. [DllImport (LIBNAME)]
  227. private static extern void ml_RTrees_setCalculateVarImportance_10 (IntPtr nativeObj, bool val);
  228. // C++: void cv::ml::RTrees::setTermCriteria(TermCriteria val)
  229. [DllImport (LIBNAME)]
  230. private static extern void ml_RTrees_setTermCriteria_10 (IntPtr nativeObj, int val_type, int val_maxCount, double val_epsilon);
  231. // native support for java finalize()
  232. [DllImport (LIBNAME)]
  233. private static extern void ml_RTrees_delete (IntPtr nativeObj);
  234. }
  235. }