BackgroundSubtractorMOG.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using OpenCVForUnity.VideoModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.BgsegmModule
  8. {
  9. // C++: class BackgroundSubtractorMOG
  10. /**
  11. * Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
  12. *
  13. * The class implements the algorithm described in CITE: KB2001 .
  14. */
  15. public class BackgroundSubtractorMOG : BackgroundSubtractor
  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. bgsegm_BackgroundSubtractorMOG_delete(nativeObj);
  28. nativeObj = IntPtr.Zero;
  29. }
  30. }
  31. finally
  32. {
  33. base.Dispose(disposing);
  34. }
  35. }
  36. protected internal BackgroundSubtractorMOG(IntPtr addr) : base(addr) { }
  37. // internal usage only
  38. public static new BackgroundSubtractorMOG __fromPtr__(IntPtr addr) { return new BackgroundSubtractorMOG(addr); }
  39. //
  40. // C++: int cv::bgsegm::BackgroundSubtractorMOG::getHistory()
  41. //
  42. public int getHistory()
  43. {
  44. ThrowIfDisposed();
  45. return bgsegm_BackgroundSubtractorMOG_getHistory_10(nativeObj);
  46. }
  47. //
  48. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setHistory(int nframes)
  49. //
  50. public void setHistory(int nframes)
  51. {
  52. ThrowIfDisposed();
  53. bgsegm_BackgroundSubtractorMOG_setHistory_10(nativeObj, nframes);
  54. }
  55. //
  56. // C++: int cv::bgsegm::BackgroundSubtractorMOG::getNMixtures()
  57. //
  58. public int getNMixtures()
  59. {
  60. ThrowIfDisposed();
  61. return bgsegm_BackgroundSubtractorMOG_getNMixtures_10(nativeObj);
  62. }
  63. //
  64. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setNMixtures(int nmix)
  65. //
  66. public void setNMixtures(int nmix)
  67. {
  68. ThrowIfDisposed();
  69. bgsegm_BackgroundSubtractorMOG_setNMixtures_10(nativeObj, nmix);
  70. }
  71. //
  72. // C++: double cv::bgsegm::BackgroundSubtractorMOG::getBackgroundRatio()
  73. //
  74. public double getBackgroundRatio()
  75. {
  76. ThrowIfDisposed();
  77. return bgsegm_BackgroundSubtractorMOG_getBackgroundRatio_10(nativeObj);
  78. }
  79. //
  80. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setBackgroundRatio(double backgroundRatio)
  81. //
  82. public void setBackgroundRatio(double backgroundRatio)
  83. {
  84. ThrowIfDisposed();
  85. bgsegm_BackgroundSubtractorMOG_setBackgroundRatio_10(nativeObj, backgroundRatio);
  86. }
  87. //
  88. // C++: double cv::bgsegm::BackgroundSubtractorMOG::getNoiseSigma()
  89. //
  90. public double getNoiseSigma()
  91. {
  92. ThrowIfDisposed();
  93. return bgsegm_BackgroundSubtractorMOG_getNoiseSigma_10(nativeObj);
  94. }
  95. //
  96. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setNoiseSigma(double noiseSigma)
  97. //
  98. public void setNoiseSigma(double noiseSigma)
  99. {
  100. ThrowIfDisposed();
  101. bgsegm_BackgroundSubtractorMOG_setNoiseSigma_10(nativeObj, noiseSigma);
  102. }
  103. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  104. const string LIBNAME = "__Internal";
  105. #else
  106. const string LIBNAME = "opencvforunity";
  107. #endif
  108. // C++: int cv::bgsegm::BackgroundSubtractorMOG::getHistory()
  109. [DllImport(LIBNAME)]
  110. private static extern int bgsegm_BackgroundSubtractorMOG_getHistory_10(IntPtr nativeObj);
  111. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setHistory(int nframes)
  112. [DllImport(LIBNAME)]
  113. private static extern void bgsegm_BackgroundSubtractorMOG_setHistory_10(IntPtr nativeObj, int nframes);
  114. // C++: int cv::bgsegm::BackgroundSubtractorMOG::getNMixtures()
  115. [DllImport(LIBNAME)]
  116. private static extern int bgsegm_BackgroundSubtractorMOG_getNMixtures_10(IntPtr nativeObj);
  117. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setNMixtures(int nmix)
  118. [DllImport(LIBNAME)]
  119. private static extern void bgsegm_BackgroundSubtractorMOG_setNMixtures_10(IntPtr nativeObj, int nmix);
  120. // C++: double cv::bgsegm::BackgroundSubtractorMOG::getBackgroundRatio()
  121. [DllImport(LIBNAME)]
  122. private static extern double bgsegm_BackgroundSubtractorMOG_getBackgroundRatio_10(IntPtr nativeObj);
  123. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setBackgroundRatio(double backgroundRatio)
  124. [DllImport(LIBNAME)]
  125. private static extern void bgsegm_BackgroundSubtractorMOG_setBackgroundRatio_10(IntPtr nativeObj, double backgroundRatio);
  126. // C++: double cv::bgsegm::BackgroundSubtractorMOG::getNoiseSigma()
  127. [DllImport(LIBNAME)]
  128. private static extern double bgsegm_BackgroundSubtractorMOG_getNoiseSigma_10(IntPtr nativeObj);
  129. // C++: void cv::bgsegm::BackgroundSubtractorMOG::setNoiseSigma(double noiseSigma)
  130. [DllImport(LIBNAME)]
  131. private static extern void bgsegm_BackgroundSubtractorMOG_setNoiseSigma_10(IntPtr nativeObj, double noiseSigma);
  132. // native support for java finalize()
  133. [DllImport(LIBNAME)]
  134. private static extern void bgsegm_BackgroundSubtractorMOG_delete(IntPtr nativeObj);
  135. }
  136. }