StereoMatcher.cs 11 KB

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