MSDDetector.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.Features2dModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.Xfeatures2dModule
  8. {
  9. // C++: class MSDDetector
  10. /**
  11. * Class implementing the MSD (*Maximal Self-Dissimilarity*) keypoint detector, described in CITE: Tombari14.
  12. *
  13. * The algorithm implements a novel interest point detector stemming from the intuition that image patches
  14. * which are highly dissimilar over a relatively large extent of their surroundings hold the property of
  15. * being repeatable and distinctive. This concept of "contextual self-dissimilarity" reverses the key
  16. * paradigm of recent successful techniques such as the Local Self-Similarity descriptor and the Non-Local
  17. * Means filter, which build upon the presence of similar - rather than dissimilar - patches. Moreover,
  18. * it extends to contextual information the local self-dissimilarity notion embedded in established
  19. * detectors of corner-like interest points, thereby achieving enhanced repeatability, distinctiveness and
  20. * localization accuracy.
  21. */
  22. public class MSDDetector : Feature2D
  23. {
  24. protected override void Dispose(bool disposing)
  25. {
  26. try
  27. {
  28. if (disposing)
  29. {
  30. }
  31. if (IsEnabledDispose)
  32. {
  33. if (nativeObj != IntPtr.Zero)
  34. xfeatures2d_MSDDetector_delete(nativeObj);
  35. nativeObj = IntPtr.Zero;
  36. }
  37. }
  38. finally
  39. {
  40. base.Dispose(disposing);
  41. }
  42. }
  43. protected internal MSDDetector(IntPtr addr) : base(addr) { }
  44. // internal usage only
  45. public static new MSDDetector __fromPtr__(IntPtr addr) { return new MSDDetector(addr); }
  46. //
  47. // C++: static Ptr_MSDDetector cv::xfeatures2d::MSDDetector::create(int m_patch_radius = 3, int m_search_area_radius = 5, int m_nms_radius = 5, int m_nms_scale_radius = 0, float m_th_saliency = 250.0f, int m_kNN = 4, float m_scale_factor = 1.25f, int m_n_scales = -1, bool m_compute_orientation = false)
  48. //
  49. public static MSDDetector create(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN, float m_scale_factor, int m_n_scales, bool m_compute_orientation)
  50. {
  51. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_10(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius, m_th_saliency, m_kNN, m_scale_factor, m_n_scales, m_compute_orientation)));
  52. }
  53. public static MSDDetector create(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN, float m_scale_factor, int m_n_scales)
  54. {
  55. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_11(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius, m_th_saliency, m_kNN, m_scale_factor, m_n_scales)));
  56. }
  57. public static MSDDetector create(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN, float m_scale_factor)
  58. {
  59. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_12(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius, m_th_saliency, m_kNN, m_scale_factor)));
  60. }
  61. public static MSDDetector create(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN)
  62. {
  63. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_13(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius, m_th_saliency, m_kNN)));
  64. }
  65. public static MSDDetector create(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency)
  66. {
  67. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_14(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius, m_th_saliency)));
  68. }
  69. public static MSDDetector create(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius)
  70. {
  71. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_15(m_patch_radius, m_search_area_radius, m_nms_radius, m_nms_scale_radius)));
  72. }
  73. public static MSDDetector create(int m_patch_radius, int m_search_area_radius, int m_nms_radius)
  74. {
  75. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_16(m_patch_radius, m_search_area_radius, m_nms_radius)));
  76. }
  77. public static MSDDetector create(int m_patch_radius, int m_search_area_radius)
  78. {
  79. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_17(m_patch_radius, m_search_area_radius)));
  80. }
  81. public static MSDDetector create(int m_patch_radius)
  82. {
  83. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_18(m_patch_radius)));
  84. }
  85. public static MSDDetector create()
  86. {
  87. return MSDDetector.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_create_19()));
  88. }
  89. //
  90. // C++: void cv::xfeatures2d::MSDDetector::setPatchRadius(int patch_radius)
  91. //
  92. public void setPatchRadius(int patch_radius)
  93. {
  94. ThrowIfDisposed();
  95. xfeatures2d_MSDDetector_setPatchRadius_10(nativeObj, patch_radius);
  96. }
  97. //
  98. // C++: int cv::xfeatures2d::MSDDetector::getPatchRadius()
  99. //
  100. public int getPatchRadius()
  101. {
  102. ThrowIfDisposed();
  103. return xfeatures2d_MSDDetector_getPatchRadius_10(nativeObj);
  104. }
  105. //
  106. // C++: void cv::xfeatures2d::MSDDetector::setSearchAreaRadius(int use_orientation)
  107. //
  108. public void setSearchAreaRadius(int use_orientation)
  109. {
  110. ThrowIfDisposed();
  111. xfeatures2d_MSDDetector_setSearchAreaRadius_10(nativeObj, use_orientation);
  112. }
  113. //
  114. // C++: int cv::xfeatures2d::MSDDetector::getSearchAreaRadius()
  115. //
  116. public int getSearchAreaRadius()
  117. {
  118. ThrowIfDisposed();
  119. return xfeatures2d_MSDDetector_getSearchAreaRadius_10(nativeObj);
  120. }
  121. //
  122. // C++: void cv::xfeatures2d::MSDDetector::setNmsRadius(int nms_radius)
  123. //
  124. public void setNmsRadius(int nms_radius)
  125. {
  126. ThrowIfDisposed();
  127. xfeatures2d_MSDDetector_setNmsRadius_10(nativeObj, nms_radius);
  128. }
  129. //
  130. // C++: int cv::xfeatures2d::MSDDetector::getNmsRadius()
  131. //
  132. public int getNmsRadius()
  133. {
  134. ThrowIfDisposed();
  135. return xfeatures2d_MSDDetector_getNmsRadius_10(nativeObj);
  136. }
  137. //
  138. // C++: void cv::xfeatures2d::MSDDetector::setNmsScaleRadius(int nms_scale_radius)
  139. //
  140. public void setNmsScaleRadius(int nms_scale_radius)
  141. {
  142. ThrowIfDisposed();
  143. xfeatures2d_MSDDetector_setNmsScaleRadius_10(nativeObj, nms_scale_radius);
  144. }
  145. //
  146. // C++: int cv::xfeatures2d::MSDDetector::getNmsScaleRadius()
  147. //
  148. public int getNmsScaleRadius()
  149. {
  150. ThrowIfDisposed();
  151. return xfeatures2d_MSDDetector_getNmsScaleRadius_10(nativeObj);
  152. }
  153. //
  154. // C++: void cv::xfeatures2d::MSDDetector::setThSaliency(float th_saliency)
  155. //
  156. public void setThSaliency(float th_saliency)
  157. {
  158. ThrowIfDisposed();
  159. xfeatures2d_MSDDetector_setThSaliency_10(nativeObj, th_saliency);
  160. }
  161. //
  162. // C++: float cv::xfeatures2d::MSDDetector::getThSaliency()
  163. //
  164. public float getThSaliency()
  165. {
  166. ThrowIfDisposed();
  167. return xfeatures2d_MSDDetector_getThSaliency_10(nativeObj);
  168. }
  169. //
  170. // C++: void cv::xfeatures2d::MSDDetector::setKNN(int kNN)
  171. //
  172. public void setKNN(int kNN)
  173. {
  174. ThrowIfDisposed();
  175. xfeatures2d_MSDDetector_setKNN_10(nativeObj, kNN);
  176. }
  177. //
  178. // C++: int cv::xfeatures2d::MSDDetector::getKNN()
  179. //
  180. public int getKNN()
  181. {
  182. ThrowIfDisposed();
  183. return xfeatures2d_MSDDetector_getKNN_10(nativeObj);
  184. }
  185. //
  186. // C++: void cv::xfeatures2d::MSDDetector::setScaleFactor(float scale_factor)
  187. //
  188. public void setScaleFactor(float scale_factor)
  189. {
  190. ThrowIfDisposed();
  191. xfeatures2d_MSDDetector_setScaleFactor_10(nativeObj, scale_factor);
  192. }
  193. //
  194. // C++: float cv::xfeatures2d::MSDDetector::getScaleFactor()
  195. //
  196. public float getScaleFactor()
  197. {
  198. ThrowIfDisposed();
  199. return xfeatures2d_MSDDetector_getScaleFactor_10(nativeObj);
  200. }
  201. //
  202. // C++: void cv::xfeatures2d::MSDDetector::setNScales(int use_orientation)
  203. //
  204. public void setNScales(int use_orientation)
  205. {
  206. ThrowIfDisposed();
  207. xfeatures2d_MSDDetector_setNScales_10(nativeObj, use_orientation);
  208. }
  209. //
  210. // C++: int cv::xfeatures2d::MSDDetector::getNScales()
  211. //
  212. public int getNScales()
  213. {
  214. ThrowIfDisposed();
  215. return xfeatures2d_MSDDetector_getNScales_10(nativeObj);
  216. }
  217. //
  218. // C++: void cv::xfeatures2d::MSDDetector::setComputeOrientation(bool compute_orientation)
  219. //
  220. public void setComputeOrientation(bool compute_orientation)
  221. {
  222. ThrowIfDisposed();
  223. xfeatures2d_MSDDetector_setComputeOrientation_10(nativeObj, compute_orientation);
  224. }
  225. //
  226. // C++: bool cv::xfeatures2d::MSDDetector::getComputeOrientation()
  227. //
  228. public bool getComputeOrientation()
  229. {
  230. ThrowIfDisposed();
  231. return xfeatures2d_MSDDetector_getComputeOrientation_10(nativeObj);
  232. }
  233. //
  234. // C++: String cv::xfeatures2d::MSDDetector::getDefaultName()
  235. //
  236. public override string getDefaultName()
  237. {
  238. ThrowIfDisposed();
  239. string retVal = Marshal.PtrToStringAnsi(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_MSDDetector_getDefaultName_10(nativeObj)));
  240. return retVal;
  241. }
  242. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  243. const string LIBNAME = "__Internal";
  244. #else
  245. const string LIBNAME = "opencvforunity";
  246. #endif
  247. // C++: static Ptr_MSDDetector cv::xfeatures2d::MSDDetector::create(int m_patch_radius = 3, int m_search_area_radius = 5, int m_nms_radius = 5, int m_nms_scale_radius = 0, float m_th_saliency = 250.0f, int m_kNN = 4, float m_scale_factor = 1.25f, int m_n_scales = -1, bool m_compute_orientation = false)
  248. [DllImport(LIBNAME)]
  249. private static extern IntPtr xfeatures2d_MSDDetector_create_10(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN, float m_scale_factor, int m_n_scales, [MarshalAs(UnmanagedType.U1)] bool m_compute_orientation);
  250. [DllImport(LIBNAME)]
  251. private static extern IntPtr xfeatures2d_MSDDetector_create_11(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN, float m_scale_factor, int m_n_scales);
  252. [DllImport(LIBNAME)]
  253. private static extern IntPtr xfeatures2d_MSDDetector_create_12(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN, float m_scale_factor);
  254. [DllImport(LIBNAME)]
  255. private static extern IntPtr xfeatures2d_MSDDetector_create_13(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency, int m_kNN);
  256. [DllImport(LIBNAME)]
  257. private static extern IntPtr xfeatures2d_MSDDetector_create_14(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius, float m_th_saliency);
  258. [DllImport(LIBNAME)]
  259. private static extern IntPtr xfeatures2d_MSDDetector_create_15(int m_patch_radius, int m_search_area_radius, int m_nms_radius, int m_nms_scale_radius);
  260. [DllImport(LIBNAME)]
  261. private static extern IntPtr xfeatures2d_MSDDetector_create_16(int m_patch_radius, int m_search_area_radius, int m_nms_radius);
  262. [DllImport(LIBNAME)]
  263. private static extern IntPtr xfeatures2d_MSDDetector_create_17(int m_patch_radius, int m_search_area_radius);
  264. [DllImport(LIBNAME)]
  265. private static extern IntPtr xfeatures2d_MSDDetector_create_18(int m_patch_radius);
  266. [DllImport(LIBNAME)]
  267. private static extern IntPtr xfeatures2d_MSDDetector_create_19();
  268. // C++: void cv::xfeatures2d::MSDDetector::setPatchRadius(int patch_radius)
  269. [DllImport(LIBNAME)]
  270. private static extern void xfeatures2d_MSDDetector_setPatchRadius_10(IntPtr nativeObj, int patch_radius);
  271. // C++: int cv::xfeatures2d::MSDDetector::getPatchRadius()
  272. [DllImport(LIBNAME)]
  273. private static extern int xfeatures2d_MSDDetector_getPatchRadius_10(IntPtr nativeObj);
  274. // C++: void cv::xfeatures2d::MSDDetector::setSearchAreaRadius(int use_orientation)
  275. [DllImport(LIBNAME)]
  276. private static extern void xfeatures2d_MSDDetector_setSearchAreaRadius_10(IntPtr nativeObj, int use_orientation);
  277. // C++: int cv::xfeatures2d::MSDDetector::getSearchAreaRadius()
  278. [DllImport(LIBNAME)]
  279. private static extern int xfeatures2d_MSDDetector_getSearchAreaRadius_10(IntPtr nativeObj);
  280. // C++: void cv::xfeatures2d::MSDDetector::setNmsRadius(int nms_radius)
  281. [DllImport(LIBNAME)]
  282. private static extern void xfeatures2d_MSDDetector_setNmsRadius_10(IntPtr nativeObj, int nms_radius);
  283. // C++: int cv::xfeatures2d::MSDDetector::getNmsRadius()
  284. [DllImport(LIBNAME)]
  285. private static extern int xfeatures2d_MSDDetector_getNmsRadius_10(IntPtr nativeObj);
  286. // C++: void cv::xfeatures2d::MSDDetector::setNmsScaleRadius(int nms_scale_radius)
  287. [DllImport(LIBNAME)]
  288. private static extern void xfeatures2d_MSDDetector_setNmsScaleRadius_10(IntPtr nativeObj, int nms_scale_radius);
  289. // C++: int cv::xfeatures2d::MSDDetector::getNmsScaleRadius()
  290. [DllImport(LIBNAME)]
  291. private static extern int xfeatures2d_MSDDetector_getNmsScaleRadius_10(IntPtr nativeObj);
  292. // C++: void cv::xfeatures2d::MSDDetector::setThSaliency(float th_saliency)
  293. [DllImport(LIBNAME)]
  294. private static extern void xfeatures2d_MSDDetector_setThSaliency_10(IntPtr nativeObj, float th_saliency);
  295. // C++: float cv::xfeatures2d::MSDDetector::getThSaliency()
  296. [DllImport(LIBNAME)]
  297. private static extern float xfeatures2d_MSDDetector_getThSaliency_10(IntPtr nativeObj);
  298. // C++: void cv::xfeatures2d::MSDDetector::setKNN(int kNN)
  299. [DllImport(LIBNAME)]
  300. private static extern void xfeatures2d_MSDDetector_setKNN_10(IntPtr nativeObj, int kNN);
  301. // C++: int cv::xfeatures2d::MSDDetector::getKNN()
  302. [DllImport(LIBNAME)]
  303. private static extern int xfeatures2d_MSDDetector_getKNN_10(IntPtr nativeObj);
  304. // C++: void cv::xfeatures2d::MSDDetector::setScaleFactor(float scale_factor)
  305. [DllImport(LIBNAME)]
  306. private static extern void xfeatures2d_MSDDetector_setScaleFactor_10(IntPtr nativeObj, float scale_factor);
  307. // C++: float cv::xfeatures2d::MSDDetector::getScaleFactor()
  308. [DllImport(LIBNAME)]
  309. private static extern float xfeatures2d_MSDDetector_getScaleFactor_10(IntPtr nativeObj);
  310. // C++: void cv::xfeatures2d::MSDDetector::setNScales(int use_orientation)
  311. [DllImport(LIBNAME)]
  312. private static extern void xfeatures2d_MSDDetector_setNScales_10(IntPtr nativeObj, int use_orientation);
  313. // C++: int cv::xfeatures2d::MSDDetector::getNScales()
  314. [DllImport(LIBNAME)]
  315. private static extern int xfeatures2d_MSDDetector_getNScales_10(IntPtr nativeObj);
  316. // C++: void cv::xfeatures2d::MSDDetector::setComputeOrientation(bool compute_orientation)
  317. [DllImport(LIBNAME)]
  318. private static extern void xfeatures2d_MSDDetector_setComputeOrientation_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool compute_orientation);
  319. // C++: bool cv::xfeatures2d::MSDDetector::getComputeOrientation()
  320. [DllImport(LIBNAME)]
  321. [return: MarshalAs(UnmanagedType.U1)]
  322. private static extern bool xfeatures2d_MSDDetector_getComputeOrientation_10(IntPtr nativeObj);
  323. // C++: String cv::xfeatures2d::MSDDetector::getDefaultName()
  324. [DllImport(LIBNAME)]
  325. private static extern IntPtr xfeatures2d_MSDDetector_getDefaultName_10(IntPtr nativeObj);
  326. // native support for java finalize()
  327. [DllImport(LIBNAME)]
  328. private static extern void xfeatures2d_MSDDetector_delete(IntPtr nativeObj);
  329. }
  330. }