BackgroundSubtractorGSOC.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. 
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.VideoModule;
  4. using OpenCVForUnity.UtilsModule;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Runtime.InteropServices;
  8. namespace OpenCVForUnity.BgsegmModule {
  9. // C++: class BackgroundSubtractorGSOC
  10. //javadoc: BackgroundSubtractorGSOC
  11. public class BackgroundSubtractorGSOC : BackgroundSubtractor {
  12. protected override void Dispose(bool disposing) {
  13. #if (UNITY_ANDROID && !UNITY_EDITOR)
  14. try {
  15. if (disposing) {
  16. }
  17. if (IsEnabledDispose) {
  18. if (nativeObj != IntPtr.Zero)
  19. bgsegm_BackgroundSubtractorGSOC_delete(nativeObj);
  20. nativeObj = IntPtr.Zero;
  21. }
  22. } finally {
  23. base.Dispose(disposing);
  24. }
  25. #else
  26. return;
  27. #endif
  28. }
  29. protected internal BackgroundSubtractorGSOC(IntPtr addr)
  30. : base(addr) {
  31. }
  32. // internal usage only
  33. public static new BackgroundSubtractorGSOC __fromPtr__(IntPtr addr) {
  34. return new BackgroundSubtractorGSOC(addr);
  35. }
  36. //
  37. // C++: void cv::bgsegm::BackgroundSubtractorGSOC::apply(Mat image, Mat& fgmask, double learningRate = -1)
  38. //
  39. //javadoc: BackgroundSubtractorGSOC::apply(image, fgmask, learningRate)
  40. public override void apply(Mat image, Mat fgmask, double learningRate) {
  41. ThrowIfDisposed();
  42. if (image != null)
  43. image.ThrowIfDisposed();
  44. if (fgmask != null)
  45. fgmask.ThrowIfDisposed();
  46. #if (UNITY_ANDROID && !UNITY_EDITOR)
  47. bgsegm_BackgroundSubtractorGSOC_apply_10(nativeObj, image.nativeObj, fgmask.nativeObj, learningRate);
  48. return;
  49. #else
  50. return;
  51. #endif
  52. }
  53. //javadoc: BackgroundSubtractorGSOC::apply(image, fgmask)
  54. public override void apply(Mat image, Mat fgmask) {
  55. ThrowIfDisposed();
  56. if (image != null)
  57. image.ThrowIfDisposed();
  58. if (fgmask != null)
  59. fgmask.ThrowIfDisposed();
  60. #if (UNITY_ANDROID && !UNITY_EDITOR)
  61. bgsegm_BackgroundSubtractorGSOC_apply_11(nativeObj, image.nativeObj, fgmask.nativeObj);
  62. return;
  63. #else
  64. return;
  65. #endif
  66. }
  67. //
  68. // C++: void cv::bgsegm::BackgroundSubtractorGSOC::getBackgroundImage(Mat& backgroundImage)
  69. //
  70. //javadoc: BackgroundSubtractorGSOC::getBackgroundImage(backgroundImage)
  71. public override void getBackgroundImage(Mat backgroundImage) {
  72. ThrowIfDisposed();
  73. if (backgroundImage != null)
  74. backgroundImage.ThrowIfDisposed();
  75. #if (UNITY_ANDROID && !UNITY_EDITOR)
  76. bgsegm_BackgroundSubtractorGSOC_getBackgroundImage_10(nativeObj, backgroundImage.nativeObj);
  77. return;
  78. #else
  79. return;
  80. #endif
  81. }
  82. #if (UNITY_ANDROID && !UNITY_EDITOR)
  83. const string LIBNAME = "opencvforunity";
  84. // C++: void cv::bgsegm::BackgroundSubtractorGSOC::apply(Mat image, Mat& fgmask, double learningRate = -1)
  85. [DllImport(LIBNAME)]
  86. private static extern void bgsegm_BackgroundSubtractorGSOC_apply_10(IntPtr nativeObj, IntPtr image_nativeObj, IntPtr fgmask_nativeObj, double learningRate);
  87. [DllImport(LIBNAME)]
  88. private static extern void bgsegm_BackgroundSubtractorGSOC_apply_11(IntPtr nativeObj, IntPtr image_nativeObj, IntPtr fgmask_nativeObj);
  89. // C++: void cv::bgsegm::BackgroundSubtractorGSOC::getBackgroundImage(Mat& backgroundImage)
  90. [DllImport(LIBNAME)]
  91. private static extern void bgsegm_BackgroundSubtractorGSOC_getBackgroundImage_10(IntPtr nativeObj, IntPtr backgroundImage_nativeObj);
  92. // native support for java finalize()
  93. [DllImport(LIBNAME)]
  94. private static extern void bgsegm_BackgroundSubtractorGSOC_delete(IntPtr nativeObj);
  95. #endif
  96. }
  97. }