DTrees.cs 13 KB

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