SparseMatchInterpolator.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.XimgprocModule
  7. {
  8. // C++: class SparseMatchInterpolator
  9. /**
  10. * Main interface for all filters, that take sparse matches as an
  11. * input and produce a dense per-pixel matching (optical flow) as an output.
  12. */
  13. public class SparseMatchInterpolator : Algorithm
  14. {
  15. protected override void Dispose(bool disposing)
  16. {
  17. try
  18. {
  19. if (disposing)
  20. {
  21. }
  22. if (IsEnabledDispose)
  23. {
  24. if (nativeObj != IntPtr.Zero)
  25. ximgproc_SparseMatchInterpolator_delete(nativeObj);
  26. nativeObj = IntPtr.Zero;
  27. }
  28. }
  29. finally
  30. {
  31. base.Dispose(disposing);
  32. }
  33. }
  34. protected internal SparseMatchInterpolator(IntPtr addr) : base(addr) { }
  35. // internal usage only
  36. public static new SparseMatchInterpolator __fromPtr__(IntPtr addr) { return new SparseMatchInterpolator(addr); }
  37. //
  38. // C++: void cv::ximgproc::SparseMatchInterpolator::interpolate(Mat from_image, Mat from_points, Mat to_image, Mat to_points, Mat& dense_flow)
  39. //
  40. /**
  41. * Interpolate input sparse matches.
  42. *
  43. * param from_image first of the two matched images, 8-bit single-channel or three-channel.
  44. *
  45. * param from_points points of the from_image for which there are correspondences in the
  46. * to_image (Point2f vector or Mat of depth CV_32F)
  47. *
  48. * param to_image second of the two matched images, 8-bit single-channel or three-channel.
  49. *
  50. * param to_points points in the to_image corresponding to from_points
  51. * (Point2f vector or Mat of depth CV_32F)
  52. *
  53. * param dense_flow output dense matching (two-channel CV_32F image)
  54. */
  55. public void interpolate(Mat from_image, Mat from_points, Mat to_image, Mat to_points, Mat dense_flow)
  56. {
  57. ThrowIfDisposed();
  58. if (from_image != null) from_image.ThrowIfDisposed();
  59. if (from_points != null) from_points.ThrowIfDisposed();
  60. if (to_image != null) to_image.ThrowIfDisposed();
  61. if (to_points != null) to_points.ThrowIfDisposed();
  62. if (dense_flow != null) dense_flow.ThrowIfDisposed();
  63. ximgproc_SparseMatchInterpolator_interpolate_10(nativeObj, from_image.nativeObj, from_points.nativeObj, to_image.nativeObj, to_points.nativeObj, dense_flow.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::ximgproc::SparseMatchInterpolator::interpolate(Mat from_image, Mat from_points, Mat to_image, Mat to_points, Mat& dense_flow)
  71. [DllImport(LIBNAME)]
  72. private static extern void ximgproc_SparseMatchInterpolator_interpolate_10(IntPtr nativeObj, IntPtr from_image_nativeObj, IntPtr from_points_nativeObj, IntPtr to_image_nativeObj, IntPtr to_points_nativeObj, IntPtr dense_flow_nativeObj);
  73. // native support for java finalize()
  74. [DllImport(LIBNAME)]
  75. private static extern void ximgproc_SparseMatchInterpolator_delete(IntPtr nativeObj);
  76. }
  77. }