SVMSGD.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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 SVMSGD
  10. //javadoc: SVMSGD
  11. public class SVMSGD : 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_SVMSGD_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal SVMSGD (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new SVMSGD __fromPtr__ (IntPtr addr) { return new SVMSGD (addr); }
  34. // C++: enum SvmsgdType
  35. public const int SGD = 0;
  36. public const int ASGD = 1;
  37. // C++: enum MarginType
  38. public const int SOFT_MARGIN = 0;
  39. public const int HARD_MARGIN = 1;
  40. //
  41. // C++: Mat cv::ml::SVMSGD::getWeights()
  42. //
  43. //javadoc: SVMSGD::getWeights()
  44. public Mat getWeights ()
  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_SVMSGD_getWeights_10(nativeObj));
  49. return retVal;
  50. #else
  51. return null;
  52. #endif
  53. }
  54. //
  55. // C++: static Ptr_SVMSGD cv::ml::SVMSGD::create()
  56. //
  57. //javadoc: SVMSGD::create()
  58. public static SVMSGD create ()
  59. {
  60. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  61. SVMSGD retVal = SVMSGD.__fromPtr__(ml_SVMSGD_create_10());
  62. return retVal;
  63. #else
  64. return null;
  65. #endif
  66. }
  67. //
  68. // C++: static Ptr_SVMSGD cv::ml::SVMSGD::load(String filepath, String nodeName = String())
  69. //
  70. //javadoc: SVMSGD::load(filepath, nodeName)
  71. public static SVMSGD load (string filepath, string nodeName)
  72. {
  73. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  74. SVMSGD retVal = SVMSGD.__fromPtr__(ml_SVMSGD_load_10(filepath, nodeName));
  75. return retVal;
  76. #else
  77. return null;
  78. #endif
  79. }
  80. //javadoc: SVMSGD::load(filepath)
  81. public static SVMSGD load (string filepath)
  82. {
  83. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  84. SVMSGD retVal = SVMSGD.__fromPtr__(ml_SVMSGD_load_11(filepath));
  85. return retVal;
  86. #else
  87. return null;
  88. #endif
  89. }
  90. //
  91. // C++: TermCriteria cv::ml::SVMSGD::getTermCriteria()
  92. //
  93. //javadoc: SVMSGD::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_SVMSGD_getTermCriteria_10(nativeObj, tmpArray);
  100. TermCriteria retVal = new TermCriteria (tmpArray);
  101. return retVal;
  102. #else
  103. return null;
  104. #endif
  105. }
  106. //
  107. // C++: float cv::ml::SVMSGD::getInitialStepSize()
  108. //
  109. //javadoc: SVMSGD::getInitialStepSize()
  110. public float getInitialStepSize ()
  111. {
  112. ThrowIfDisposed ();
  113. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  114. float retVal = ml_SVMSGD_getInitialStepSize_10(nativeObj);
  115. return retVal;
  116. #else
  117. return -1;
  118. #endif
  119. }
  120. //
  121. // C++: float cv::ml::SVMSGD::getMarginRegularization()
  122. //
  123. //javadoc: SVMSGD::getMarginRegularization()
  124. public float getMarginRegularization ()
  125. {
  126. ThrowIfDisposed ();
  127. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  128. float retVal = ml_SVMSGD_getMarginRegularization_10(nativeObj);
  129. return retVal;
  130. #else
  131. return -1;
  132. #endif
  133. }
  134. //
  135. // C++: float cv::ml::SVMSGD::getShift()
  136. //
  137. //javadoc: SVMSGD::getShift()
  138. public float getShift ()
  139. {
  140. ThrowIfDisposed ();
  141. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  142. float retVal = ml_SVMSGD_getShift_10(nativeObj);
  143. return retVal;
  144. #else
  145. return -1;
  146. #endif
  147. }
  148. //
  149. // C++: float cv::ml::SVMSGD::getStepDecreasingPower()
  150. //
  151. //javadoc: SVMSGD::getStepDecreasingPower()
  152. public float getStepDecreasingPower ()
  153. {
  154. ThrowIfDisposed ();
  155. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  156. float retVal = ml_SVMSGD_getStepDecreasingPower_10(nativeObj);
  157. return retVal;
  158. #else
  159. return -1;
  160. #endif
  161. }
  162. //
  163. // C++: int cv::ml::SVMSGD::getMarginType()
  164. //
  165. //javadoc: SVMSGD::getMarginType()
  166. public int getMarginType ()
  167. {
  168. ThrowIfDisposed ();
  169. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  170. int retVal = ml_SVMSGD_getMarginType_10(nativeObj);
  171. return retVal;
  172. #else
  173. return -1;
  174. #endif
  175. }
  176. //
  177. // C++: int cv::ml::SVMSGD::getSvmsgdType()
  178. //
  179. //javadoc: SVMSGD::getSvmsgdType()
  180. public int getSvmsgdType ()
  181. {
  182. ThrowIfDisposed ();
  183. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  184. int retVal = ml_SVMSGD_getSvmsgdType_10(nativeObj);
  185. return retVal;
  186. #else
  187. return -1;
  188. #endif
  189. }
  190. //
  191. // C++: void cv::ml::SVMSGD::setInitialStepSize(float InitialStepSize)
  192. //
  193. //javadoc: SVMSGD::setInitialStepSize(InitialStepSize)
  194. public void setInitialStepSize (float InitialStepSize)
  195. {
  196. ThrowIfDisposed ();
  197. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  198. ml_SVMSGD_setInitialStepSize_10(nativeObj, InitialStepSize);
  199. return;
  200. #else
  201. return;
  202. #endif
  203. }
  204. //
  205. // C++: void cv::ml::SVMSGD::setMarginRegularization(float marginRegularization)
  206. //
  207. //javadoc: SVMSGD::setMarginRegularization(marginRegularization)
  208. public void setMarginRegularization (float marginRegularization)
  209. {
  210. ThrowIfDisposed ();
  211. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  212. ml_SVMSGD_setMarginRegularization_10(nativeObj, marginRegularization);
  213. return;
  214. #else
  215. return;
  216. #endif
  217. }
  218. //
  219. // C++: void cv::ml::SVMSGD::setMarginType(int marginType)
  220. //
  221. //javadoc: SVMSGD::setMarginType(marginType)
  222. public void setMarginType (int marginType)
  223. {
  224. ThrowIfDisposed ();
  225. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  226. ml_SVMSGD_setMarginType_10(nativeObj, marginType);
  227. return;
  228. #else
  229. return;
  230. #endif
  231. }
  232. //
  233. // C++: void cv::ml::SVMSGD::setOptimalParameters(int svmsgdType = SVMSGD::ASGD, int marginType = SVMSGD::SOFT_MARGIN)
  234. //
  235. //javadoc: SVMSGD::setOptimalParameters(svmsgdType, marginType)
  236. public void setOptimalParameters (int svmsgdType, int marginType)
  237. {
  238. ThrowIfDisposed ();
  239. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  240. ml_SVMSGD_setOptimalParameters_10(nativeObj, svmsgdType, marginType);
  241. return;
  242. #else
  243. return;
  244. #endif
  245. }
  246. //javadoc: SVMSGD::setOptimalParameters(svmsgdType)
  247. public void setOptimalParameters (int svmsgdType)
  248. {
  249. ThrowIfDisposed ();
  250. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  251. ml_SVMSGD_setOptimalParameters_11(nativeObj, svmsgdType);
  252. return;
  253. #else
  254. return;
  255. #endif
  256. }
  257. //javadoc: SVMSGD::setOptimalParameters()
  258. public void setOptimalParameters ()
  259. {
  260. ThrowIfDisposed ();
  261. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  262. ml_SVMSGD_setOptimalParameters_12(nativeObj);
  263. return;
  264. #else
  265. return;
  266. #endif
  267. }
  268. //
  269. // C++: void cv::ml::SVMSGD::setStepDecreasingPower(float stepDecreasingPower)
  270. //
  271. //javadoc: SVMSGD::setStepDecreasingPower(stepDecreasingPower)
  272. public void setStepDecreasingPower (float stepDecreasingPower)
  273. {
  274. ThrowIfDisposed ();
  275. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  276. ml_SVMSGD_setStepDecreasingPower_10(nativeObj, stepDecreasingPower);
  277. return;
  278. #else
  279. return;
  280. #endif
  281. }
  282. //
  283. // C++: void cv::ml::SVMSGD::setSvmsgdType(int svmsgdType)
  284. //
  285. //javadoc: SVMSGD::setSvmsgdType(svmsgdType)
  286. public void setSvmsgdType (int svmsgdType)
  287. {
  288. ThrowIfDisposed ();
  289. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  290. ml_SVMSGD_setSvmsgdType_10(nativeObj, svmsgdType);
  291. return;
  292. #else
  293. return;
  294. #endif
  295. }
  296. //
  297. // C++: void cv::ml::SVMSGD::setTermCriteria(TermCriteria val)
  298. //
  299. //javadoc: SVMSGD::setTermCriteria(val)
  300. public void setTermCriteria (TermCriteria val)
  301. {
  302. ThrowIfDisposed ();
  303. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  304. ml_SVMSGD_setTermCriteria_10(nativeObj, val.type, val.maxCount, val.epsilon);
  305. return;
  306. #else
  307. return;
  308. #endif
  309. }
  310. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  311. const string LIBNAME = "__Internal";
  312. #else
  313. const string LIBNAME = "opencvforunity";
  314. #endif
  315. // C++: Mat cv::ml::SVMSGD::getWeights()
  316. [DllImport (LIBNAME)]
  317. private static extern IntPtr ml_SVMSGD_getWeights_10 (IntPtr nativeObj);
  318. // C++: static Ptr_SVMSGD cv::ml::SVMSGD::create()
  319. [DllImport (LIBNAME)]
  320. private static extern IntPtr ml_SVMSGD_create_10 ();
  321. // C++: static Ptr_SVMSGD cv::ml::SVMSGD::load(String filepath, String nodeName = String())
  322. [DllImport (LIBNAME)]
  323. private static extern IntPtr ml_SVMSGD_load_10 (string filepath, string nodeName);
  324. [DllImport (LIBNAME)]
  325. private static extern IntPtr ml_SVMSGD_load_11 (string filepath);
  326. // C++: TermCriteria cv::ml::SVMSGD::getTermCriteria()
  327. [DllImport (LIBNAME)]
  328. private static extern void ml_SVMSGD_getTermCriteria_10 (IntPtr nativeObj, double[] retVal);
  329. // C++: float cv::ml::SVMSGD::getInitialStepSize()
  330. [DllImport (LIBNAME)]
  331. private static extern float ml_SVMSGD_getInitialStepSize_10 (IntPtr nativeObj);
  332. // C++: float cv::ml::SVMSGD::getMarginRegularization()
  333. [DllImport (LIBNAME)]
  334. private static extern float ml_SVMSGD_getMarginRegularization_10 (IntPtr nativeObj);
  335. // C++: float cv::ml::SVMSGD::getShift()
  336. [DllImport (LIBNAME)]
  337. private static extern float ml_SVMSGD_getShift_10 (IntPtr nativeObj);
  338. // C++: float cv::ml::SVMSGD::getStepDecreasingPower()
  339. [DllImport (LIBNAME)]
  340. private static extern float ml_SVMSGD_getStepDecreasingPower_10 (IntPtr nativeObj);
  341. // C++: int cv::ml::SVMSGD::getMarginType()
  342. [DllImport (LIBNAME)]
  343. private static extern int ml_SVMSGD_getMarginType_10 (IntPtr nativeObj);
  344. // C++: int cv::ml::SVMSGD::getSvmsgdType()
  345. [DllImport (LIBNAME)]
  346. private static extern int ml_SVMSGD_getSvmsgdType_10 (IntPtr nativeObj);
  347. // C++: void cv::ml::SVMSGD::setInitialStepSize(float InitialStepSize)
  348. [DllImport (LIBNAME)]
  349. private static extern void ml_SVMSGD_setInitialStepSize_10 (IntPtr nativeObj, float InitialStepSize);
  350. // C++: void cv::ml::SVMSGD::setMarginRegularization(float marginRegularization)
  351. [DllImport (LIBNAME)]
  352. private static extern void ml_SVMSGD_setMarginRegularization_10 (IntPtr nativeObj, float marginRegularization);
  353. // C++: void cv::ml::SVMSGD::setMarginType(int marginType)
  354. [DllImport (LIBNAME)]
  355. private static extern void ml_SVMSGD_setMarginType_10 (IntPtr nativeObj, int marginType);
  356. // C++: void cv::ml::SVMSGD::setOptimalParameters(int svmsgdType = SVMSGD::ASGD, int marginType = SVMSGD::SOFT_MARGIN)
  357. [DllImport (LIBNAME)]
  358. private static extern void ml_SVMSGD_setOptimalParameters_10 (IntPtr nativeObj, int svmsgdType, int marginType);
  359. [DllImport (LIBNAME)]
  360. private static extern void ml_SVMSGD_setOptimalParameters_11 (IntPtr nativeObj, int svmsgdType);
  361. [DllImport (LIBNAME)]
  362. private static extern void ml_SVMSGD_setOptimalParameters_12 (IntPtr nativeObj);
  363. // C++: void cv::ml::SVMSGD::setStepDecreasingPower(float stepDecreasingPower)
  364. [DllImport (LIBNAME)]
  365. private static extern void ml_SVMSGD_setStepDecreasingPower_10 (IntPtr nativeObj, float stepDecreasingPower);
  366. // C++: void cv::ml::SVMSGD::setSvmsgdType(int svmsgdType)
  367. [DllImport (LIBNAME)]
  368. private static extern void ml_SVMSGD_setSvmsgdType_10 (IntPtr nativeObj, int svmsgdType);
  369. // C++: void cv::ml::SVMSGD::setTermCriteria(TermCriteria val)
  370. [DllImport (LIBNAME)]
  371. private static extern void ml_SVMSGD_setTermCriteria_10 (IntPtr nativeObj, int val_type, int val_maxCount, double val_epsilon);
  372. // native support for java finalize()
  373. [DllImport (LIBNAME)]
  374. private static extern void ml_SVMSGD_delete (IntPtr nativeObj);
  375. }
  376. }