Boost.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.MlModule
  7. {
  8. // C++: class Boost
  9. /**
  10. * Boosted tree classifier derived from DTrees
  11. *
  12. * SEE: REF: ml_intro_boost
  13. */
  14. public class Boost : DTrees
  15. {
  16. protected override void Dispose(bool disposing)
  17. {
  18. try
  19. {
  20. if (disposing)
  21. {
  22. }
  23. if (IsEnabledDispose)
  24. {
  25. if (nativeObj != IntPtr.Zero)
  26. ml_Boost_delete(nativeObj);
  27. nativeObj = IntPtr.Zero;
  28. }
  29. }
  30. finally
  31. {
  32. base.Dispose(disposing);
  33. }
  34. }
  35. protected internal Boost(IntPtr addr) : base(addr) { }
  36. // internal usage only
  37. public static new Boost __fromPtr__(IntPtr addr) { return new Boost(addr); }
  38. // C++: enum cv.ml.Boost.Types
  39. public const int DISCRETE = 0;
  40. public const int REAL = 1;
  41. public const int LOGIT = 2;
  42. public const int GENTLE = 3;
  43. //
  44. // C++: int cv::ml::Boost::getBoostType()
  45. //
  46. /**
  47. * SEE: setBoostType
  48. * return automatically generated
  49. */
  50. public int getBoostType()
  51. {
  52. ThrowIfDisposed();
  53. return ml_Boost_getBoostType_10(nativeObj);
  54. }
  55. //
  56. // C++: void cv::ml::Boost::setBoostType(int val)
  57. //
  58. /**
  59. * getBoostType SEE: getBoostType
  60. * param val automatically generated
  61. */
  62. public void setBoostType(int val)
  63. {
  64. ThrowIfDisposed();
  65. ml_Boost_setBoostType_10(nativeObj, val);
  66. }
  67. //
  68. // C++: int cv::ml::Boost::getWeakCount()
  69. //
  70. /**
  71. * SEE: setWeakCount
  72. * return automatically generated
  73. */
  74. public int getWeakCount()
  75. {
  76. ThrowIfDisposed();
  77. return ml_Boost_getWeakCount_10(nativeObj);
  78. }
  79. //
  80. // C++: void cv::ml::Boost::setWeakCount(int val)
  81. //
  82. /**
  83. * getWeakCount SEE: getWeakCount
  84. * param val automatically generated
  85. */
  86. public void setWeakCount(int val)
  87. {
  88. ThrowIfDisposed();
  89. ml_Boost_setWeakCount_10(nativeObj, val);
  90. }
  91. //
  92. // C++: double cv::ml::Boost::getWeightTrimRate()
  93. //
  94. /**
  95. * SEE: setWeightTrimRate
  96. * return automatically generated
  97. */
  98. public double getWeightTrimRate()
  99. {
  100. ThrowIfDisposed();
  101. return ml_Boost_getWeightTrimRate_10(nativeObj);
  102. }
  103. //
  104. // C++: void cv::ml::Boost::setWeightTrimRate(double val)
  105. //
  106. /**
  107. * getWeightTrimRate SEE: getWeightTrimRate
  108. * param val automatically generated
  109. */
  110. public void setWeightTrimRate(double val)
  111. {
  112. ThrowIfDisposed();
  113. ml_Boost_setWeightTrimRate_10(nativeObj, val);
  114. }
  115. //
  116. // C++: static Ptr_Boost cv::ml::Boost::create()
  117. //
  118. /**
  119. * Creates the empty model.
  120. * Use StatModel::train to train the model, Algorithm::load<Boost>(filename) to load the pre-trained model.
  121. * return automatically generated
  122. */
  123. public static new Boost create()
  124. {
  125. return Boost.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_Boost_create_10()));
  126. }
  127. //
  128. // C++: static Ptr_Boost cv::ml::Boost::load(String filepath, String nodeName = String())
  129. //
  130. /**
  131. * Loads and creates a serialized Boost from a file
  132. *
  133. * Use Boost::save to serialize and store an RTree to disk.
  134. * Load the Boost from this file again, by calling this function with the path to the file.
  135. * Optionally specify the node for the file containing the classifier
  136. *
  137. * param filepath path to serialized Boost
  138. * param nodeName name of node containing the classifier
  139. * return automatically generated
  140. */
  141. public static new Boost load(string filepath, string nodeName)
  142. {
  143. return Boost.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_Boost_load_10(filepath, nodeName)));
  144. }
  145. /**
  146. * Loads and creates a serialized Boost from a file
  147. *
  148. * Use Boost::save to serialize and store an RTree to disk.
  149. * Load the Boost from this file again, by calling this function with the path to the file.
  150. * Optionally specify the node for the file containing the classifier
  151. *
  152. * param filepath path to serialized Boost
  153. * return automatically generated
  154. */
  155. public static new Boost load(string filepath)
  156. {
  157. return Boost.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_Boost_load_11(filepath)));
  158. }
  159. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  160. const string LIBNAME = "__Internal";
  161. #else
  162. const string LIBNAME = "opencvforunity";
  163. #endif
  164. // C++: int cv::ml::Boost::getBoostType()
  165. [DllImport(LIBNAME)]
  166. private static extern int ml_Boost_getBoostType_10(IntPtr nativeObj);
  167. // C++: void cv::ml::Boost::setBoostType(int val)
  168. [DllImport(LIBNAME)]
  169. private static extern void ml_Boost_setBoostType_10(IntPtr nativeObj, int val);
  170. // C++: int cv::ml::Boost::getWeakCount()
  171. [DllImport(LIBNAME)]
  172. private static extern int ml_Boost_getWeakCount_10(IntPtr nativeObj);
  173. // C++: void cv::ml::Boost::setWeakCount(int val)
  174. [DllImport(LIBNAME)]
  175. private static extern void ml_Boost_setWeakCount_10(IntPtr nativeObj, int val);
  176. // C++: double cv::ml::Boost::getWeightTrimRate()
  177. [DllImport(LIBNAME)]
  178. private static extern double ml_Boost_getWeightTrimRate_10(IntPtr nativeObj);
  179. // C++: void cv::ml::Boost::setWeightTrimRate(double val)
  180. [DllImport(LIBNAME)]
  181. private static extern void ml_Boost_setWeightTrimRate_10(IntPtr nativeObj, double val);
  182. // C++: static Ptr_Boost cv::ml::Boost::create()
  183. [DllImport(LIBNAME)]
  184. private static extern IntPtr ml_Boost_create_10();
  185. // C++: static Ptr_Boost cv::ml::Boost::load(String filepath, String nodeName = String())
  186. [DllImport(LIBNAME)]
  187. private static extern IntPtr ml_Boost_load_10(string filepath, string nodeName);
  188. [DllImport(LIBNAME)]
  189. private static extern IntPtr ml_Boost_load_11(string filepath);
  190. // native support for java finalize()
  191. [DllImport(LIBNAME)]
  192. private static extern void ml_Boost_delete(IntPtr nativeObj);
  193. }
  194. }