StereoMatcher.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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.Calib3dModule {
  8. // C++: class StereoMatcher
  9. //javadoc: StereoMatcher
  10. public class StereoMatcher : 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. calib3d_StereoMatcher_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal StereoMatcher(IntPtr addr) : base(addr) { }
  29. // internal usage only
  30. public static new StereoMatcher __fromPtr__(IntPtr addr) { return new StereoMatcher(addr); }
  31. // C++: enum <unnamed>
  32. public const int DISP_SHIFT = 4;
  33. public const int DISP_SCALE = (1 << DISP_SHIFT);
  34. //
  35. // C++: int cv::StereoMatcher::getBlockSize()
  36. //
  37. //javadoc: StereoMatcher::getBlockSize()
  38. public int getBlockSize() {
  39. ThrowIfDisposed();
  40. #if (UNITY_ANDROID && !UNITY_EDITOR)
  41. int retVal = calib3d_StereoMatcher_getBlockSize_10(nativeObj);
  42. return retVal;
  43. #else
  44. return -1;
  45. #endif
  46. }
  47. //
  48. // C++: int cv::StereoMatcher::getDisp12MaxDiff()
  49. //
  50. //javadoc: StereoMatcher::getDisp12MaxDiff()
  51. public int getDisp12MaxDiff() {
  52. ThrowIfDisposed();
  53. #if (UNITY_ANDROID && !UNITY_EDITOR)
  54. int retVal = calib3d_StereoMatcher_getDisp12MaxDiff_10(nativeObj);
  55. return retVal;
  56. #else
  57. return -1;
  58. #endif
  59. }
  60. //
  61. // C++: int cv::StereoMatcher::getMinDisparity()
  62. //
  63. //javadoc: StereoMatcher::getMinDisparity()
  64. public int getMinDisparity() {
  65. ThrowIfDisposed();
  66. #if (UNITY_ANDROID && !UNITY_EDITOR)
  67. int retVal = calib3d_StereoMatcher_getMinDisparity_10(nativeObj);
  68. return retVal;
  69. #else
  70. return -1;
  71. #endif
  72. }
  73. //
  74. // C++: int cv::StereoMatcher::getNumDisparities()
  75. //
  76. //javadoc: StereoMatcher::getNumDisparities()
  77. public int getNumDisparities() {
  78. ThrowIfDisposed();
  79. #if (UNITY_ANDROID && !UNITY_EDITOR)
  80. int retVal = calib3d_StereoMatcher_getNumDisparities_10(nativeObj);
  81. return retVal;
  82. #else
  83. return -1;
  84. #endif
  85. }
  86. //
  87. // C++: int cv::StereoMatcher::getSpeckleRange()
  88. //
  89. //javadoc: StereoMatcher::getSpeckleRange()
  90. public int getSpeckleRange() {
  91. ThrowIfDisposed();
  92. #if (UNITY_ANDROID && !UNITY_EDITOR)
  93. int retVal = calib3d_StereoMatcher_getSpeckleRange_10(nativeObj);
  94. return retVal;
  95. #else
  96. return -1;
  97. #endif
  98. }
  99. //
  100. // C++: int cv::StereoMatcher::getSpeckleWindowSize()
  101. //
  102. //javadoc: StereoMatcher::getSpeckleWindowSize()
  103. public int getSpeckleWindowSize() {
  104. ThrowIfDisposed();
  105. #if (UNITY_ANDROID && !UNITY_EDITOR)
  106. int retVal = calib3d_StereoMatcher_getSpeckleWindowSize_10(nativeObj);
  107. return retVal;
  108. #else
  109. return -1;
  110. #endif
  111. }
  112. //
  113. // C++: void cv::StereoMatcher::compute(Mat left, Mat right, Mat& disparity)
  114. //
  115. //javadoc: StereoMatcher::compute(left, right, disparity)
  116. public void compute(Mat left, Mat right, Mat disparity) {
  117. ThrowIfDisposed();
  118. if (left != null) left.ThrowIfDisposed();
  119. if (right != null) right.ThrowIfDisposed();
  120. if (disparity != null) disparity.ThrowIfDisposed();
  121. #if (UNITY_ANDROID && !UNITY_EDITOR)
  122. calib3d_StereoMatcher_compute_10(nativeObj, left.nativeObj, right.nativeObj, disparity.nativeObj);
  123. return;
  124. #else
  125. return;
  126. #endif
  127. }
  128. //
  129. // C++: void cv::StereoMatcher::setBlockSize(int blockSize)
  130. //
  131. //javadoc: StereoMatcher::setBlockSize(blockSize)
  132. public void setBlockSize(int blockSize) {
  133. ThrowIfDisposed();
  134. #if (UNITY_ANDROID && !UNITY_EDITOR)
  135. calib3d_StereoMatcher_setBlockSize_10(nativeObj, blockSize);
  136. return;
  137. #else
  138. return;
  139. #endif
  140. }
  141. //
  142. // C++: void cv::StereoMatcher::setDisp12MaxDiff(int disp12MaxDiff)
  143. //
  144. //javadoc: StereoMatcher::setDisp12MaxDiff(disp12MaxDiff)
  145. public void setDisp12MaxDiff(int disp12MaxDiff) {
  146. ThrowIfDisposed();
  147. #if (UNITY_ANDROID && !UNITY_EDITOR)
  148. calib3d_StereoMatcher_setDisp12MaxDiff_10(nativeObj, disp12MaxDiff);
  149. return;
  150. #else
  151. return;
  152. #endif
  153. }
  154. //
  155. // C++: void cv::StereoMatcher::setMinDisparity(int minDisparity)
  156. //
  157. //javadoc: StereoMatcher::setMinDisparity(minDisparity)
  158. public void setMinDisparity(int minDisparity) {
  159. ThrowIfDisposed();
  160. #if (UNITY_ANDROID && !UNITY_EDITOR)
  161. calib3d_StereoMatcher_setMinDisparity_10(nativeObj, minDisparity);
  162. return;
  163. #else
  164. return;
  165. #endif
  166. }
  167. //
  168. // C++: void cv::StereoMatcher::setNumDisparities(int numDisparities)
  169. //
  170. //javadoc: StereoMatcher::setNumDisparities(numDisparities)
  171. public void setNumDisparities(int numDisparities) {
  172. ThrowIfDisposed();
  173. #if (UNITY_ANDROID && !UNITY_EDITOR)
  174. calib3d_StereoMatcher_setNumDisparities_10(nativeObj, numDisparities);
  175. return;
  176. #else
  177. return;
  178. #endif
  179. }
  180. //
  181. // C++: void cv::StereoMatcher::setSpeckleRange(int speckleRange)
  182. //
  183. //javadoc: StereoMatcher::setSpeckleRange(speckleRange)
  184. public void setSpeckleRange(int speckleRange) {
  185. ThrowIfDisposed();
  186. #if (UNITY_ANDROID && !UNITY_EDITOR)
  187. calib3d_StereoMatcher_setSpeckleRange_10(nativeObj, speckleRange);
  188. return;
  189. #else
  190. return;
  191. #endif
  192. }
  193. //
  194. // C++: void cv::StereoMatcher::setSpeckleWindowSize(int speckleWindowSize)
  195. //
  196. //javadoc: StereoMatcher::setSpeckleWindowSize(speckleWindowSize)
  197. public void setSpeckleWindowSize(int speckleWindowSize) {
  198. ThrowIfDisposed();
  199. #if (UNITY_ANDROID && !UNITY_EDITOR)
  200. calib3d_StereoMatcher_setSpeckleWindowSize_10(nativeObj, speckleWindowSize);
  201. return;
  202. #else
  203. return;
  204. #endif
  205. }
  206. #if (UNITY_ANDROID && !UNITY_EDITOR)
  207. const string LIBNAME = "opencvforunity";
  208. // C++: int cv::StereoMatcher::getBlockSize()
  209. [DllImport(LIBNAME)]
  210. private static extern int calib3d_StereoMatcher_getBlockSize_10(IntPtr nativeObj);
  211. // C++: int cv::StereoMatcher::getDisp12MaxDiff()
  212. [DllImport(LIBNAME)]
  213. private static extern int calib3d_StereoMatcher_getDisp12MaxDiff_10(IntPtr nativeObj);
  214. // C++: int cv::StereoMatcher::getMinDisparity()
  215. [DllImport(LIBNAME)]
  216. private static extern int calib3d_StereoMatcher_getMinDisparity_10(IntPtr nativeObj);
  217. // C++: int cv::StereoMatcher::getNumDisparities()
  218. [DllImport(LIBNAME)]
  219. private static extern int calib3d_StereoMatcher_getNumDisparities_10(IntPtr nativeObj);
  220. // C++: int cv::StereoMatcher::getSpeckleRange()
  221. [DllImport(LIBNAME)]
  222. private static extern int calib3d_StereoMatcher_getSpeckleRange_10(IntPtr nativeObj);
  223. // C++: int cv::StereoMatcher::getSpeckleWindowSize()
  224. [DllImport(LIBNAME)]
  225. private static extern int calib3d_StereoMatcher_getSpeckleWindowSize_10(IntPtr nativeObj);
  226. // C++: void cv::StereoMatcher::compute(Mat left, Mat right, Mat& disparity)
  227. [DllImport(LIBNAME)]
  228. private static extern void calib3d_StereoMatcher_compute_10(IntPtr nativeObj, IntPtr left_nativeObj, IntPtr right_nativeObj, IntPtr disparity_nativeObj);
  229. // C++: void cv::StereoMatcher::setBlockSize(int blockSize)
  230. [DllImport(LIBNAME)]
  231. private static extern void calib3d_StereoMatcher_setBlockSize_10(IntPtr nativeObj, int blockSize);
  232. // C++: void cv::StereoMatcher::setDisp12MaxDiff(int disp12MaxDiff)
  233. [DllImport(LIBNAME)]
  234. private static extern void calib3d_StereoMatcher_setDisp12MaxDiff_10(IntPtr nativeObj, int disp12MaxDiff);
  235. // C++: void cv::StereoMatcher::setMinDisparity(int minDisparity)
  236. [DllImport(LIBNAME)]
  237. private static extern void calib3d_StereoMatcher_setMinDisparity_10(IntPtr nativeObj, int minDisparity);
  238. // C++: void cv::StereoMatcher::setNumDisparities(int numDisparities)
  239. [DllImport(LIBNAME)]
  240. private static extern void calib3d_StereoMatcher_setNumDisparities_10(IntPtr nativeObj, int numDisparities);
  241. // C++: void cv::StereoMatcher::setSpeckleRange(int speckleRange)
  242. [DllImport(LIBNAME)]
  243. private static extern void calib3d_StereoMatcher_setSpeckleRange_10(IntPtr nativeObj, int speckleRange);
  244. // C++: void cv::StereoMatcher::setSpeckleWindowSize(int speckleWindowSize)
  245. [DllImport(LIBNAME)]
  246. private static extern void calib3d_StereoMatcher_setSpeckleWindowSize_10(IntPtr nativeObj, int speckleWindowSize);
  247. // native support for java finalize()
  248. [DllImport(LIBNAME)]
  249. private static extern void calib3d_StereoMatcher_delete(IntPtr nativeObj);
  250. #endif
  251. }
  252. }