SuperpixelSEEDS.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.XimgprocModule {
  8. // C++: class SuperpixelSEEDS
  9. //javadoc: SuperpixelSEEDS
  10. public class SuperpixelSEEDS : Algorithm {
  11. protected override void Dispose(bool disposing) {
  12. #if (UNITY_ANDROID && !UNITY_EDITOR)
  13. try {
  14. if (disposing) {
  15. }
  16. if (IsEnabledDispose) {
  17. if (nativeObj != IntPtr.Zero)
  18. ximgproc_SuperpixelSEEDS_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal SuperpixelSEEDS(IntPtr addr) : base(addr) { }
  29. // internal usage only
  30. public static new SuperpixelSEEDS __fromPtr__(IntPtr addr) { return new SuperpixelSEEDS(addr); }
  31. //
  32. // C++: int cv::ximgproc::SuperpixelSEEDS::getNumberOfSuperpixels()
  33. //
  34. //javadoc: SuperpixelSEEDS::getNumberOfSuperpixels()
  35. public int getNumberOfSuperpixels() {
  36. ThrowIfDisposed();
  37. #if (UNITY_ANDROID && !UNITY_EDITOR)
  38. int retVal = ximgproc_SuperpixelSEEDS_getNumberOfSuperpixels_10(nativeObj);
  39. return retVal;
  40. #else
  41. return -1;
  42. #endif
  43. }
  44. //
  45. // C++: void cv::ximgproc::SuperpixelSEEDS::getLabelContourMask(Mat& image, bool thick_line = false)
  46. //
  47. //javadoc: SuperpixelSEEDS::getLabelContourMask(image, thick_line)
  48. public void getLabelContourMask(Mat image, bool thick_line) {
  49. ThrowIfDisposed();
  50. if (image != null) image.ThrowIfDisposed();
  51. #if (UNITY_ANDROID && !UNITY_EDITOR)
  52. ximgproc_SuperpixelSEEDS_getLabelContourMask_10(nativeObj, image.nativeObj, thick_line);
  53. return;
  54. #else
  55. return;
  56. #endif
  57. }
  58. //javadoc: SuperpixelSEEDS::getLabelContourMask(image)
  59. public void getLabelContourMask(Mat image) {
  60. ThrowIfDisposed();
  61. if (image != null) image.ThrowIfDisposed();
  62. #if (UNITY_ANDROID && !UNITY_EDITOR)
  63. ximgproc_SuperpixelSEEDS_getLabelContourMask_11(nativeObj, image.nativeObj);
  64. return;
  65. #else
  66. return;
  67. #endif
  68. }
  69. //
  70. // C++: void cv::ximgproc::SuperpixelSEEDS::getLabels(Mat& labels_out)
  71. //
  72. //javadoc: SuperpixelSEEDS::getLabels(labels_out)
  73. public void getLabels(Mat labels_out) {
  74. ThrowIfDisposed();
  75. if (labels_out != null) labels_out.ThrowIfDisposed();
  76. #if (UNITY_ANDROID && !UNITY_EDITOR)
  77. ximgproc_SuperpixelSEEDS_getLabels_10(nativeObj, labels_out.nativeObj);
  78. return;
  79. #else
  80. return;
  81. #endif
  82. }
  83. //
  84. // C++: void cv::ximgproc::SuperpixelSEEDS::iterate(Mat img, int num_iterations = 4)
  85. //
  86. //javadoc: SuperpixelSEEDS::iterate(img, num_iterations)
  87. public void iterate(Mat img, int num_iterations) {
  88. ThrowIfDisposed();
  89. if (img != null) img.ThrowIfDisposed();
  90. #if (UNITY_ANDROID && !UNITY_EDITOR)
  91. ximgproc_SuperpixelSEEDS_iterate_10(nativeObj, img.nativeObj, num_iterations);
  92. return;
  93. #else
  94. return;
  95. #endif
  96. }
  97. //javadoc: SuperpixelSEEDS::iterate(img)
  98. public void iterate(Mat img) {
  99. ThrowIfDisposed();
  100. if (img != null) img.ThrowIfDisposed();
  101. #if (UNITY_ANDROID && !UNITY_EDITOR)
  102. ximgproc_SuperpixelSEEDS_iterate_11(nativeObj, img.nativeObj);
  103. return;
  104. #else
  105. return;
  106. #endif
  107. }
  108. #if (UNITY_ANDROID && !UNITY_EDITOR)
  109. const string LIBNAME = "opencvforunity";
  110. // C++: int cv::ximgproc::SuperpixelSEEDS::getNumberOfSuperpixels()
  111. [DllImport(LIBNAME)]
  112. private static extern int ximgproc_SuperpixelSEEDS_getNumberOfSuperpixels_10(IntPtr nativeObj);
  113. // C++: void cv::ximgproc::SuperpixelSEEDS::getLabelContourMask(Mat& image, bool thick_line = false)
  114. [DllImport(LIBNAME)]
  115. private static extern void ximgproc_SuperpixelSEEDS_getLabelContourMask_10(IntPtr nativeObj, IntPtr image_nativeObj, bool thick_line);
  116. [DllImport(LIBNAME)]
  117. private static extern void ximgproc_SuperpixelSEEDS_getLabelContourMask_11(IntPtr nativeObj, IntPtr image_nativeObj);
  118. // C++: void cv::ximgproc::SuperpixelSEEDS::getLabels(Mat& labels_out)
  119. [DllImport(LIBNAME)]
  120. private static extern void ximgproc_SuperpixelSEEDS_getLabels_10(IntPtr nativeObj, IntPtr labels_out_nativeObj);
  121. // C++: void cv::ximgproc::SuperpixelSEEDS::iterate(Mat img, int num_iterations = 4)
  122. [DllImport(LIBNAME)]
  123. private static extern void ximgproc_SuperpixelSEEDS_iterate_10(IntPtr nativeObj, IntPtr img_nativeObj, int num_iterations);
  124. [DllImport(LIBNAME)]
  125. private static extern void ximgproc_SuperpixelSEEDS_iterate_11(IntPtr nativeObj, IntPtr img_nativeObj);
  126. // native support for java finalize()
  127. [DllImport(LIBNAME)]
  128. private static extern void ximgproc_SuperpixelSEEDS_delete(IntPtr nativeObj);
  129. #endif
  130. }
  131. }