HistogramPhaseUnwrapping.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #if !UNITY_WEBGL
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.Phase_unwrappingModule
  8. {
  9. // C++: class HistogramPhaseUnwrapping
  10. /**
  11. * Class implementing two-dimensional phase unwrapping based on CITE: histogramUnwrapping
  12. * This algorithm belongs to the quality-guided phase unwrapping methods.
  13. * First, it computes a reliability map from second differences between a pixel and its eight neighbours.
  14. * Reliability values lie between 0 and 16*pi*pi. Then, this reliability map is used to compute
  15. * the reliabilities of "edges". An edge is an entity defined by two pixels that are connected
  16. * horizontally or vertically. Its reliability is found by adding the the reliabilities of the
  17. * two pixels connected through it. Edges are sorted in a histogram based on their reliability values.
  18. * This histogram is then used to unwrap pixels, starting from the highest quality pixel.
  19. *
  20. * The wrapped phase map and the unwrapped result are stored in CV_32FC1 Mat.
  21. */
  22. public class HistogramPhaseUnwrapping : PhaseUnwrapping
  23. {
  24. protected override void Dispose(bool disposing)
  25. {
  26. try
  27. {
  28. if (disposing)
  29. {
  30. }
  31. if (IsEnabledDispose)
  32. {
  33. if (nativeObj != IntPtr.Zero)
  34. phase_1unwrapping_HistogramPhaseUnwrapping_delete(nativeObj);
  35. nativeObj = IntPtr.Zero;
  36. }
  37. }
  38. finally
  39. {
  40. base.Dispose(disposing);
  41. }
  42. }
  43. protected internal HistogramPhaseUnwrapping(IntPtr addr) : base(addr) { }
  44. // internal usage only
  45. public static new HistogramPhaseUnwrapping __fromPtr__(IntPtr addr) { return new HistogramPhaseUnwrapping(addr); }
  46. //
  47. // C++: static Ptr_HistogramPhaseUnwrapping cv::phase_unwrapping::HistogramPhaseUnwrapping::create(HistogramPhaseUnwrapping_Params parameters = HistogramPhaseUnwrapping::Params())
  48. //
  49. /**
  50. * Constructor
  51. *
  52. * param parameters HistogramPhaseUnwrapping parameters HistogramPhaseUnwrapping::Params: width,height of the phase map and histogram characteristics.
  53. * return automatically generated
  54. */
  55. public static HistogramPhaseUnwrapping create(HistogramPhaseUnwrapping_Params parameters)
  56. {
  57. if (parameters != null) parameters.ThrowIfDisposed();
  58. return HistogramPhaseUnwrapping.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(phase_1unwrapping_HistogramPhaseUnwrapping_create_10(parameters.nativeObj)));
  59. }
  60. /**
  61. * Constructor
  62. *
  63. * return automatically generated
  64. */
  65. public static HistogramPhaseUnwrapping create()
  66. {
  67. return HistogramPhaseUnwrapping.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(phase_1unwrapping_HistogramPhaseUnwrapping_create_11()));
  68. }
  69. //
  70. // C++: void cv::phase_unwrapping::HistogramPhaseUnwrapping::getInverseReliabilityMap(Mat& reliabilityMap)
  71. //
  72. /**
  73. * Get the reliability map computed from the wrapped phase map.
  74. *
  75. * param reliabilityMap Image where the reliability map is stored.
  76. */
  77. public void getInverseReliabilityMap(Mat reliabilityMap)
  78. {
  79. ThrowIfDisposed();
  80. if (reliabilityMap != null) reliabilityMap.ThrowIfDisposed();
  81. phase_1unwrapping_HistogramPhaseUnwrapping_getInverseReliabilityMap_10(nativeObj, reliabilityMap.nativeObj);
  82. }
  83. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  84. const string LIBNAME = "__Internal";
  85. #else
  86. const string LIBNAME = "opencvforunity";
  87. #endif
  88. // C++: static Ptr_HistogramPhaseUnwrapping cv::phase_unwrapping::HistogramPhaseUnwrapping::create(HistogramPhaseUnwrapping_Params parameters = HistogramPhaseUnwrapping::Params())
  89. [DllImport(LIBNAME)]
  90. private static extern IntPtr phase_1unwrapping_HistogramPhaseUnwrapping_create_10(IntPtr parameters_nativeObj);
  91. [DllImport(LIBNAME)]
  92. private static extern IntPtr phase_1unwrapping_HistogramPhaseUnwrapping_create_11();
  93. // C++: void cv::phase_unwrapping::HistogramPhaseUnwrapping::getInverseReliabilityMap(Mat& reliabilityMap)
  94. [DllImport(LIBNAME)]
  95. private static extern void phase_1unwrapping_HistogramPhaseUnwrapping_getInverseReliabilityMap_10(IntPtr nativeObj, IntPtr reliabilityMap_nativeObj);
  96. // native support for java finalize()
  97. [DllImport(LIBNAME)]
  98. private static extern void phase_1unwrapping_HistogramPhaseUnwrapping_delete(IntPtr nativeObj);
  99. }
  100. }
  101. #endif