DenseOpticalFlow.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.VideoModule
  7. {
  8. // C++: class DenseOpticalFlow
  9. /**
  10. * Base class for dense optical flow algorithms
  11. */
  12. public class DenseOpticalFlow : Algorithm
  13. {
  14. protected override void Dispose(bool disposing)
  15. {
  16. try
  17. {
  18. if (disposing)
  19. {
  20. }
  21. if (IsEnabledDispose)
  22. {
  23. if (nativeObj != IntPtr.Zero)
  24. video_DenseOpticalFlow_delete(nativeObj);
  25. nativeObj = IntPtr.Zero;
  26. }
  27. }
  28. finally
  29. {
  30. base.Dispose(disposing);
  31. }
  32. }
  33. protected internal DenseOpticalFlow(IntPtr addr) : base(addr) { }
  34. // internal usage only
  35. public static new DenseOpticalFlow __fromPtr__(IntPtr addr) { return new DenseOpticalFlow(addr); }
  36. //
  37. // C++: void cv::DenseOpticalFlow::calc(Mat I0, Mat I1, Mat& flow)
  38. //
  39. /**
  40. * Calculates an optical flow.
  41. *
  42. * param I0 first 8-bit single-channel input image.
  43. * param I1 second input image of the same size and the same type as prev.
  44. * param flow computed flow image that has the same size as prev and type CV_32FC2.
  45. */
  46. public void calc(Mat I0, Mat I1, Mat flow)
  47. {
  48. ThrowIfDisposed();
  49. if (I0 != null) I0.ThrowIfDisposed();
  50. if (I1 != null) I1.ThrowIfDisposed();
  51. if (flow != null) flow.ThrowIfDisposed();
  52. video_DenseOpticalFlow_calc_10(nativeObj, I0.nativeObj, I1.nativeObj, flow.nativeObj);
  53. }
  54. //
  55. // C++: void cv::DenseOpticalFlow::collectGarbage()
  56. //
  57. /**
  58. * Releases all inner buffers.
  59. */
  60. public void collectGarbage()
  61. {
  62. ThrowIfDisposed();
  63. video_DenseOpticalFlow_collectGarbage_10(nativeObj);
  64. }
  65. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  66. const string LIBNAME = "__Internal";
  67. #else
  68. const string LIBNAME = "opencvforunity";
  69. #endif
  70. // C++: void cv::DenseOpticalFlow::calc(Mat I0, Mat I1, Mat& flow)
  71. [DllImport(LIBNAME)]
  72. private static extern void video_DenseOpticalFlow_calc_10(IntPtr nativeObj, IntPtr I0_nativeObj, IntPtr I1_nativeObj, IntPtr flow_nativeObj);
  73. // C++: void cv::DenseOpticalFlow::collectGarbage()
  74. [DllImport(LIBNAME)]
  75. private static extern void video_DenseOpticalFlow_collectGarbage_10(IntPtr nativeObj);
  76. // native support for java finalize()
  77. [DllImport(LIBNAME)]
  78. private static extern void video_DenseOpticalFlow_delete(IntPtr nativeObj);
  79. }
  80. }