SVMSGD.cs 13 KB

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