SuperpixelLSC.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 SuperpixelLSC
  9. //javadoc: SuperpixelLSC
  10. public class SuperpixelLSC : 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_SuperpixelLSC_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal SuperpixelLSC(IntPtr addr) : base(addr) { }
  29. // internal usage only
  30. public static new SuperpixelLSC __fromPtr__(IntPtr addr) { return new SuperpixelLSC(addr); }
  31. //
  32. // C++: int cv::ximgproc::SuperpixelLSC::getNumberOfSuperpixels()
  33. //
  34. //javadoc: SuperpixelLSC::getNumberOfSuperpixels()
  35. public int getNumberOfSuperpixels() {
  36. ThrowIfDisposed();
  37. #if (UNITY_ANDROID && !UNITY_EDITOR)
  38. int retVal = ximgproc_SuperpixelLSC_getNumberOfSuperpixels_10(nativeObj);
  39. return retVal;
  40. #else
  41. return -1;
  42. #endif
  43. }
  44. //
  45. // C++: void cv::ximgproc::SuperpixelLSC::enforceLabelConnectivity(int min_element_size = 20)
  46. //
  47. //javadoc: SuperpixelLSC::enforceLabelConnectivity(min_element_size)
  48. public void enforceLabelConnectivity(int min_element_size) {
  49. ThrowIfDisposed();
  50. #if (UNITY_ANDROID && !UNITY_EDITOR)
  51. ximgproc_SuperpixelLSC_enforceLabelConnectivity_10(nativeObj, min_element_size);
  52. return;
  53. #else
  54. return;
  55. #endif
  56. }
  57. //javadoc: SuperpixelLSC::enforceLabelConnectivity()
  58. public void enforceLabelConnectivity() {
  59. ThrowIfDisposed();
  60. #if (UNITY_ANDROID && !UNITY_EDITOR)
  61. ximgproc_SuperpixelLSC_enforceLabelConnectivity_11(nativeObj);
  62. return;
  63. #else
  64. return;
  65. #endif
  66. }
  67. //
  68. // C++: void cv::ximgproc::SuperpixelLSC::getLabelContourMask(Mat& image, bool thick_line = true)
  69. //
  70. //javadoc: SuperpixelLSC::getLabelContourMask(image, thick_line)
  71. public void getLabelContourMask(Mat image, bool thick_line) {
  72. ThrowIfDisposed();
  73. if (image != null) image.ThrowIfDisposed();
  74. #if (UNITY_ANDROID && !UNITY_EDITOR)
  75. ximgproc_SuperpixelLSC_getLabelContourMask_10(nativeObj, image.nativeObj, thick_line);
  76. return;
  77. #else
  78. return;
  79. #endif
  80. }
  81. //javadoc: SuperpixelLSC::getLabelContourMask(image)
  82. public void getLabelContourMask(Mat image) {
  83. ThrowIfDisposed();
  84. if (image != null) image.ThrowIfDisposed();
  85. #if (UNITY_ANDROID && !UNITY_EDITOR)
  86. ximgproc_SuperpixelLSC_getLabelContourMask_11(nativeObj, image.nativeObj);
  87. return;
  88. #else
  89. return;
  90. #endif
  91. }
  92. //
  93. // C++: void cv::ximgproc::SuperpixelLSC::getLabels(Mat& labels_out)
  94. //
  95. //javadoc: SuperpixelLSC::getLabels(labels_out)
  96. public void getLabels(Mat labels_out) {
  97. ThrowIfDisposed();
  98. if (labels_out != null) labels_out.ThrowIfDisposed();
  99. #if (UNITY_ANDROID && !UNITY_EDITOR)
  100. ximgproc_SuperpixelLSC_getLabels_10(nativeObj, labels_out.nativeObj);
  101. return;
  102. #else
  103. return;
  104. #endif
  105. }
  106. //
  107. // C++: void cv::ximgproc::SuperpixelLSC::iterate(int num_iterations = 10)
  108. //
  109. //javadoc: SuperpixelLSC::iterate(num_iterations)
  110. public void iterate(int num_iterations) {
  111. ThrowIfDisposed();
  112. #if (UNITY_ANDROID && !UNITY_EDITOR)
  113. ximgproc_SuperpixelLSC_iterate_10(nativeObj, num_iterations);
  114. return;
  115. #else
  116. return;
  117. #endif
  118. }
  119. //javadoc: SuperpixelLSC::iterate()
  120. public void iterate() {
  121. ThrowIfDisposed();
  122. #if (UNITY_ANDROID && !UNITY_EDITOR)
  123. ximgproc_SuperpixelLSC_iterate_11(nativeObj);
  124. return;
  125. #else
  126. return;
  127. #endif
  128. }
  129. #if (UNITY_ANDROID && !UNITY_EDITOR)
  130. const string LIBNAME = "opencvforunity";
  131. // C++: int cv::ximgproc::SuperpixelLSC::getNumberOfSuperpixels()
  132. [DllImport(LIBNAME)]
  133. private static extern int ximgproc_SuperpixelLSC_getNumberOfSuperpixels_10(IntPtr nativeObj);
  134. // C++: void cv::ximgproc::SuperpixelLSC::enforceLabelConnectivity(int min_element_size = 20)
  135. [DllImport(LIBNAME)]
  136. private static extern void ximgproc_SuperpixelLSC_enforceLabelConnectivity_10(IntPtr nativeObj, int min_element_size);
  137. [DllImport(LIBNAME)]
  138. private static extern void ximgproc_SuperpixelLSC_enforceLabelConnectivity_11(IntPtr nativeObj);
  139. // C++: void cv::ximgproc::SuperpixelLSC::getLabelContourMask(Mat& image, bool thick_line = true)
  140. [DllImport(LIBNAME)]
  141. private static extern void ximgproc_SuperpixelLSC_getLabelContourMask_10(IntPtr nativeObj, IntPtr image_nativeObj, bool thick_line);
  142. [DllImport(LIBNAME)]
  143. private static extern void ximgproc_SuperpixelLSC_getLabelContourMask_11(IntPtr nativeObj, IntPtr image_nativeObj);
  144. // C++: void cv::ximgproc::SuperpixelLSC::getLabels(Mat& labels_out)
  145. [DllImport(LIBNAME)]
  146. private static extern void ximgproc_SuperpixelLSC_getLabels_10(IntPtr nativeObj, IntPtr labels_out_nativeObj);
  147. // C++: void cv::ximgproc::SuperpixelLSC::iterate(int num_iterations = 10)
  148. [DllImport(LIBNAME)]
  149. private static extern void ximgproc_SuperpixelLSC_iterate_10(IntPtr nativeObj, int num_iterations);
  150. [DllImport(LIBNAME)]
  151. private static extern void ximgproc_SuperpixelLSC_iterate_11(IntPtr nativeObj);
  152. // native support for java finalize()
  153. [DllImport(LIBNAME)]
  154. private static extern void ximgproc_SuperpixelLSC_delete(IntPtr nativeObj);
  155. #endif
  156. }
  157. }