GraphSegmentation.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 GraphSegmentation
  9. /**
  10. * Graph Based Segmentation Algorithm.
  11. * The class implements the algorithm described in CITE: PFF2004 .
  12. */
  13. public class GraphSegmentation : 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_GraphSegmentation_delete(nativeObj);
  26. nativeObj = IntPtr.Zero;
  27. }
  28. }
  29. finally
  30. {
  31. base.Dispose(disposing);
  32. }
  33. }
  34. protected internal GraphSegmentation(IntPtr addr) : base(addr) { }
  35. // internal usage only
  36. public static new GraphSegmentation __fromPtr__(IntPtr addr) { return new GraphSegmentation(addr); }
  37. //
  38. // C++: void cv::ximgproc::segmentation::GraphSegmentation::processImage(Mat src, Mat& dst)
  39. //
  40. /**
  41. * Segment an image and store output in dst
  42. * param src The input image. Any number of channel (1 (Eg: Gray), 3 (Eg: RGB), 4 (Eg: RGB-D)) can be provided
  43. * param dst The output segmentation. It's a CV_32SC1 Mat with the same number of cols and rows as input image, with an unique, sequential, id for each pixel.
  44. */
  45. public void processImage(Mat src, Mat dst)
  46. {
  47. ThrowIfDisposed();
  48. if (src != null) src.ThrowIfDisposed();
  49. if (dst != null) dst.ThrowIfDisposed();
  50. ximgproc_GraphSegmentation_processImage_10(nativeObj, src.nativeObj, dst.nativeObj);
  51. }
  52. //
  53. // C++: void cv::ximgproc::segmentation::GraphSegmentation::setSigma(double sigma)
  54. //
  55. public void setSigma(double sigma)
  56. {
  57. ThrowIfDisposed();
  58. ximgproc_GraphSegmentation_setSigma_10(nativeObj, sigma);
  59. }
  60. //
  61. // C++: double cv::ximgproc::segmentation::GraphSegmentation::getSigma()
  62. //
  63. public double getSigma()
  64. {
  65. ThrowIfDisposed();
  66. return ximgproc_GraphSegmentation_getSigma_10(nativeObj);
  67. }
  68. //
  69. // C++: void cv::ximgproc::segmentation::GraphSegmentation::setK(float k)
  70. //
  71. public void setK(float k)
  72. {
  73. ThrowIfDisposed();
  74. ximgproc_GraphSegmentation_setK_10(nativeObj, k);
  75. }
  76. //
  77. // C++: float cv::ximgproc::segmentation::GraphSegmentation::getK()
  78. //
  79. public float getK()
  80. {
  81. ThrowIfDisposed();
  82. return ximgproc_GraphSegmentation_getK_10(nativeObj);
  83. }
  84. //
  85. // C++: void cv::ximgproc::segmentation::GraphSegmentation::setMinSize(int min_size)
  86. //
  87. public void setMinSize(int min_size)
  88. {
  89. ThrowIfDisposed();
  90. ximgproc_GraphSegmentation_setMinSize_10(nativeObj, min_size);
  91. }
  92. //
  93. // C++: int cv::ximgproc::segmentation::GraphSegmentation::getMinSize()
  94. //
  95. public int getMinSize()
  96. {
  97. ThrowIfDisposed();
  98. return ximgproc_GraphSegmentation_getMinSize_10(nativeObj);
  99. }
  100. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  101. const string LIBNAME = "__Internal";
  102. #else
  103. const string LIBNAME = "opencvforunity";
  104. #endif
  105. // C++: void cv::ximgproc::segmentation::GraphSegmentation::processImage(Mat src, Mat& dst)
  106. [DllImport(LIBNAME)]
  107. private static extern void ximgproc_GraphSegmentation_processImage_10(IntPtr nativeObj, IntPtr src_nativeObj, IntPtr dst_nativeObj);
  108. // C++: void cv::ximgproc::segmentation::GraphSegmentation::setSigma(double sigma)
  109. [DllImport(LIBNAME)]
  110. private static extern void ximgproc_GraphSegmentation_setSigma_10(IntPtr nativeObj, double sigma);
  111. // C++: double cv::ximgproc::segmentation::GraphSegmentation::getSigma()
  112. [DllImport(LIBNAME)]
  113. private static extern double ximgproc_GraphSegmentation_getSigma_10(IntPtr nativeObj);
  114. // C++: void cv::ximgproc::segmentation::GraphSegmentation::setK(float k)
  115. [DllImport(LIBNAME)]
  116. private static extern void ximgproc_GraphSegmentation_setK_10(IntPtr nativeObj, float k);
  117. // C++: float cv::ximgproc::segmentation::GraphSegmentation::getK()
  118. [DllImport(LIBNAME)]
  119. private static extern float ximgproc_GraphSegmentation_getK_10(IntPtr nativeObj);
  120. // C++: void cv::ximgproc::segmentation::GraphSegmentation::setMinSize(int min_size)
  121. [DllImport(LIBNAME)]
  122. private static extern void ximgproc_GraphSegmentation_setMinSize_10(IntPtr nativeObj, int min_size);
  123. // C++: int cv::ximgproc::segmentation::GraphSegmentation::getMinSize()
  124. [DllImport(LIBNAME)]
  125. private static extern int ximgproc_GraphSegmentation_getMinSize_10(IntPtr nativeObj);
  126. // native support for java finalize()
  127. [DllImport(LIBNAME)]
  128. private static extern void ximgproc_GraphSegmentation_delete(IntPtr nativeObj);
  129. }
  130. }