StereoBM.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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 StereoBM
  9. //javadoc: StereoBM
  10. public class StereoBM : StereoMatcher {
  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_StereoBM_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal StereoBM(IntPtr addr) : base(addr) { }
  29. // internal usage only
  30. public static new StereoBM __fromPtr__(IntPtr addr) { return new StereoBM(addr); }
  31. // C++: enum <unnamed>
  32. public const int PREFILTER_NORMALIZED_RESPONSE = 0;
  33. public const int PREFILTER_XSOBEL = 1;
  34. //
  35. // C++: static Ptr_StereoBM cv::StereoBM::create(int numDisparities = 0, int blockSize = 21)
  36. //
  37. //javadoc: StereoBM::create(numDisparities, blockSize)
  38. public static StereoBM create(int numDisparities, int blockSize) {
  39. #if (UNITY_ANDROID && !UNITY_EDITOR)
  40. StereoBM retVal = StereoBM.__fromPtr__(calib3d_StereoBM_create_10(numDisparities, blockSize));
  41. return retVal;
  42. #else
  43. return null;
  44. #endif
  45. }
  46. //javadoc: StereoBM::create(numDisparities)
  47. public static StereoBM create(int numDisparities) {
  48. #if (UNITY_ANDROID && !UNITY_EDITOR)
  49. StereoBM retVal = StereoBM.__fromPtr__(calib3d_StereoBM_create_11(numDisparities));
  50. return retVal;
  51. #else
  52. return null;
  53. #endif
  54. }
  55. //javadoc: StereoBM::create()
  56. public static StereoBM create() {
  57. #if (UNITY_ANDROID && !UNITY_EDITOR)
  58. StereoBM retVal = StereoBM.__fromPtr__(calib3d_StereoBM_create_12());
  59. return retVal;
  60. #else
  61. return null;
  62. #endif
  63. }
  64. //
  65. // C++: Rect cv::StereoBM::getROI1()
  66. //
  67. //javadoc: StereoBM::getROI1()
  68. public Rect getROI1() {
  69. ThrowIfDisposed();
  70. #if (UNITY_ANDROID && !UNITY_EDITOR)
  71. double[] tmpArray = new double[4];
  72. calib3d_StereoBM_getROI1_10(nativeObj, tmpArray);
  73. Rect retVal = new Rect(tmpArray);
  74. return retVal;
  75. #else
  76. return null;
  77. #endif
  78. }
  79. //
  80. // C++: Rect cv::StereoBM::getROI2()
  81. //
  82. //javadoc: StereoBM::getROI2()
  83. public Rect getROI2() {
  84. ThrowIfDisposed();
  85. #if (UNITY_ANDROID && !UNITY_EDITOR)
  86. double[] tmpArray = new double[4];
  87. calib3d_StereoBM_getROI2_10(nativeObj, tmpArray);
  88. Rect retVal = new Rect(tmpArray);
  89. return retVal;
  90. #else
  91. return null;
  92. #endif
  93. }
  94. //
  95. // C++: int cv::StereoBM::getPreFilterCap()
  96. //
  97. //javadoc: StereoBM::getPreFilterCap()
  98. public int getPreFilterCap() {
  99. ThrowIfDisposed();
  100. #if (UNITY_ANDROID && !UNITY_EDITOR)
  101. int retVal = calib3d_StereoBM_getPreFilterCap_10(nativeObj);
  102. return retVal;
  103. #else
  104. return -1;
  105. #endif
  106. }
  107. //
  108. // C++: int cv::StereoBM::getPreFilterSize()
  109. //
  110. //javadoc: StereoBM::getPreFilterSize()
  111. public int getPreFilterSize() {
  112. ThrowIfDisposed();
  113. #if (UNITY_ANDROID && !UNITY_EDITOR)
  114. int retVal = calib3d_StereoBM_getPreFilterSize_10(nativeObj);
  115. return retVal;
  116. #else
  117. return -1;
  118. #endif
  119. }
  120. //
  121. // C++: int cv::StereoBM::getPreFilterType()
  122. //
  123. //javadoc: StereoBM::getPreFilterType()
  124. public int getPreFilterType() {
  125. ThrowIfDisposed();
  126. #if (UNITY_ANDROID && !UNITY_EDITOR)
  127. int retVal = calib3d_StereoBM_getPreFilterType_10(nativeObj);
  128. return retVal;
  129. #else
  130. return -1;
  131. #endif
  132. }
  133. //
  134. // C++: int cv::StereoBM::getSmallerBlockSize()
  135. //
  136. //javadoc: StereoBM::getSmallerBlockSize()
  137. public int getSmallerBlockSize() {
  138. ThrowIfDisposed();
  139. #if (UNITY_ANDROID && !UNITY_EDITOR)
  140. int retVal = calib3d_StereoBM_getSmallerBlockSize_10(nativeObj);
  141. return retVal;
  142. #else
  143. return -1;
  144. #endif
  145. }
  146. //
  147. // C++: int cv::StereoBM::getTextureThreshold()
  148. //
  149. //javadoc: StereoBM::getTextureThreshold()
  150. public int getTextureThreshold() {
  151. ThrowIfDisposed();
  152. #if (UNITY_ANDROID && !UNITY_EDITOR)
  153. int retVal = calib3d_StereoBM_getTextureThreshold_10(nativeObj);
  154. return retVal;
  155. #else
  156. return -1;
  157. #endif
  158. }
  159. //
  160. // C++: int cv::StereoBM::getUniquenessRatio()
  161. //
  162. //javadoc: StereoBM::getUniquenessRatio()
  163. public int getUniquenessRatio() {
  164. ThrowIfDisposed();
  165. #if (UNITY_ANDROID && !UNITY_EDITOR)
  166. int retVal = calib3d_StereoBM_getUniquenessRatio_10(nativeObj);
  167. return retVal;
  168. #else
  169. return -1;
  170. #endif
  171. }
  172. //
  173. // C++: void cv::StereoBM::setPreFilterCap(int preFilterCap)
  174. //
  175. //javadoc: StereoBM::setPreFilterCap(preFilterCap)
  176. public void setPreFilterCap(int preFilterCap) {
  177. ThrowIfDisposed();
  178. #if (UNITY_ANDROID && !UNITY_EDITOR)
  179. calib3d_StereoBM_setPreFilterCap_10(nativeObj, preFilterCap);
  180. return;
  181. #else
  182. return;
  183. #endif
  184. }
  185. //
  186. // C++: void cv::StereoBM::setPreFilterSize(int preFilterSize)
  187. //
  188. //javadoc: StereoBM::setPreFilterSize(preFilterSize)
  189. public void setPreFilterSize(int preFilterSize) {
  190. ThrowIfDisposed();
  191. #if (UNITY_ANDROID && !UNITY_EDITOR)
  192. calib3d_StereoBM_setPreFilterSize_10(nativeObj, preFilterSize);
  193. return;
  194. #else
  195. return;
  196. #endif
  197. }
  198. //
  199. // C++: void cv::StereoBM::setPreFilterType(int preFilterType)
  200. //
  201. //javadoc: StereoBM::setPreFilterType(preFilterType)
  202. public void setPreFilterType(int preFilterType) {
  203. ThrowIfDisposed();
  204. #if (UNITY_ANDROID && !UNITY_EDITOR)
  205. calib3d_StereoBM_setPreFilterType_10(nativeObj, preFilterType);
  206. return;
  207. #else
  208. return;
  209. #endif
  210. }
  211. //
  212. // C++: void cv::StereoBM::setROI1(Rect roi1)
  213. //
  214. //javadoc: StereoBM::setROI1(roi1)
  215. public void setROI1(Rect roi1) {
  216. ThrowIfDisposed();
  217. #if (UNITY_ANDROID && !UNITY_EDITOR)
  218. calib3d_StereoBM_setROI1_10(nativeObj, roi1.x, roi1.y, roi1.width, roi1.height);
  219. return;
  220. #else
  221. return;
  222. #endif
  223. }
  224. //
  225. // C++: void cv::StereoBM::setROI2(Rect roi2)
  226. //
  227. //javadoc: StereoBM::setROI2(roi2)
  228. public void setROI2(Rect roi2) {
  229. ThrowIfDisposed();
  230. #if (UNITY_ANDROID && !UNITY_EDITOR)
  231. calib3d_StereoBM_setROI2_10(nativeObj, roi2.x, roi2.y, roi2.width, roi2.height);
  232. return;
  233. #else
  234. return;
  235. #endif
  236. }
  237. //
  238. // C++: void cv::StereoBM::setSmallerBlockSize(int blockSize)
  239. //
  240. //javadoc: StereoBM::setSmallerBlockSize(blockSize)
  241. public void setSmallerBlockSize(int blockSize) {
  242. ThrowIfDisposed();
  243. #if (UNITY_ANDROID && !UNITY_EDITOR)
  244. calib3d_StereoBM_setSmallerBlockSize_10(nativeObj, blockSize);
  245. return;
  246. #else
  247. return;
  248. #endif
  249. }
  250. //
  251. // C++: void cv::StereoBM::setTextureThreshold(int textureThreshold)
  252. //
  253. //javadoc: StereoBM::setTextureThreshold(textureThreshold)
  254. public void setTextureThreshold(int textureThreshold) {
  255. ThrowIfDisposed();
  256. #if (UNITY_ANDROID && !UNITY_EDITOR)
  257. calib3d_StereoBM_setTextureThreshold_10(nativeObj, textureThreshold);
  258. return;
  259. #else
  260. return;
  261. #endif
  262. }
  263. //
  264. // C++: void cv::StereoBM::setUniquenessRatio(int uniquenessRatio)
  265. //
  266. //javadoc: StereoBM::setUniquenessRatio(uniquenessRatio)
  267. public void setUniquenessRatio(int uniquenessRatio) {
  268. ThrowIfDisposed();
  269. #if (UNITY_ANDROID && !UNITY_EDITOR)
  270. calib3d_StereoBM_setUniquenessRatio_10(nativeObj, uniquenessRatio);
  271. return;
  272. #else
  273. return;
  274. #endif
  275. }
  276. #if (UNITY_ANDROID && !UNITY_EDITOR)
  277. const string LIBNAME = "opencvforunity";
  278. // C++: static Ptr_StereoBM cv::StereoBM::create(int numDisparities = 0, int blockSize = 21)
  279. [DllImport(LIBNAME)]
  280. private static extern IntPtr calib3d_StereoBM_create_10(int numDisparities, int blockSize);
  281. [DllImport(LIBNAME)]
  282. private static extern IntPtr calib3d_StereoBM_create_11(int numDisparities);
  283. [DllImport(LIBNAME)]
  284. private static extern IntPtr calib3d_StereoBM_create_12();
  285. // C++: Rect cv::StereoBM::getROI1()
  286. [DllImport(LIBNAME)]
  287. private static extern void calib3d_StereoBM_getROI1_10(IntPtr nativeObj, double[] retVal);
  288. // C++: Rect cv::StereoBM::getROI2()
  289. [DllImport(LIBNAME)]
  290. private static extern void calib3d_StereoBM_getROI2_10(IntPtr nativeObj, double[] retVal);
  291. // C++: int cv::StereoBM::getPreFilterCap()
  292. [DllImport(LIBNAME)]
  293. private static extern int calib3d_StereoBM_getPreFilterCap_10(IntPtr nativeObj);
  294. // C++: int cv::StereoBM::getPreFilterSize()
  295. [DllImport(LIBNAME)]
  296. private static extern int calib3d_StereoBM_getPreFilterSize_10(IntPtr nativeObj);
  297. // C++: int cv::StereoBM::getPreFilterType()
  298. [DllImport(LIBNAME)]
  299. private static extern int calib3d_StereoBM_getPreFilterType_10(IntPtr nativeObj);
  300. // C++: int cv::StereoBM::getSmallerBlockSize()
  301. [DllImport(LIBNAME)]
  302. private static extern int calib3d_StereoBM_getSmallerBlockSize_10(IntPtr nativeObj);
  303. // C++: int cv::StereoBM::getTextureThreshold()
  304. [DllImport(LIBNAME)]
  305. private static extern int calib3d_StereoBM_getTextureThreshold_10(IntPtr nativeObj);
  306. // C++: int cv::StereoBM::getUniquenessRatio()
  307. [DllImport(LIBNAME)]
  308. private static extern int calib3d_StereoBM_getUniquenessRatio_10(IntPtr nativeObj);
  309. // C++: void cv::StereoBM::setPreFilterCap(int preFilterCap)
  310. [DllImport(LIBNAME)]
  311. private static extern void calib3d_StereoBM_setPreFilterCap_10(IntPtr nativeObj, int preFilterCap);
  312. // C++: void cv::StereoBM::setPreFilterSize(int preFilterSize)
  313. [DllImport(LIBNAME)]
  314. private static extern void calib3d_StereoBM_setPreFilterSize_10(IntPtr nativeObj, int preFilterSize);
  315. // C++: void cv::StereoBM::setPreFilterType(int preFilterType)
  316. [DllImport(LIBNAME)]
  317. private static extern void calib3d_StereoBM_setPreFilterType_10(IntPtr nativeObj, int preFilterType);
  318. // C++: void cv::StereoBM::setROI1(Rect roi1)
  319. [DllImport(LIBNAME)]
  320. private static extern void calib3d_StereoBM_setROI1_10(IntPtr nativeObj, int roi1_x, int roi1_y, int roi1_width, int roi1_height);
  321. // C++: void cv::StereoBM::setROI2(Rect roi2)
  322. [DllImport(LIBNAME)]
  323. private static extern void calib3d_StereoBM_setROI2_10(IntPtr nativeObj, int roi2_x, int roi2_y, int roi2_width, int roi2_height);
  324. // C++: void cv::StereoBM::setSmallerBlockSize(int blockSize)
  325. [DllImport(LIBNAME)]
  326. private static extern void calib3d_StereoBM_setSmallerBlockSize_10(IntPtr nativeObj, int blockSize);
  327. // C++: void cv::StereoBM::setTextureThreshold(int textureThreshold)
  328. [DllImport(LIBNAME)]
  329. private static extern void calib3d_StereoBM_setTextureThreshold_10(IntPtr nativeObj, int textureThreshold);
  330. // C++: void cv::StereoBM::setUniquenessRatio(int uniquenessRatio)
  331. [DllImport(LIBNAME)]
  332. private static extern void calib3d_StereoBM_setUniquenessRatio_10(IntPtr nativeObj, int uniquenessRatio);
  333. // native support for java finalize()
  334. [DllImport(LIBNAME)]
  335. private static extern void calib3d_StereoBM_delete(IntPtr nativeObj);
  336. #endif
  337. }
  338. }