ParamGrid.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 ParamGrid
  9. /**
  10. * The structure represents the logarithmic grid range of statmodel parameters.
  11. *
  12. * It is used for optimizing statmodel accuracy by varying model parameters, the accuracy estimate
  13. * being computed by cross-validation.
  14. */
  15. public class ParamGrid : DisposableOpenCVObject
  16. {
  17. protected override void Dispose(bool disposing)
  18. {
  19. try
  20. {
  21. if (disposing)
  22. {
  23. }
  24. if (IsEnabledDispose)
  25. {
  26. if (nativeObj != IntPtr.Zero)
  27. ml_ParamGrid_delete(nativeObj);
  28. nativeObj = IntPtr.Zero;
  29. }
  30. }
  31. finally
  32. {
  33. base.Dispose(disposing);
  34. }
  35. }
  36. protected internal ParamGrid(IntPtr addr) : base(addr) { }
  37. public IntPtr getNativeObjAddr() { return nativeObj; }
  38. // internal usage only
  39. public static ParamGrid __fromPtr__(IntPtr addr) { return new ParamGrid(addr); }
  40. //
  41. // C++: static Ptr_ParamGrid cv::ml::ParamGrid::create(double minVal = 0., double maxVal = 0., double logstep = 1.)
  42. //
  43. /**
  44. * Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
  45. *
  46. * param minVal minimum value of the parameter grid
  47. * param maxVal maximum value of the parameter grid
  48. * param logstep Logarithmic step for iterating the statmodel parameter
  49. * return automatically generated
  50. */
  51. public static ParamGrid create(double minVal, double maxVal, double logstep)
  52. {
  53. return ParamGrid.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_ParamGrid_create_10(minVal, maxVal, logstep)));
  54. }
  55. /**
  56. * Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
  57. *
  58. * param minVal minimum value of the parameter grid
  59. * param maxVal maximum value of the parameter grid
  60. * return automatically generated
  61. */
  62. public static ParamGrid create(double minVal, double maxVal)
  63. {
  64. return ParamGrid.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_ParamGrid_create_11(minVal, maxVal)));
  65. }
  66. /**
  67. * Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
  68. *
  69. * param minVal minimum value of the parameter grid
  70. * return automatically generated
  71. */
  72. public static ParamGrid create(double minVal)
  73. {
  74. return ParamGrid.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_ParamGrid_create_12(minVal)));
  75. }
  76. /**
  77. * Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
  78. *
  79. * return automatically generated
  80. */
  81. public static ParamGrid create()
  82. {
  83. return ParamGrid.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_ParamGrid_create_13()));
  84. }
  85. //
  86. // C++: double ParamGrid::minVal
  87. //
  88. public double get_minVal()
  89. {
  90. ThrowIfDisposed();
  91. return ml_ParamGrid_get_1minVal_10(nativeObj);
  92. }
  93. //
  94. // C++: void ParamGrid::minVal
  95. //
  96. public void set_minVal(double minVal)
  97. {
  98. ThrowIfDisposed();
  99. ml_ParamGrid_set_1minVal_10(nativeObj, minVal);
  100. }
  101. //
  102. // C++: double ParamGrid::maxVal
  103. //
  104. public double get_maxVal()
  105. {
  106. ThrowIfDisposed();
  107. return ml_ParamGrid_get_1maxVal_10(nativeObj);
  108. }
  109. //
  110. // C++: void ParamGrid::maxVal
  111. //
  112. public void set_maxVal(double maxVal)
  113. {
  114. ThrowIfDisposed();
  115. ml_ParamGrid_set_1maxVal_10(nativeObj, maxVal);
  116. }
  117. //
  118. // C++: double ParamGrid::logStep
  119. //
  120. public double get_logStep()
  121. {
  122. ThrowIfDisposed();
  123. return ml_ParamGrid_get_1logStep_10(nativeObj);
  124. }
  125. //
  126. // C++: void ParamGrid::logStep
  127. //
  128. public void set_logStep(double logStep)
  129. {
  130. ThrowIfDisposed();
  131. ml_ParamGrid_set_1logStep_10(nativeObj, logStep);
  132. }
  133. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  134. const string LIBNAME = "__Internal";
  135. #else
  136. const string LIBNAME = "opencvforunity";
  137. #endif
  138. // C++: static Ptr_ParamGrid cv::ml::ParamGrid::create(double minVal = 0., double maxVal = 0., double logstep = 1.)
  139. [DllImport(LIBNAME)]
  140. private static extern IntPtr ml_ParamGrid_create_10(double minVal, double maxVal, double logstep);
  141. [DllImport(LIBNAME)]
  142. private static extern IntPtr ml_ParamGrid_create_11(double minVal, double maxVal);
  143. [DllImport(LIBNAME)]
  144. private static extern IntPtr ml_ParamGrid_create_12(double minVal);
  145. [DllImport(LIBNAME)]
  146. private static extern IntPtr ml_ParamGrid_create_13();
  147. // C++: double ParamGrid::minVal
  148. [DllImport(LIBNAME)]
  149. private static extern double ml_ParamGrid_get_1minVal_10(IntPtr nativeObj);
  150. // C++: void ParamGrid::minVal
  151. [DllImport(LIBNAME)]
  152. private static extern void ml_ParamGrid_set_1minVal_10(IntPtr nativeObj, double minVal);
  153. // C++: double ParamGrid::maxVal
  154. [DllImport(LIBNAME)]
  155. private static extern double ml_ParamGrid_get_1maxVal_10(IntPtr nativeObj);
  156. // C++: void ParamGrid::maxVal
  157. [DllImport(LIBNAME)]
  158. private static extern void ml_ParamGrid_set_1maxVal_10(IntPtr nativeObj, double maxVal);
  159. // C++: double ParamGrid::logStep
  160. [DllImport(LIBNAME)]
  161. private static extern double ml_ParamGrid_get_1logStep_10(IntPtr nativeObj);
  162. // C++: void ParamGrid::logStep
  163. [DllImport(LIBNAME)]
  164. private static extern void ml_ParamGrid_set_1logStep_10(IntPtr nativeObj, double logStep);
  165. // native support for java finalize()
  166. [DllImport(LIBNAME)]
  167. private static extern void ml_ParamGrid_delete(IntPtr nativeObj);
  168. }
  169. }