CLAHE.cs 4.8 KB

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