DTrees.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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 DTrees
  10. //javadoc: DTrees
  11. public class DTrees : StatModel
  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_DTrees_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal DTrees (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new DTrees __fromPtr__ (IntPtr addr) { return new DTrees (addr); }
  34. // C++: enum Flags
  35. public const int PREDICT_AUTO = 0;
  36. public const int PREDICT_SUM = (1 << 8);
  37. public const int PREDICT_MAX_VOTE = (2 << 8);
  38. public const int PREDICT_MASK = (3 << 8);
  39. //
  40. // C++: Mat cv::ml::DTrees::getPriors()
  41. //
  42. //javadoc: DTrees::getPriors()
  43. public Mat getPriors ()
  44. {
  45. ThrowIfDisposed ();
  46. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  47. Mat retVal = new Mat(ml_DTrees_getPriors_10(nativeObj));
  48. return retVal;
  49. #else
  50. return null;
  51. #endif
  52. }
  53. //
  54. // C++: static Ptr_DTrees cv::ml::DTrees::create()
  55. //
  56. //javadoc: DTrees::create()
  57. public static DTrees create ()
  58. {
  59. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  60. DTrees retVal = DTrees.__fromPtr__(ml_DTrees_create_10());
  61. return retVal;
  62. #else
  63. return null;
  64. #endif
  65. }
  66. //
  67. // C++: static Ptr_DTrees cv::ml::DTrees::load(String filepath, String nodeName = String())
  68. //
  69. //javadoc: DTrees::load(filepath, nodeName)
  70. public static DTrees load (string filepath, string nodeName)
  71. {
  72. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  73. DTrees retVal = DTrees.__fromPtr__(ml_DTrees_load_10(filepath, nodeName));
  74. return retVal;
  75. #else
  76. return null;
  77. #endif
  78. }
  79. //javadoc: DTrees::load(filepath)
  80. public static DTrees load (string filepath)
  81. {
  82. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  83. DTrees retVal = DTrees.__fromPtr__(ml_DTrees_load_11(filepath));
  84. return retVal;
  85. #else
  86. return null;
  87. #endif
  88. }
  89. //
  90. // C++: bool cv::ml::DTrees::getTruncatePrunedTree()
  91. //
  92. //javadoc: DTrees::getTruncatePrunedTree()
  93. public bool getTruncatePrunedTree ()
  94. {
  95. ThrowIfDisposed ();
  96. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  97. bool retVal = ml_DTrees_getTruncatePrunedTree_10(nativeObj);
  98. return retVal;
  99. #else
  100. return false;
  101. #endif
  102. }
  103. //
  104. // C++: bool cv::ml::DTrees::getUse1SERule()
  105. //
  106. //javadoc: DTrees::getUse1SERule()
  107. public bool getUse1SERule ()
  108. {
  109. ThrowIfDisposed ();
  110. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  111. bool retVal = ml_DTrees_getUse1SERule_10(nativeObj);
  112. return retVal;
  113. #else
  114. return false;
  115. #endif
  116. }
  117. //
  118. // C++: bool cv::ml::DTrees::getUseSurrogates()
  119. //
  120. //javadoc: DTrees::getUseSurrogates()
  121. public bool getUseSurrogates ()
  122. {
  123. ThrowIfDisposed ();
  124. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  125. bool retVal = ml_DTrees_getUseSurrogates_10(nativeObj);
  126. return retVal;
  127. #else
  128. return false;
  129. #endif
  130. }
  131. //
  132. // C++: float cv::ml::DTrees::getRegressionAccuracy()
  133. //
  134. //javadoc: DTrees::getRegressionAccuracy()
  135. public float getRegressionAccuracy ()
  136. {
  137. ThrowIfDisposed ();
  138. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  139. float retVal = ml_DTrees_getRegressionAccuracy_10(nativeObj);
  140. return retVal;
  141. #else
  142. return -1;
  143. #endif
  144. }
  145. //
  146. // C++: int cv::ml::DTrees::getCVFolds()
  147. //
  148. //javadoc: DTrees::getCVFolds()
  149. public int getCVFolds ()
  150. {
  151. ThrowIfDisposed ();
  152. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  153. int retVal = ml_DTrees_getCVFolds_10(nativeObj);
  154. return retVal;
  155. #else
  156. return -1;
  157. #endif
  158. }
  159. //
  160. // C++: int cv::ml::DTrees::getMaxCategories()
  161. //
  162. //javadoc: DTrees::getMaxCategories()
  163. public int getMaxCategories ()
  164. {
  165. ThrowIfDisposed ();
  166. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  167. int retVal = ml_DTrees_getMaxCategories_10(nativeObj);
  168. return retVal;
  169. #else
  170. return -1;
  171. #endif
  172. }
  173. //
  174. // C++: int cv::ml::DTrees::getMaxDepth()
  175. //
  176. //javadoc: DTrees::getMaxDepth()
  177. public int getMaxDepth ()
  178. {
  179. ThrowIfDisposed ();
  180. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  181. int retVal = ml_DTrees_getMaxDepth_10(nativeObj);
  182. return retVal;
  183. #else
  184. return -1;
  185. #endif
  186. }
  187. //
  188. // C++: int cv::ml::DTrees::getMinSampleCount()
  189. //
  190. //javadoc: DTrees::getMinSampleCount()
  191. public int getMinSampleCount ()
  192. {
  193. ThrowIfDisposed ();
  194. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  195. int retVal = ml_DTrees_getMinSampleCount_10(nativeObj);
  196. return retVal;
  197. #else
  198. return -1;
  199. #endif
  200. }
  201. //
  202. // C++: void cv::ml::DTrees::setCVFolds(int val)
  203. //
  204. //javadoc: DTrees::setCVFolds(val)
  205. public void setCVFolds (int val)
  206. {
  207. ThrowIfDisposed ();
  208. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  209. ml_DTrees_setCVFolds_10(nativeObj, val);
  210. return;
  211. #else
  212. return;
  213. #endif
  214. }
  215. //
  216. // C++: void cv::ml::DTrees::setMaxCategories(int val)
  217. //
  218. //javadoc: DTrees::setMaxCategories(val)
  219. public void setMaxCategories (int val)
  220. {
  221. ThrowIfDisposed ();
  222. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  223. ml_DTrees_setMaxCategories_10(nativeObj, val);
  224. return;
  225. #else
  226. return;
  227. #endif
  228. }
  229. //
  230. // C++: void cv::ml::DTrees::setMaxDepth(int val)
  231. //
  232. //javadoc: DTrees::setMaxDepth(val)
  233. public void setMaxDepth (int val)
  234. {
  235. ThrowIfDisposed ();
  236. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  237. ml_DTrees_setMaxDepth_10(nativeObj, val);
  238. return;
  239. #else
  240. return;
  241. #endif
  242. }
  243. //
  244. // C++: void cv::ml::DTrees::setMinSampleCount(int val)
  245. //
  246. //javadoc: DTrees::setMinSampleCount(val)
  247. public void setMinSampleCount (int val)
  248. {
  249. ThrowIfDisposed ();
  250. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  251. ml_DTrees_setMinSampleCount_10(nativeObj, val);
  252. return;
  253. #else
  254. return;
  255. #endif
  256. }
  257. //
  258. // C++: void cv::ml::DTrees::setPriors(Mat val)
  259. //
  260. //javadoc: DTrees::setPriors(val)
  261. public void setPriors (Mat val)
  262. {
  263. ThrowIfDisposed ();
  264. if (val != null) val.ThrowIfDisposed ();
  265. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  266. ml_DTrees_setPriors_10(nativeObj, val.nativeObj);
  267. return;
  268. #else
  269. return;
  270. #endif
  271. }
  272. //
  273. // C++: void cv::ml::DTrees::setRegressionAccuracy(float val)
  274. //
  275. //javadoc: DTrees::setRegressionAccuracy(val)
  276. public void setRegressionAccuracy (float val)
  277. {
  278. ThrowIfDisposed ();
  279. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  280. ml_DTrees_setRegressionAccuracy_10(nativeObj, val);
  281. return;
  282. #else
  283. return;
  284. #endif
  285. }
  286. //
  287. // C++: void cv::ml::DTrees::setTruncatePrunedTree(bool val)
  288. //
  289. //javadoc: DTrees::setTruncatePrunedTree(val)
  290. public void setTruncatePrunedTree (bool val)
  291. {
  292. ThrowIfDisposed ();
  293. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  294. ml_DTrees_setTruncatePrunedTree_10(nativeObj, val);
  295. return;
  296. #else
  297. return;
  298. #endif
  299. }
  300. //
  301. // C++: void cv::ml::DTrees::setUse1SERule(bool val)
  302. //
  303. //javadoc: DTrees::setUse1SERule(val)
  304. public void setUse1SERule (bool val)
  305. {
  306. ThrowIfDisposed ();
  307. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  308. ml_DTrees_setUse1SERule_10(nativeObj, val);
  309. return;
  310. #else
  311. return;
  312. #endif
  313. }
  314. //
  315. // C++: void cv::ml::DTrees::setUseSurrogates(bool val)
  316. //
  317. //javadoc: DTrees::setUseSurrogates(val)
  318. public void setUseSurrogates (bool val)
  319. {
  320. ThrowIfDisposed ();
  321. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  322. ml_DTrees_setUseSurrogates_10(nativeObj, val);
  323. return;
  324. #else
  325. return;
  326. #endif
  327. }
  328. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  329. const string LIBNAME = "__Internal";
  330. #else
  331. const string LIBNAME = "opencvforunity";
  332. #endif
  333. // C++: Mat cv::ml::DTrees::getPriors()
  334. [DllImport (LIBNAME)]
  335. private static extern IntPtr ml_DTrees_getPriors_10 (IntPtr nativeObj);
  336. // C++: static Ptr_DTrees cv::ml::DTrees::create()
  337. [DllImport (LIBNAME)]
  338. private static extern IntPtr ml_DTrees_create_10 ();
  339. // C++: static Ptr_DTrees cv::ml::DTrees::load(String filepath, String nodeName = String())
  340. [DllImport (LIBNAME)]
  341. private static extern IntPtr ml_DTrees_load_10 (string filepath, string nodeName);
  342. [DllImport (LIBNAME)]
  343. private static extern IntPtr ml_DTrees_load_11 (string filepath);
  344. // C++: bool cv::ml::DTrees::getTruncatePrunedTree()
  345. [DllImport (LIBNAME)]
  346. private static extern bool ml_DTrees_getTruncatePrunedTree_10 (IntPtr nativeObj);
  347. // C++: bool cv::ml::DTrees::getUse1SERule()
  348. [DllImport (LIBNAME)]
  349. private static extern bool ml_DTrees_getUse1SERule_10 (IntPtr nativeObj);
  350. // C++: bool cv::ml::DTrees::getUseSurrogates()
  351. [DllImport (LIBNAME)]
  352. private static extern bool ml_DTrees_getUseSurrogates_10 (IntPtr nativeObj);
  353. // C++: float cv::ml::DTrees::getRegressionAccuracy()
  354. [DllImport (LIBNAME)]
  355. private static extern float ml_DTrees_getRegressionAccuracy_10 (IntPtr nativeObj);
  356. // C++: int cv::ml::DTrees::getCVFolds()
  357. [DllImport (LIBNAME)]
  358. private static extern int ml_DTrees_getCVFolds_10 (IntPtr nativeObj);
  359. // C++: int cv::ml::DTrees::getMaxCategories()
  360. [DllImport (LIBNAME)]
  361. private static extern int ml_DTrees_getMaxCategories_10 (IntPtr nativeObj);
  362. // C++: int cv::ml::DTrees::getMaxDepth()
  363. [DllImport (LIBNAME)]
  364. private static extern int ml_DTrees_getMaxDepth_10 (IntPtr nativeObj);
  365. // C++: int cv::ml::DTrees::getMinSampleCount()
  366. [DllImport (LIBNAME)]
  367. private static extern int ml_DTrees_getMinSampleCount_10 (IntPtr nativeObj);
  368. // C++: void cv::ml::DTrees::setCVFolds(int val)
  369. [DllImport (LIBNAME)]
  370. private static extern void ml_DTrees_setCVFolds_10 (IntPtr nativeObj, int val);
  371. // C++: void cv::ml::DTrees::setMaxCategories(int val)
  372. [DllImport (LIBNAME)]
  373. private static extern void ml_DTrees_setMaxCategories_10 (IntPtr nativeObj, int val);
  374. // C++: void cv::ml::DTrees::setMaxDepth(int val)
  375. [DllImport (LIBNAME)]
  376. private static extern void ml_DTrees_setMaxDepth_10 (IntPtr nativeObj, int val);
  377. // C++: void cv::ml::DTrees::setMinSampleCount(int val)
  378. [DllImport (LIBNAME)]
  379. private static extern void ml_DTrees_setMinSampleCount_10 (IntPtr nativeObj, int val);
  380. // C++: void cv::ml::DTrees::setPriors(Mat val)
  381. [DllImport (LIBNAME)]
  382. private static extern void ml_DTrees_setPriors_10 (IntPtr nativeObj, IntPtr val_nativeObj);
  383. // C++: void cv::ml::DTrees::setRegressionAccuracy(float val)
  384. [DllImport (LIBNAME)]
  385. private static extern void ml_DTrees_setRegressionAccuracy_10 (IntPtr nativeObj, float val);
  386. // C++: void cv::ml::DTrees::setTruncatePrunedTree(bool val)
  387. [DllImport (LIBNAME)]
  388. private static extern void ml_DTrees_setTruncatePrunedTree_10 (IntPtr nativeObj, bool val);
  389. // C++: void cv::ml::DTrees::setUse1SERule(bool val)
  390. [DllImport (LIBNAME)]
  391. private static extern void ml_DTrees_setUse1SERule_10 (IntPtr nativeObj, bool val);
  392. // C++: void cv::ml::DTrees::setUseSurrogates(bool val)
  393. [DllImport (LIBNAME)]
  394. private static extern void ml_DTrees_setUseSurrogates_10 (IntPtr nativeObj, bool val);
  395. // native support for java finalize()
  396. [DllImport (LIBNAME)]
  397. private static extern void ml_DTrees_delete (IntPtr nativeObj);
  398. }
  399. }