BOWKMeansTrainer.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.Features2dModule
  8. {
  9. // C++: class BOWKMeansTrainer
  10. //javadoc: BOWKMeansTrainer
  11. public class BOWKMeansTrainer : BOWTrainer
  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. features2d_BOWKMeansTrainer_delete (nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal BOWKMeansTrainer (IntPtr addr)
  32. : base (addr)
  33. {
  34. }
  35. // internal usage only
  36. public static new BOWKMeansTrainer __fromPtr__ (IntPtr addr)
  37. {
  38. return new BOWKMeansTrainer (addr);
  39. }
  40. //
  41. // C++: cv::BOWKMeansTrainer::BOWKMeansTrainer(int clusterCount, TermCriteria termcrit = TermCriteria(), int attempts = 3, int flags = KMEANS_PP_CENTERS)
  42. //
  43. //javadoc: BOWKMeansTrainer::BOWKMeansTrainer(clusterCount, termcrit, attempts, flags)
  44. public BOWKMeansTrainer (int clusterCount, TermCriteria termcrit, int attempts, int flags) :
  45. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  46. base (features2d_BOWKMeansTrainer_BOWKMeansTrainer_10 (clusterCount, termcrit.type, termcrit.maxCount, termcrit.epsilon, attempts, flags))
  47. #else
  48. base (IntPtr.Zero)
  49. #endif
  50. {
  51. return;
  52. }
  53. //javadoc: BOWKMeansTrainer::BOWKMeansTrainer(clusterCount, termcrit, attempts)
  54. public BOWKMeansTrainer (int clusterCount, TermCriteria termcrit, int attempts) :
  55. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  56. base (features2d_BOWKMeansTrainer_BOWKMeansTrainer_11 (clusterCount, termcrit.type, termcrit.maxCount, termcrit.epsilon, attempts))
  57. #else
  58. base (IntPtr.Zero)
  59. #endif
  60. {
  61. return;
  62. }
  63. //javadoc: BOWKMeansTrainer::BOWKMeansTrainer(clusterCount, termcrit)
  64. public BOWKMeansTrainer (int clusterCount, TermCriteria termcrit) :
  65. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  66. base (features2d_BOWKMeansTrainer_BOWKMeansTrainer_12 (clusterCount, termcrit.type, termcrit.maxCount, termcrit.epsilon))
  67. #else
  68. base (IntPtr.Zero)
  69. #endif
  70. {
  71. return;
  72. }
  73. //javadoc: BOWKMeansTrainer::BOWKMeansTrainer(clusterCount)
  74. public BOWKMeansTrainer (int clusterCount) :
  75. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  76. base (features2d_BOWKMeansTrainer_BOWKMeansTrainer_13 (clusterCount))
  77. #else
  78. base (IntPtr.Zero)
  79. #endif
  80. {
  81. return;
  82. }
  83. //
  84. // C++: Mat cv::BOWKMeansTrainer::cluster(Mat descriptors)
  85. //
  86. //javadoc: BOWKMeansTrainer::cluster(descriptors)
  87. public override Mat cluster (Mat descriptors)
  88. {
  89. ThrowIfDisposed ();
  90. if (descriptors != null)
  91. descriptors.ThrowIfDisposed ();
  92. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  93. Mat retVal = new Mat (features2d_BOWKMeansTrainer_cluster_10 (nativeObj, descriptors.nativeObj));
  94. return retVal;
  95. #else
  96. return null;
  97. #endif
  98. }
  99. //
  100. // C++: Mat cv::BOWKMeansTrainer::cluster()
  101. //
  102. //javadoc: BOWKMeansTrainer::cluster()
  103. public override Mat cluster ()
  104. {
  105. ThrowIfDisposed ();
  106. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  107. Mat retVal = new Mat (features2d_BOWKMeansTrainer_cluster_11 (nativeObj));
  108. return retVal;
  109. #else
  110. return null;
  111. #endif
  112. }
  113. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  114. const string LIBNAME = "__Internal";
  115. #else
  116. const string LIBNAME = "opencvforunity";
  117. #endif
  118. // C++: cv::BOWKMeansTrainer::BOWKMeansTrainer(int clusterCount, TermCriteria termcrit = TermCriteria(), int attempts = 3, int flags = KMEANS_PP_CENTERS)
  119. [DllImport (LIBNAME)]
  120. private static extern IntPtr features2d_BOWKMeansTrainer_BOWKMeansTrainer_10 (int clusterCount, int termcrit_type, int termcrit_maxCount, double termcrit_epsilon, int attempts, int flags);
  121. [DllImport (LIBNAME)]
  122. private static extern IntPtr features2d_BOWKMeansTrainer_BOWKMeansTrainer_11 (int clusterCount, int termcrit_type, int termcrit_maxCount, double termcrit_epsilon, int attempts);
  123. [DllImport (LIBNAME)]
  124. private static extern IntPtr features2d_BOWKMeansTrainer_BOWKMeansTrainer_12 (int clusterCount, int termcrit_type, int termcrit_maxCount, double termcrit_epsilon);
  125. [DllImport (LIBNAME)]
  126. private static extern IntPtr features2d_BOWKMeansTrainer_BOWKMeansTrainer_13 (int clusterCount);
  127. // C++: Mat cv::BOWKMeansTrainer::cluster(Mat descriptors)
  128. [DllImport (LIBNAME)]
  129. private static extern IntPtr features2d_BOWKMeansTrainer_cluster_10 (IntPtr nativeObj, IntPtr descriptors_nativeObj);
  130. // C++: Mat cv::BOWKMeansTrainer::cluster()
  131. [DllImport (LIBNAME)]
  132. private static extern IntPtr features2d_BOWKMeansTrainer_cluster_11 (IntPtr nativeObj);
  133. // native support for java finalize()
  134. [DllImport (LIBNAME)]
  135. private static extern void features2d_BOWKMeansTrainer_delete (IntPtr nativeObj);
  136. }
  137. }