EdgeAwareInterpolator.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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 EdgeAwareInterpolator
  9. /**
  10. * Sparse match interpolation algorithm based on modified locally-weighted affine
  11. * estimator from CITE: Revaud2015 and Fast Global Smoother as post-processing filter.
  12. */
  13. public class EdgeAwareInterpolator : SparseMatchInterpolator
  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_EdgeAwareInterpolator_delete(nativeObj);
  26. nativeObj = IntPtr.Zero;
  27. }
  28. }
  29. finally
  30. {
  31. base.Dispose(disposing);
  32. }
  33. }
  34. protected internal EdgeAwareInterpolator(IntPtr addr) : base(addr) { }
  35. // internal usage only
  36. public static new EdgeAwareInterpolator __fromPtr__(IntPtr addr) { return new EdgeAwareInterpolator(addr); }
  37. //
  38. // C++: void cv::ximgproc::EdgeAwareInterpolator::setCostMap(Mat _costMap)
  39. //
  40. /**
  41. * Interface to provide a more elaborated cost map, i.e. edge map, for the edge-aware term.
  42. * This implementation is based on a rather simple gradient-based edge map estimation.
  43. * To used more complex edge map estimator (e.g. StructuredEdgeDetection that has been
  44. * used in the original publication) that may lead to improved accuracies, the internal
  45. * edge map estimation can be bypassed here.
  46. * param _costMap a type CV_32FC1 Mat is required.
  47. * SEE: cv::ximgproc::createSuperpixelSLIC
  48. */
  49. public void setCostMap(Mat _costMap)
  50. {
  51. ThrowIfDisposed();
  52. if (_costMap != null) _costMap.ThrowIfDisposed();
  53. ximgproc_EdgeAwareInterpolator_setCostMap_10(nativeObj, _costMap.nativeObj);
  54. }
  55. //
  56. // C++: void cv::ximgproc::EdgeAwareInterpolator::setK(int _k)
  57. //
  58. /**
  59. * K is a number of nearest-neighbor matches considered, when fitting a locally affine
  60. * model. Usually it should be around 128. However, lower values would make the interpolation
  61. * noticeably faster.
  62. * param _k automatically generated
  63. */
  64. public void setK(int _k)
  65. {
  66. ThrowIfDisposed();
  67. ximgproc_EdgeAwareInterpolator_setK_10(nativeObj, _k);
  68. }
  69. //
  70. // C++: int cv::ximgproc::EdgeAwareInterpolator::getK()
  71. //
  72. /**
  73. * SEE: setK
  74. * return automatically generated
  75. */
  76. public int getK()
  77. {
  78. ThrowIfDisposed();
  79. return ximgproc_EdgeAwareInterpolator_getK_10(nativeObj);
  80. }
  81. //
  82. // C++: void cv::ximgproc::EdgeAwareInterpolator::setSigma(float _sigma)
  83. //
  84. /**
  85. * Sigma is a parameter defining how fast the weights decrease in the locally-weighted affine
  86. * fitting. Higher values can help preserve fine details, lower values can help to get rid of noise in the
  87. * output flow.
  88. * param _sigma automatically generated
  89. */
  90. public void setSigma(float _sigma)
  91. {
  92. ThrowIfDisposed();
  93. ximgproc_EdgeAwareInterpolator_setSigma_10(nativeObj, _sigma);
  94. }
  95. //
  96. // C++: float cv::ximgproc::EdgeAwareInterpolator::getSigma()
  97. //
  98. /**
  99. * SEE: setSigma
  100. * return automatically generated
  101. */
  102. public float getSigma()
  103. {
  104. ThrowIfDisposed();
  105. return ximgproc_EdgeAwareInterpolator_getSigma_10(nativeObj);
  106. }
  107. //
  108. // C++: void cv::ximgproc::EdgeAwareInterpolator::setLambda(float _lambda)
  109. //
  110. /**
  111. * Lambda is a parameter defining the weight of the edge-aware term in geodesic distance,
  112. * should be in the range of 0 to 1000.
  113. * param _lambda automatically generated
  114. */
  115. public void setLambda(float _lambda)
  116. {
  117. ThrowIfDisposed();
  118. ximgproc_EdgeAwareInterpolator_setLambda_10(nativeObj, _lambda);
  119. }
  120. //
  121. // C++: float cv::ximgproc::EdgeAwareInterpolator::getLambda()
  122. //
  123. /**
  124. * SEE: setLambda
  125. * return automatically generated
  126. */
  127. public float getLambda()
  128. {
  129. ThrowIfDisposed();
  130. return ximgproc_EdgeAwareInterpolator_getLambda_10(nativeObj);
  131. }
  132. //
  133. // C++: void cv::ximgproc::EdgeAwareInterpolator::setUsePostProcessing(bool _use_post_proc)
  134. //
  135. /**
  136. * Sets whether the fastGlobalSmootherFilter() post-processing is employed. It is turned on by
  137. * default.
  138. * param _use_post_proc automatically generated
  139. */
  140. public void setUsePostProcessing(bool _use_post_proc)
  141. {
  142. ThrowIfDisposed();
  143. ximgproc_EdgeAwareInterpolator_setUsePostProcessing_10(nativeObj, _use_post_proc);
  144. }
  145. //
  146. // C++: bool cv::ximgproc::EdgeAwareInterpolator::getUsePostProcessing()
  147. //
  148. /**
  149. * SEE: setUsePostProcessing
  150. * return automatically generated
  151. */
  152. public bool getUsePostProcessing()
  153. {
  154. ThrowIfDisposed();
  155. return ximgproc_EdgeAwareInterpolator_getUsePostProcessing_10(nativeObj);
  156. }
  157. //
  158. // C++: void cv::ximgproc::EdgeAwareInterpolator::setFGSLambda(float _lambda)
  159. //
  160. /**
  161. * Sets the respective fastGlobalSmootherFilter() parameter.
  162. * param _lambda automatically generated
  163. */
  164. public void setFGSLambda(float _lambda)
  165. {
  166. ThrowIfDisposed();
  167. ximgproc_EdgeAwareInterpolator_setFGSLambda_10(nativeObj, _lambda);
  168. }
  169. //
  170. // C++: float cv::ximgproc::EdgeAwareInterpolator::getFGSLambda()
  171. //
  172. /**
  173. * SEE: setFGSLambda
  174. * return automatically generated
  175. */
  176. public float getFGSLambda()
  177. {
  178. ThrowIfDisposed();
  179. return ximgproc_EdgeAwareInterpolator_getFGSLambda_10(nativeObj);
  180. }
  181. //
  182. // C++: void cv::ximgproc::EdgeAwareInterpolator::setFGSSigma(float _sigma)
  183. //
  184. /**
  185. * SEE: setFGSLambda
  186. * param _sigma automatically generated
  187. */
  188. public void setFGSSigma(float _sigma)
  189. {
  190. ThrowIfDisposed();
  191. ximgproc_EdgeAwareInterpolator_setFGSSigma_10(nativeObj, _sigma);
  192. }
  193. //
  194. // C++: float cv::ximgproc::EdgeAwareInterpolator::getFGSSigma()
  195. //
  196. /**
  197. * SEE: setFGSLambda
  198. * return automatically generated
  199. */
  200. public float getFGSSigma()
  201. {
  202. ThrowIfDisposed();
  203. return ximgproc_EdgeAwareInterpolator_getFGSSigma_10(nativeObj);
  204. }
  205. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  206. const string LIBNAME = "__Internal";
  207. #else
  208. const string LIBNAME = "opencvforunity";
  209. #endif
  210. // C++: void cv::ximgproc::EdgeAwareInterpolator::setCostMap(Mat _costMap)
  211. [DllImport(LIBNAME)]
  212. private static extern void ximgproc_EdgeAwareInterpolator_setCostMap_10(IntPtr nativeObj, IntPtr _costMap_nativeObj);
  213. // C++: void cv::ximgproc::EdgeAwareInterpolator::setK(int _k)
  214. [DllImport(LIBNAME)]
  215. private static extern void ximgproc_EdgeAwareInterpolator_setK_10(IntPtr nativeObj, int _k);
  216. // C++: int cv::ximgproc::EdgeAwareInterpolator::getK()
  217. [DllImport(LIBNAME)]
  218. private static extern int ximgproc_EdgeAwareInterpolator_getK_10(IntPtr nativeObj);
  219. // C++: void cv::ximgproc::EdgeAwareInterpolator::setSigma(float _sigma)
  220. [DllImport(LIBNAME)]
  221. private static extern void ximgproc_EdgeAwareInterpolator_setSigma_10(IntPtr nativeObj, float _sigma);
  222. // C++: float cv::ximgproc::EdgeAwareInterpolator::getSigma()
  223. [DllImport(LIBNAME)]
  224. private static extern float ximgproc_EdgeAwareInterpolator_getSigma_10(IntPtr nativeObj);
  225. // C++: void cv::ximgproc::EdgeAwareInterpolator::setLambda(float _lambda)
  226. [DllImport(LIBNAME)]
  227. private static extern void ximgproc_EdgeAwareInterpolator_setLambda_10(IntPtr nativeObj, float _lambda);
  228. // C++: float cv::ximgproc::EdgeAwareInterpolator::getLambda()
  229. [DllImport(LIBNAME)]
  230. private static extern float ximgproc_EdgeAwareInterpolator_getLambda_10(IntPtr nativeObj);
  231. // C++: void cv::ximgproc::EdgeAwareInterpolator::setUsePostProcessing(bool _use_post_proc)
  232. [DllImport(LIBNAME)]
  233. private static extern void ximgproc_EdgeAwareInterpolator_setUsePostProcessing_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool _use_post_proc);
  234. // C++: bool cv::ximgproc::EdgeAwareInterpolator::getUsePostProcessing()
  235. [DllImport(LIBNAME)]
  236. [return: MarshalAs(UnmanagedType.U1)]
  237. private static extern bool ximgproc_EdgeAwareInterpolator_getUsePostProcessing_10(IntPtr nativeObj);
  238. // C++: void cv::ximgproc::EdgeAwareInterpolator::setFGSLambda(float _lambda)
  239. [DllImport(LIBNAME)]
  240. private static extern void ximgproc_EdgeAwareInterpolator_setFGSLambda_10(IntPtr nativeObj, float _lambda);
  241. // C++: float cv::ximgproc::EdgeAwareInterpolator::getFGSLambda()
  242. [DllImport(LIBNAME)]
  243. private static extern float ximgproc_EdgeAwareInterpolator_getFGSLambda_10(IntPtr nativeObj);
  244. // C++: void cv::ximgproc::EdgeAwareInterpolator::setFGSSigma(float _sigma)
  245. [DllImport(LIBNAME)]
  246. private static extern void ximgproc_EdgeAwareInterpolator_setFGSSigma_10(IntPtr nativeObj, float _sigma);
  247. // C++: float cv::ximgproc::EdgeAwareInterpolator::getFGSSigma()
  248. [DllImport(LIBNAME)]
  249. private static extern float ximgproc_EdgeAwareInterpolator_getFGSSigma_10(IntPtr nativeObj);
  250. // native support for java finalize()
  251. [DllImport(LIBNAME)]
  252. private static extern void ximgproc_EdgeAwareInterpolator_delete(IntPtr nativeObj);
  253. }
  254. }