EM.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  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 EM
  10. //javadoc: EM
  11. public class EM : 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_EM_delete (nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal EM (IntPtr addr)
  32. : base (addr)
  33. {
  34. }
  35. // internal usage only
  36. public static new EM __fromPtr__ (IntPtr addr)
  37. {
  38. return new EM (addr);
  39. }
  40. // C++: enum Types
  41. public const int COV_MAT_SPHERICAL = 0;
  42. public const int COV_MAT_DIAGONAL = 1;
  43. public const int COV_MAT_GENERIC = 2;
  44. public const int COV_MAT_DEFAULT = COV_MAT_DIAGONAL;
  45. // C++: enum <unnamed>
  46. public const int DEFAULT_NCLUSTERS = 5;
  47. public const int DEFAULT_MAX_ITERS = 100;
  48. public const int START_E_STEP = 1;
  49. public const int START_M_STEP = 2;
  50. public const int START_AUTO_STEP = 0;
  51. //
  52. // C++: Mat cv::ml::EM::getMeans()
  53. //
  54. //javadoc: EM::getMeans()
  55. public Mat getMeans ()
  56. {
  57. ThrowIfDisposed ();
  58. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  59. Mat retVal = new Mat (ml_EM_getMeans_10 (nativeObj));
  60. return retVal;
  61. #else
  62. return null;
  63. #endif
  64. }
  65. //
  66. // C++: Mat cv::ml::EM::getWeights()
  67. //
  68. //javadoc: EM::getWeights()
  69. public Mat getWeights ()
  70. {
  71. ThrowIfDisposed ();
  72. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  73. Mat retVal = new Mat (ml_EM_getWeights_10 (nativeObj));
  74. return retVal;
  75. #else
  76. return null;
  77. #endif
  78. }
  79. //
  80. // C++: static Ptr_EM cv::ml::EM::create()
  81. //
  82. //javadoc: EM::create()
  83. public static EM create ()
  84. {
  85. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  86. EM retVal = EM.__fromPtr__ (ml_EM_create_10 ());
  87. return retVal;
  88. #else
  89. return null;
  90. #endif
  91. }
  92. //
  93. // C++: static Ptr_EM cv::ml::EM::load(String filepath, String nodeName = String())
  94. //
  95. //javadoc: EM::load(filepath, nodeName)
  96. public static EM load (string filepath, string nodeName)
  97. {
  98. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  99. EM retVal = EM.__fromPtr__ (ml_EM_load_10 (filepath, nodeName));
  100. return retVal;
  101. #else
  102. return null;
  103. #endif
  104. }
  105. //javadoc: EM::load(filepath)
  106. public static EM load (string filepath)
  107. {
  108. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  109. EM retVal = EM.__fromPtr__ (ml_EM_load_11 (filepath));
  110. return retVal;
  111. #else
  112. return null;
  113. #endif
  114. }
  115. //
  116. // C++: TermCriteria cv::ml::EM::getTermCriteria()
  117. //
  118. //javadoc: EM::getTermCriteria()
  119. public TermCriteria getTermCriteria ()
  120. {
  121. ThrowIfDisposed ();
  122. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  123. double[] tmpArray = new double[3];
  124. ml_EM_getTermCriteria_10 (nativeObj, tmpArray);
  125. TermCriteria retVal = new TermCriteria (tmpArray);
  126. return retVal;
  127. #else
  128. return null;
  129. #endif
  130. }
  131. //
  132. // C++: Vec2d cv::ml::EM::predict2(Mat sample, Mat& probs)
  133. //
  134. //javadoc: EM::predict2(sample, probs)
  135. public double[] predict2 (Mat sample, Mat probs)
  136. {
  137. ThrowIfDisposed ();
  138. if (sample != null)
  139. sample.ThrowIfDisposed ();
  140. if (probs != null)
  141. probs.ThrowIfDisposed ();
  142. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  143. double[] retVal = new double[2];
  144. ml_EM_predict2_10 (nativeObj, sample.nativeObj, probs.nativeObj, retVal);
  145. return retVal;
  146. #else
  147. return null;
  148. #endif
  149. }
  150. //
  151. // C++: bool cv::ml::EM::trainE(Mat samples, Mat means0, Mat covs0 = Mat(), Mat weights0 = Mat(), Mat& logLikelihoods = Mat(), Mat& labels = Mat(), Mat& probs = Mat())
  152. //
  153. //javadoc: EM::trainE(samples, means0, covs0, weights0, logLikelihoods, labels, probs)
  154. public bool trainE (Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels, Mat probs)
  155. {
  156. ThrowIfDisposed ();
  157. if (samples != null)
  158. samples.ThrowIfDisposed ();
  159. if (means0 != null)
  160. means0.ThrowIfDisposed ();
  161. if (covs0 != null)
  162. covs0.ThrowIfDisposed ();
  163. if (weights0 != null)
  164. weights0.ThrowIfDisposed ();
  165. if (logLikelihoods != null)
  166. logLikelihoods.ThrowIfDisposed ();
  167. if (labels != null)
  168. labels.ThrowIfDisposed ();
  169. if (probs != null)
  170. probs.ThrowIfDisposed ();
  171. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  172. bool retVal = ml_EM_trainE_10 (nativeObj, samples.nativeObj, means0.nativeObj, covs0.nativeObj, weights0.nativeObj, logLikelihoods.nativeObj, labels.nativeObj, probs.nativeObj);
  173. return retVal;
  174. #else
  175. return false;
  176. #endif
  177. }
  178. //javadoc: EM::trainE(samples, means0, covs0, weights0, logLikelihoods, labels)
  179. public bool trainE (Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods, Mat labels)
  180. {
  181. ThrowIfDisposed ();
  182. if (samples != null)
  183. samples.ThrowIfDisposed ();
  184. if (means0 != null)
  185. means0.ThrowIfDisposed ();
  186. if (covs0 != null)
  187. covs0.ThrowIfDisposed ();
  188. if (weights0 != null)
  189. weights0.ThrowIfDisposed ();
  190. if (logLikelihoods != null)
  191. logLikelihoods.ThrowIfDisposed ();
  192. if (labels != null)
  193. labels.ThrowIfDisposed ();
  194. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  195. bool retVal = ml_EM_trainE_11 (nativeObj, samples.nativeObj, means0.nativeObj, covs0.nativeObj, weights0.nativeObj, logLikelihoods.nativeObj, labels.nativeObj);
  196. return retVal;
  197. #else
  198. return false;
  199. #endif
  200. }
  201. //javadoc: EM::trainE(samples, means0, covs0, weights0, logLikelihoods)
  202. public bool trainE (Mat samples, Mat means0, Mat covs0, Mat weights0, Mat logLikelihoods)
  203. {
  204. ThrowIfDisposed ();
  205. if (samples != null)
  206. samples.ThrowIfDisposed ();
  207. if (means0 != null)
  208. means0.ThrowIfDisposed ();
  209. if (covs0 != null)
  210. covs0.ThrowIfDisposed ();
  211. if (weights0 != null)
  212. weights0.ThrowIfDisposed ();
  213. if (logLikelihoods != null)
  214. logLikelihoods.ThrowIfDisposed ();
  215. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  216. bool retVal = ml_EM_trainE_12 (nativeObj, samples.nativeObj, means0.nativeObj, covs0.nativeObj, weights0.nativeObj, logLikelihoods.nativeObj);
  217. return retVal;
  218. #else
  219. return false;
  220. #endif
  221. }
  222. //javadoc: EM::trainE(samples, means0, covs0, weights0)
  223. public bool trainE (Mat samples, Mat means0, Mat covs0, Mat weights0)
  224. {
  225. ThrowIfDisposed ();
  226. if (samples != null)
  227. samples.ThrowIfDisposed ();
  228. if (means0 != null)
  229. means0.ThrowIfDisposed ();
  230. if (covs0 != null)
  231. covs0.ThrowIfDisposed ();
  232. if (weights0 != null)
  233. weights0.ThrowIfDisposed ();
  234. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  235. bool retVal = ml_EM_trainE_13 (nativeObj, samples.nativeObj, means0.nativeObj, covs0.nativeObj, weights0.nativeObj);
  236. return retVal;
  237. #else
  238. return false;
  239. #endif
  240. }
  241. //javadoc: EM::trainE(samples, means0, covs0)
  242. public bool trainE (Mat samples, Mat means0, Mat covs0)
  243. {
  244. ThrowIfDisposed ();
  245. if (samples != null)
  246. samples.ThrowIfDisposed ();
  247. if (means0 != null)
  248. means0.ThrowIfDisposed ();
  249. if (covs0 != null)
  250. covs0.ThrowIfDisposed ();
  251. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  252. bool retVal = ml_EM_trainE_14 (nativeObj, samples.nativeObj, means0.nativeObj, covs0.nativeObj);
  253. return retVal;
  254. #else
  255. return false;
  256. #endif
  257. }
  258. //javadoc: EM::trainE(samples, means0)
  259. public bool trainE (Mat samples, Mat means0)
  260. {
  261. ThrowIfDisposed ();
  262. if (samples != null)
  263. samples.ThrowIfDisposed ();
  264. if (means0 != null)
  265. means0.ThrowIfDisposed ();
  266. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  267. bool retVal = ml_EM_trainE_15 (nativeObj, samples.nativeObj, means0.nativeObj);
  268. return retVal;
  269. #else
  270. return false;
  271. #endif
  272. }
  273. //
  274. // C++: bool cv::ml::EM::trainEM(Mat samples, Mat& logLikelihoods = Mat(), Mat& labels = Mat(), Mat& probs = Mat())
  275. //
  276. //javadoc: EM::trainEM(samples, logLikelihoods, labels, probs)
  277. public bool trainEM (Mat samples, Mat logLikelihoods, Mat labels, Mat probs)
  278. {
  279. ThrowIfDisposed ();
  280. if (samples != null)
  281. samples.ThrowIfDisposed ();
  282. if (logLikelihoods != null)
  283. logLikelihoods.ThrowIfDisposed ();
  284. if (labels != null)
  285. labels.ThrowIfDisposed ();
  286. if (probs != null)
  287. probs.ThrowIfDisposed ();
  288. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  289. bool retVal = ml_EM_trainEM_10 (nativeObj, samples.nativeObj, logLikelihoods.nativeObj, labels.nativeObj, probs.nativeObj);
  290. return retVal;
  291. #else
  292. return false;
  293. #endif
  294. }
  295. //javadoc: EM::trainEM(samples, logLikelihoods, labels)
  296. public bool trainEM (Mat samples, Mat logLikelihoods, Mat labels)
  297. {
  298. ThrowIfDisposed ();
  299. if (samples != null)
  300. samples.ThrowIfDisposed ();
  301. if (logLikelihoods != null)
  302. logLikelihoods.ThrowIfDisposed ();
  303. if (labels != null)
  304. labels.ThrowIfDisposed ();
  305. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  306. bool retVal = ml_EM_trainEM_11 (nativeObj, samples.nativeObj, logLikelihoods.nativeObj, labels.nativeObj);
  307. return retVal;
  308. #else
  309. return false;
  310. #endif
  311. }
  312. //javadoc: EM::trainEM(samples, logLikelihoods)
  313. public bool trainEM (Mat samples, Mat logLikelihoods)
  314. {
  315. ThrowIfDisposed ();
  316. if (samples != null)
  317. samples.ThrowIfDisposed ();
  318. if (logLikelihoods != null)
  319. logLikelihoods.ThrowIfDisposed ();
  320. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  321. bool retVal = ml_EM_trainEM_12 (nativeObj, samples.nativeObj, logLikelihoods.nativeObj);
  322. return retVal;
  323. #else
  324. return false;
  325. #endif
  326. }
  327. //javadoc: EM::trainEM(samples)
  328. public bool trainEM (Mat samples)
  329. {
  330. ThrowIfDisposed ();
  331. if (samples != null)
  332. samples.ThrowIfDisposed ();
  333. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  334. bool retVal = ml_EM_trainEM_13 (nativeObj, samples.nativeObj);
  335. return retVal;
  336. #else
  337. return false;
  338. #endif
  339. }
  340. //
  341. // C++: bool cv::ml::EM::trainM(Mat samples, Mat probs0, Mat& logLikelihoods = Mat(), Mat& labels = Mat(), Mat& probs = Mat())
  342. //
  343. //javadoc: EM::trainM(samples, probs0, logLikelihoods, labels, probs)
  344. public bool trainM (Mat samples, Mat probs0, Mat logLikelihoods, Mat labels, Mat probs)
  345. {
  346. ThrowIfDisposed ();
  347. if (samples != null)
  348. samples.ThrowIfDisposed ();
  349. if (probs0 != null)
  350. probs0.ThrowIfDisposed ();
  351. if (logLikelihoods != null)
  352. logLikelihoods.ThrowIfDisposed ();
  353. if (labels != null)
  354. labels.ThrowIfDisposed ();
  355. if (probs != null)
  356. probs.ThrowIfDisposed ();
  357. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  358. bool retVal = ml_EM_trainM_10 (nativeObj, samples.nativeObj, probs0.nativeObj, logLikelihoods.nativeObj, labels.nativeObj, probs.nativeObj);
  359. return retVal;
  360. #else
  361. return false;
  362. #endif
  363. }
  364. //javadoc: EM::trainM(samples, probs0, logLikelihoods, labels)
  365. public bool trainM (Mat samples, Mat probs0, Mat logLikelihoods, Mat labels)
  366. {
  367. ThrowIfDisposed ();
  368. if (samples != null)
  369. samples.ThrowIfDisposed ();
  370. if (probs0 != null)
  371. probs0.ThrowIfDisposed ();
  372. if (logLikelihoods != null)
  373. logLikelihoods.ThrowIfDisposed ();
  374. if (labels != null)
  375. labels.ThrowIfDisposed ();
  376. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  377. bool retVal = ml_EM_trainM_11 (nativeObj, samples.nativeObj, probs0.nativeObj, logLikelihoods.nativeObj, labels.nativeObj);
  378. return retVal;
  379. #else
  380. return false;
  381. #endif
  382. }
  383. //javadoc: EM::trainM(samples, probs0, logLikelihoods)
  384. public bool trainM (Mat samples, Mat probs0, Mat logLikelihoods)
  385. {
  386. ThrowIfDisposed ();
  387. if (samples != null)
  388. samples.ThrowIfDisposed ();
  389. if (probs0 != null)
  390. probs0.ThrowIfDisposed ();
  391. if (logLikelihoods != null)
  392. logLikelihoods.ThrowIfDisposed ();
  393. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  394. bool retVal = ml_EM_trainM_12 (nativeObj, samples.nativeObj, probs0.nativeObj, logLikelihoods.nativeObj);
  395. return retVal;
  396. #else
  397. return false;
  398. #endif
  399. }
  400. //javadoc: EM::trainM(samples, probs0)
  401. public bool trainM (Mat samples, Mat probs0)
  402. {
  403. ThrowIfDisposed ();
  404. if (samples != null)
  405. samples.ThrowIfDisposed ();
  406. if (probs0 != null)
  407. probs0.ThrowIfDisposed ();
  408. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  409. bool retVal = ml_EM_trainM_13 (nativeObj, samples.nativeObj, probs0.nativeObj);
  410. return retVal;
  411. #else
  412. return false;
  413. #endif
  414. }
  415. //
  416. // C++: float cv::ml::EM::predict(Mat samples, Mat& results = Mat(), int flags = 0)
  417. //
  418. //javadoc: EM::predict(samples, results, flags)
  419. public override float predict (Mat samples, Mat results, int flags)
  420. {
  421. ThrowIfDisposed ();
  422. if (samples != null)
  423. samples.ThrowIfDisposed ();
  424. if (results != null)
  425. results.ThrowIfDisposed ();
  426. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  427. float retVal = ml_EM_predict_10 (nativeObj, samples.nativeObj, results.nativeObj, flags);
  428. return retVal;
  429. #else
  430. return -1;
  431. #endif
  432. }
  433. //javadoc: EM::predict(samples, results)
  434. public override float predict (Mat samples, Mat results)
  435. {
  436. ThrowIfDisposed ();
  437. if (samples != null)
  438. samples.ThrowIfDisposed ();
  439. if (results != null)
  440. results.ThrowIfDisposed ();
  441. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  442. float retVal = ml_EM_predict_11 (nativeObj, samples.nativeObj, results.nativeObj);
  443. return retVal;
  444. #else
  445. return -1;
  446. #endif
  447. }
  448. //javadoc: EM::predict(samples)
  449. public override float predict (Mat samples)
  450. {
  451. ThrowIfDisposed ();
  452. if (samples != null)
  453. samples.ThrowIfDisposed ();
  454. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  455. float retVal = ml_EM_predict_12 (nativeObj, samples.nativeObj);
  456. return retVal;
  457. #else
  458. return -1;
  459. #endif
  460. }
  461. //
  462. // C++: int cv::ml::EM::getClustersNumber()
  463. //
  464. //javadoc: EM::getClustersNumber()
  465. public int getClustersNumber ()
  466. {
  467. ThrowIfDisposed ();
  468. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  469. int retVal = ml_EM_getClustersNumber_10 (nativeObj);
  470. return retVal;
  471. #else
  472. return -1;
  473. #endif
  474. }
  475. //
  476. // C++: int cv::ml::EM::getCovarianceMatrixType()
  477. //
  478. //javadoc: EM::getCovarianceMatrixType()
  479. public int getCovarianceMatrixType ()
  480. {
  481. ThrowIfDisposed ();
  482. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  483. int retVal = ml_EM_getCovarianceMatrixType_10 (nativeObj);
  484. return retVal;
  485. #else
  486. return -1;
  487. #endif
  488. }
  489. //
  490. // C++: void cv::ml::EM::getCovs(vector_Mat& covs)
  491. //
  492. //javadoc: EM::getCovs(covs)
  493. public void getCovs (List<Mat> covs)
  494. {
  495. ThrowIfDisposed ();
  496. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  497. Mat covs_mat = new Mat ();
  498. ml_EM_getCovs_10 (nativeObj, covs_mat.nativeObj);
  499. Converters.Mat_to_vector_Mat (covs_mat, covs);
  500. covs_mat.release ();
  501. return;
  502. #else
  503. return;
  504. #endif
  505. }
  506. //
  507. // C++: void cv::ml::EM::setClustersNumber(int val)
  508. //
  509. //javadoc: EM::setClustersNumber(val)
  510. public void setClustersNumber (int val)
  511. {
  512. ThrowIfDisposed ();
  513. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  514. ml_EM_setClustersNumber_10 (nativeObj, val);
  515. return;
  516. #else
  517. return;
  518. #endif
  519. }
  520. //
  521. // C++: void cv::ml::EM::setCovarianceMatrixType(int val)
  522. //
  523. //javadoc: EM::setCovarianceMatrixType(val)
  524. public void setCovarianceMatrixType (int val)
  525. {
  526. ThrowIfDisposed ();
  527. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  528. ml_EM_setCovarianceMatrixType_10 (nativeObj, val);
  529. return;
  530. #else
  531. return;
  532. #endif
  533. }
  534. //
  535. // C++: void cv::ml::EM::setTermCriteria(TermCriteria val)
  536. //
  537. //javadoc: EM::setTermCriteria(val)
  538. public void setTermCriteria (TermCriteria val)
  539. {
  540. ThrowIfDisposed ();
  541. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  542. ml_EM_setTermCriteria_10 (nativeObj, val.type, val.maxCount, val.epsilon);
  543. return;
  544. #else
  545. return;
  546. #endif
  547. }
  548. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  549. const string LIBNAME = "__Internal";
  550. #else
  551. const string LIBNAME = "opencvforunity";
  552. #endif
  553. // C++: Mat cv::ml::EM::getMeans()
  554. [DllImport (LIBNAME)]
  555. private static extern IntPtr ml_EM_getMeans_10 (IntPtr nativeObj);
  556. // C++: Mat cv::ml::EM::getWeights()
  557. [DllImport (LIBNAME)]
  558. private static extern IntPtr ml_EM_getWeights_10 (IntPtr nativeObj);
  559. // C++: static Ptr_EM cv::ml::EM::create()
  560. [DllImport (LIBNAME)]
  561. private static extern IntPtr ml_EM_create_10 ();
  562. // C++: static Ptr_EM cv::ml::EM::load(String filepath, String nodeName = String())
  563. [DllImport (LIBNAME)]
  564. private static extern IntPtr ml_EM_load_10 (string filepath, string nodeName);
  565. [DllImport (LIBNAME)]
  566. private static extern IntPtr ml_EM_load_11 (string filepath);
  567. // C++: TermCriteria cv::ml::EM::getTermCriteria()
  568. [DllImport (LIBNAME)]
  569. private static extern void ml_EM_getTermCriteria_10 (IntPtr nativeObj, double[] retVal);
  570. // C++: Vec2d cv::ml::EM::predict2(Mat sample, Mat& probs)
  571. [DllImport (LIBNAME)]
  572. private static extern void ml_EM_predict2_10 (IntPtr nativeObj, IntPtr sample_nativeObj, IntPtr probs_nativeObj, double[] retVal);
  573. // C++: bool cv::ml::EM::trainE(Mat samples, Mat means0, Mat covs0 = Mat(), Mat weights0 = Mat(), Mat& logLikelihoods = Mat(), Mat& labels = Mat(), Mat& probs = Mat())
  574. [DllImport (LIBNAME)]
  575. private static extern bool ml_EM_trainE_10 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr means0_nativeObj, IntPtr covs0_nativeObj, IntPtr weights0_nativeObj, IntPtr logLikelihoods_nativeObj, IntPtr labels_nativeObj, IntPtr probs_nativeObj);
  576. [DllImport (LIBNAME)]
  577. private static extern bool ml_EM_trainE_11 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr means0_nativeObj, IntPtr covs0_nativeObj, IntPtr weights0_nativeObj, IntPtr logLikelihoods_nativeObj, IntPtr labels_nativeObj);
  578. [DllImport (LIBNAME)]
  579. private static extern bool ml_EM_trainE_12 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr means0_nativeObj, IntPtr covs0_nativeObj, IntPtr weights0_nativeObj, IntPtr logLikelihoods_nativeObj);
  580. [DllImport (LIBNAME)]
  581. private static extern bool ml_EM_trainE_13 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr means0_nativeObj, IntPtr covs0_nativeObj, IntPtr weights0_nativeObj);
  582. [DllImport (LIBNAME)]
  583. private static extern bool ml_EM_trainE_14 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr means0_nativeObj, IntPtr covs0_nativeObj);
  584. [DllImport (LIBNAME)]
  585. private static extern bool ml_EM_trainE_15 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr means0_nativeObj);
  586. // C++: bool cv::ml::EM::trainEM(Mat samples, Mat& logLikelihoods = Mat(), Mat& labels = Mat(), Mat& probs = Mat())
  587. [DllImport (LIBNAME)]
  588. private static extern bool ml_EM_trainEM_10 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr logLikelihoods_nativeObj, IntPtr labels_nativeObj, IntPtr probs_nativeObj);
  589. [DllImport (LIBNAME)]
  590. private static extern bool ml_EM_trainEM_11 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr logLikelihoods_nativeObj, IntPtr labels_nativeObj);
  591. [DllImport (LIBNAME)]
  592. private static extern bool ml_EM_trainEM_12 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr logLikelihoods_nativeObj);
  593. [DllImport (LIBNAME)]
  594. private static extern bool ml_EM_trainEM_13 (IntPtr nativeObj, IntPtr samples_nativeObj);
  595. // C++: bool cv::ml::EM::trainM(Mat samples, Mat probs0, Mat& logLikelihoods = Mat(), Mat& labels = Mat(), Mat& probs = Mat())
  596. [DllImport (LIBNAME)]
  597. private static extern bool ml_EM_trainM_10 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr probs0_nativeObj, IntPtr logLikelihoods_nativeObj, IntPtr labels_nativeObj, IntPtr probs_nativeObj);
  598. [DllImport (LIBNAME)]
  599. private static extern bool ml_EM_trainM_11 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr probs0_nativeObj, IntPtr logLikelihoods_nativeObj, IntPtr labels_nativeObj);
  600. [DllImport (LIBNAME)]
  601. private static extern bool ml_EM_trainM_12 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr probs0_nativeObj, IntPtr logLikelihoods_nativeObj);
  602. [DllImport (LIBNAME)]
  603. private static extern bool ml_EM_trainM_13 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr probs0_nativeObj);
  604. // C++: float cv::ml::EM::predict(Mat samples, Mat& results = Mat(), int flags = 0)
  605. [DllImport (LIBNAME)]
  606. private static extern float ml_EM_predict_10 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr results_nativeObj, int flags);
  607. [DllImport (LIBNAME)]
  608. private static extern float ml_EM_predict_11 (IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr results_nativeObj);
  609. [DllImport (LIBNAME)]
  610. private static extern float ml_EM_predict_12 (IntPtr nativeObj, IntPtr samples_nativeObj);
  611. // C++: int cv::ml::EM::getClustersNumber()
  612. [DllImport (LIBNAME)]
  613. private static extern int ml_EM_getClustersNumber_10 (IntPtr nativeObj);
  614. // C++: int cv::ml::EM::getCovarianceMatrixType()
  615. [DllImport (LIBNAME)]
  616. private static extern int ml_EM_getCovarianceMatrixType_10 (IntPtr nativeObj);
  617. // C++: void cv::ml::EM::getCovs(vector_Mat& covs)
  618. [DllImport (LIBNAME)]
  619. private static extern void ml_EM_getCovs_10 (IntPtr nativeObj, IntPtr covs_mat_nativeObj);
  620. // C++: void cv::ml::EM::setClustersNumber(int val)
  621. [DllImport (LIBNAME)]
  622. private static extern void ml_EM_setClustersNumber_10 (IntPtr nativeObj, int val);
  623. // C++: void cv::ml::EM::setCovarianceMatrixType(int val)
  624. [DllImport (LIBNAME)]
  625. private static extern void ml_EM_setCovarianceMatrixType_10 (IntPtr nativeObj, int val);
  626. // C++: void cv::ml::EM::setTermCriteria(TermCriteria val)
  627. [DllImport (LIBNAME)]
  628. private static extern void ml_EM_setTermCriteria_10 (IntPtr nativeObj, int val_type, int val_maxCount, double val_epsilon);
  629. // native support for java finalize()
  630. [DllImport (LIBNAME)]
  631. private static extern void ml_EM_delete (IntPtr nativeObj);
  632. }
  633. }