SparseOpticalFlow.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. 
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.VideoModule
  8. {
  9. // C++: class SparseOpticalFlow
  10. //javadoc: SparseOpticalFlow
  11. public class SparseOpticalFlow : Algorithm
  12. {
  13. protected override void Dispose (bool disposing)
  14. {
  15. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  16. try {
  17. if (disposing) {
  18. }
  19. if (IsEnabledDispose) {
  20. if (nativeObj != IntPtr.Zero)
  21. video_SparseOpticalFlow_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal SparseOpticalFlow (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new SparseOpticalFlow __fromPtr__ (IntPtr addr) { return new SparseOpticalFlow (addr); }
  34. //
  35. // C++: void cv::SparseOpticalFlow::calc(Mat prevImg, Mat nextImg, Mat prevPts, Mat& nextPts, Mat& status, Mat& err = cv::Mat())
  36. //
  37. //javadoc: SparseOpticalFlow::calc(prevImg, nextImg, prevPts, nextPts, status, err)
  38. public void calc (Mat prevImg, Mat nextImg, Mat prevPts, Mat nextPts, Mat status, Mat err)
  39. {
  40. ThrowIfDisposed ();
  41. if (prevImg != null) prevImg.ThrowIfDisposed ();
  42. if (nextImg != null) nextImg.ThrowIfDisposed ();
  43. if (prevPts != null) prevPts.ThrowIfDisposed ();
  44. if (nextPts != null) nextPts.ThrowIfDisposed ();
  45. if (status != null) status.ThrowIfDisposed ();
  46. if (err != null) err.ThrowIfDisposed ();
  47. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  48. video_SparseOpticalFlow_calc_10(nativeObj, prevImg.nativeObj, nextImg.nativeObj, prevPts.nativeObj, nextPts.nativeObj, status.nativeObj, err.nativeObj);
  49. return;
  50. #else
  51. return;
  52. #endif
  53. }
  54. //javadoc: SparseOpticalFlow::calc(prevImg, nextImg, prevPts, nextPts, status)
  55. public void calc (Mat prevImg, Mat nextImg, Mat prevPts, Mat nextPts, Mat status)
  56. {
  57. ThrowIfDisposed ();
  58. if (prevImg != null) prevImg.ThrowIfDisposed ();
  59. if (nextImg != null) nextImg.ThrowIfDisposed ();
  60. if (prevPts != null) prevPts.ThrowIfDisposed ();
  61. if (nextPts != null) nextPts.ThrowIfDisposed ();
  62. if (status != null) status.ThrowIfDisposed ();
  63. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  64. video_SparseOpticalFlow_calc_11(nativeObj, prevImg.nativeObj, nextImg.nativeObj, prevPts.nativeObj, nextPts.nativeObj, status.nativeObj);
  65. return;
  66. #else
  67. return;
  68. #endif
  69. }
  70. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  71. const string LIBNAME = "__Internal";
  72. #else
  73. const string LIBNAME = "opencvforunity";
  74. #endif
  75. // C++: void cv::SparseOpticalFlow::calc(Mat prevImg, Mat nextImg, Mat prevPts, Mat& nextPts, Mat& status, Mat& err = cv::Mat())
  76. [DllImport (LIBNAME)]
  77. private static extern void video_SparseOpticalFlow_calc_10 (IntPtr nativeObj, IntPtr prevImg_nativeObj, IntPtr nextImg_nativeObj, IntPtr prevPts_nativeObj, IntPtr nextPts_nativeObj, IntPtr status_nativeObj, IntPtr err_nativeObj);
  78. [DllImport (LIBNAME)]
  79. private static extern void video_SparseOpticalFlow_calc_11 (IntPtr nativeObj, IntPtr prevImg_nativeObj, IntPtr nextImg_nativeObj, IntPtr prevPts_nativeObj, IntPtr nextPts_nativeObj, IntPtr status_nativeObj);
  80. // native support for java finalize()
  81. [DllImport (LIBNAME)]
  82. private static extern void video_SparseOpticalFlow_delete (IntPtr nativeObj);
  83. }
  84. }