RTrees.cs 7.8 KB

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