SyntheticSequenceGenerator.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.BgsegmModule
  7. {
  8. // C++: class SyntheticSequenceGenerator
  9. /**
  10. * Synthetic frame sequence generator for testing background subtraction algorithms.
  11. *
  12. * It will generate the moving object on top of the background.
  13. * It will apply some distortion to the background to make the test more complex.
  14. */
  15. public class SyntheticSequenceGenerator : Algorithm
  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_SyntheticSequenceGenerator_delete(nativeObj);
  28. nativeObj = IntPtr.Zero;
  29. }
  30. }
  31. finally
  32. {
  33. base.Dispose(disposing);
  34. }
  35. }
  36. protected internal SyntheticSequenceGenerator(IntPtr addr) : base(addr) { }
  37. // internal usage only
  38. public static new SyntheticSequenceGenerator __fromPtr__(IntPtr addr) { return new SyntheticSequenceGenerator(addr); }
  39. //
  40. // C++: cv::bgsegm::SyntheticSequenceGenerator::SyntheticSequenceGenerator(Mat background, Mat _object, double amplitude, double wavelength, double wavespeed, double objspeed)
  41. //
  42. /**
  43. * Creates an instance of SyntheticSequenceGenerator.
  44. *
  45. * param background Background image for object.
  46. * param amplitude Amplitude of wave distortion applied to background.
  47. * param wavelength Length of waves in distortion applied to background.
  48. * param wavespeed How fast waves will move.
  49. * param objspeed How fast object will fly over background.
  50. * param _object automatically generated
  51. */
  52. public SyntheticSequenceGenerator(Mat background, Mat _object, double amplitude, double wavelength, double wavespeed, double objspeed) :
  53. base(DisposableObject.ThrowIfNullIntPtr(bgsegm_SyntheticSequenceGenerator_SyntheticSequenceGenerator_10(background.nativeObj, _object.nativeObj, amplitude, wavelength, wavespeed, objspeed)))
  54. {
  55. }
  56. //
  57. // C++: void cv::bgsegm::SyntheticSequenceGenerator::getNextFrame(Mat& frame, Mat& gtMask)
  58. //
  59. /**
  60. * Obtain the next frame in the sequence.
  61. *
  62. * param frame Output frame.
  63. * param gtMask Output ground-truth (reference) segmentation mask object/background.
  64. */
  65. public void getNextFrame(Mat frame, Mat gtMask)
  66. {
  67. ThrowIfDisposed();
  68. if (frame != null) frame.ThrowIfDisposed();
  69. if (gtMask != null) gtMask.ThrowIfDisposed();
  70. bgsegm_SyntheticSequenceGenerator_getNextFrame_10(nativeObj, frame.nativeObj, gtMask.nativeObj);
  71. }
  72. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  73. const string LIBNAME = "__Internal";
  74. #else
  75. const string LIBNAME = "opencvforunity";
  76. #endif
  77. // C++: cv::bgsegm::SyntheticSequenceGenerator::SyntheticSequenceGenerator(Mat background, Mat _object, double amplitude, double wavelength, double wavespeed, double objspeed)
  78. [DllImport(LIBNAME)]
  79. private static extern IntPtr bgsegm_SyntheticSequenceGenerator_SyntheticSequenceGenerator_10(IntPtr background_nativeObj, IntPtr _object_nativeObj, double amplitude, double wavelength, double wavespeed, double objspeed);
  80. // C++: void cv::bgsegm::SyntheticSequenceGenerator::getNextFrame(Mat& frame, Mat& gtMask)
  81. [DllImport(LIBNAME)]
  82. private static extern void bgsegm_SyntheticSequenceGenerator_getNextFrame_10(IntPtr nativeObj, IntPtr frame_nativeObj, IntPtr gtMask_nativeObj);
  83. // native support for java finalize()
  84. [DllImport(LIBNAME)]
  85. private static extern void bgsegm_SyntheticSequenceGenerator_delete(IntPtr nativeObj);
  86. }
  87. }