CLAHE.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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.ImgprocModule
  8. {
  9. // C++: class CLAHE
  10. //javadoc: CLAHE
  11. public class CLAHE : Algorithm
  12. {
  13. protected override void Dispose (bool disposing)
  14. {
  15. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  16. try {
  17. if (disposing) {
  18. }
  19. if (IsEnabledDispose) {
  20. if (nativeObj != IntPtr.Zero)
  21. imgproc_CLAHE_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal CLAHE (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new CLAHE __fromPtr__ (IntPtr addr) { return new CLAHE (addr); }
  34. //
  35. // C++: Size cv::CLAHE::getTilesGridSize()
  36. //
  37. //javadoc: CLAHE::getTilesGridSize()
  38. public Size getTilesGridSize ()
  39. {
  40. ThrowIfDisposed ();
  41. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  42. double[] tmpArray = new double[2];
  43. imgproc_CLAHE_getTilesGridSize_10(nativeObj, tmpArray);
  44. Size retVal = new Size (tmpArray);
  45. return retVal;
  46. #else
  47. return null;
  48. #endif
  49. }
  50. //
  51. // C++: double cv::CLAHE::getClipLimit()
  52. //
  53. //javadoc: CLAHE::getClipLimit()
  54. public double getClipLimit ()
  55. {
  56. ThrowIfDisposed ();
  57. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  58. double retVal = imgproc_CLAHE_getClipLimit_10(nativeObj);
  59. return retVal;
  60. #else
  61. return -1;
  62. #endif
  63. }
  64. //
  65. // C++: void cv::CLAHE::apply(Mat src, Mat& dst)
  66. //
  67. //javadoc: CLAHE::apply(src, dst)
  68. public void apply (Mat src, Mat dst)
  69. {
  70. ThrowIfDisposed ();
  71. if (src != null) src.ThrowIfDisposed ();
  72. if (dst != null) dst.ThrowIfDisposed ();
  73. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  74. imgproc_CLAHE_apply_10(nativeObj, src.nativeObj, dst.nativeObj);
  75. return;
  76. #else
  77. return;
  78. #endif
  79. }
  80. //
  81. // C++: void cv::CLAHE::collectGarbage()
  82. //
  83. //javadoc: CLAHE::collectGarbage()
  84. public void collectGarbage ()
  85. {
  86. ThrowIfDisposed ();
  87. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  88. imgproc_CLAHE_collectGarbage_10(nativeObj);
  89. return;
  90. #else
  91. return;
  92. #endif
  93. }
  94. //
  95. // C++: void cv::CLAHE::setClipLimit(double clipLimit)
  96. //
  97. //javadoc: CLAHE::setClipLimit(clipLimit)
  98. public void setClipLimit (double clipLimit)
  99. {
  100. ThrowIfDisposed ();
  101. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  102. imgproc_CLAHE_setClipLimit_10(nativeObj, clipLimit);
  103. return;
  104. #else
  105. return;
  106. #endif
  107. }
  108. //
  109. // C++: void cv::CLAHE::setTilesGridSize(Size tileGridSize)
  110. //
  111. //javadoc: CLAHE::setTilesGridSize(tileGridSize)
  112. public void setTilesGridSize (Size tileGridSize)
  113. {
  114. ThrowIfDisposed ();
  115. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  116. imgproc_CLAHE_setTilesGridSize_10(nativeObj, tileGridSize.width, tileGridSize.height);
  117. return;
  118. #else
  119. return;
  120. #endif
  121. }
  122. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  123. const string LIBNAME = "__Internal";
  124. #else
  125. const string LIBNAME = "opencvforunity";
  126. #endif
  127. // C++: Size cv::CLAHE::getTilesGridSize()
  128. [DllImport (LIBNAME)]
  129. private static extern void imgproc_CLAHE_getTilesGridSize_10 (IntPtr nativeObj, double[] retVal);
  130. // C++: double cv::CLAHE::getClipLimit()
  131. [DllImport (LIBNAME)]
  132. private static extern double imgproc_CLAHE_getClipLimit_10 (IntPtr nativeObj);
  133. // C++: void cv::CLAHE::apply(Mat src, Mat& dst)
  134. [DllImport (LIBNAME)]
  135. private static extern void imgproc_CLAHE_apply_10 (IntPtr nativeObj, IntPtr src_nativeObj, IntPtr dst_nativeObj);
  136. // C++: void cv::CLAHE::collectGarbage()
  137. [DllImport (LIBNAME)]
  138. private static extern void imgproc_CLAHE_collectGarbage_10 (IntPtr nativeObj);
  139. // C++: void cv::CLAHE::setClipLimit(double clipLimit)
  140. [DllImport (LIBNAME)]
  141. private static extern void imgproc_CLAHE_setClipLimit_10 (IntPtr nativeObj, double clipLimit);
  142. // C++: void cv::CLAHE::setTilesGridSize(Size tileGridSize)
  143. [DllImport (LIBNAME)]
  144. private static extern void imgproc_CLAHE_setTilesGridSize_10 (IntPtr nativeObj, double tileGridSize_width, double tileGridSize_height);
  145. // native support for java finalize()
  146. [DllImport (LIBNAME)]
  147. private static extern void imgproc_CLAHE_delete (IntPtr nativeObj);
  148. }
  149. }