SURF.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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 SURF
  10. // /**
  11. // * Class for extracting Speeded Up Robust Features from an image CITE: Bay06 .
  12. // *
  13. // * The algorithm parameters:
  14. // * <ul>
  15. // * <li>
  16. // * member int extended
  17. // * <ul>
  18. // * <li>
  19. // * 0 means that the basic descriptors (64 elements each) shall be computed
  20. // * </li>
  21. // * <li>
  22. // * 1 means that the extended descriptors (128 elements each) shall be computed
  23. // * </li>
  24. // * </ul>
  25. // * <li>
  26. // * member int upright
  27. // * <ul>
  28. // * <li>
  29. // * 0 means that detector computes orientation of each feature.
  30. // * </li>
  31. // * <li>
  32. // * 1 means that the orientation is not computed (which is much, much faster). For example,
  33. // * if you match images from a stereo pair, or do image stitching, the matched features
  34. // * likely have very similar angles, and you can speed up feature extraction by setting
  35. // * upright=1.
  36. // * </li>
  37. // * </ul>
  38. // * <li>
  39. // * member double hessianThreshold
  40. // * Threshold for the keypoint detector. Only features, whose hessian is larger than
  41. // * hessianThreshold are retained by the detector. Therefore, the larger the value, the less
  42. // * keypoints you will get. A good default value could be from 300 to 500, depending from the
  43. // * image contrast.
  44. // * </li>
  45. // * <li>
  46. // * member int nOctaves
  47. // * The number of a gaussian pyramid octaves that the detector uses. It is set to 4 by default.
  48. // * If you want to get very large features, use the larger value. If you want just small
  49. // * features, decrease it.
  50. // * </li>
  51. // * <li>
  52. // * member int nOctaveLayers
  53. // * The number of images within each octave of a gaussian pyramid. It is set to 2 by default.
  54. // * </li>
  55. // * </ul>
  56. // * <b>Note:</b>
  57. // * <ul>
  58. // * <li>
  59. // * An example using the SURF feature detector can be found at
  60. // * opencv_source_code/samples/cpp/generic_descriptor_match.cpp
  61. // * <ul>
  62. // * <li>
  63. // * Another example using the SURF feature detector, extractor and matcher can be found at
  64. // * opencv_source_code/samples/cpp/matcher_simple.cpp
  65. // * </li>
  66. // * </ul>
  67. // * </li>
  68. // * </ul>
  69. // */
  70. // public class SURF : Feature2D
  71. // {
  72. // protected override void Dispose(bool disposing)
  73. // {
  74. // try
  75. // {
  76. // if (disposing)
  77. // {
  78. // }
  79. // if (IsEnabledDispose)
  80. // {
  81. // if (nativeObj != IntPtr.Zero)
  82. // xfeatures2d_SURF_delete(nativeObj);
  83. // nativeObj = IntPtr.Zero;
  84. // }
  85. // }
  86. // finally
  87. // {
  88. // base.Dispose(disposing);
  89. // }
  90. // }
  91. // protected internal SURF(IntPtr addr) : base(addr) { }
  92. // // internal usage only
  93. // public static new SURF __fromPtr__(IntPtr addr) { return new SURF(addr); }
  94. // //
  95. // // C++: static Ptr_SURF cv::xfeatures2d::SURF::create(double hessianThreshold = 100, int nOctaves = 4, int nOctaveLayers = 3, bool extended = false, bool upright = false)
  96. // //
  97. // /**
  98. // * param hessianThreshold Threshold for hessian keypoint detector used in SURF.
  99. // * param nOctaves Number of pyramid octaves the keypoint detector will use.
  100. // * param nOctaveLayers Number of octave layers within each octave.
  101. // * param extended Extended descriptor flag (true - use extended 128-element descriptors; false - use
  102. // * 64-element descriptors).
  103. // * param upright Up-right or rotated features flag (true - do not compute orientation of features;
  104. // * false - compute orientation).
  105. // * return automatically generated
  106. // */
  107. // public static SURF create(double hessianThreshold, int nOctaves, int nOctaveLayers, bool extended, bool upright)
  108. // {
  109. // return SURF.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_create_10(hessianThreshold, nOctaves, nOctaveLayers, extended, upright)));
  110. // }
  111. // /**
  112. // * param hessianThreshold Threshold for hessian keypoint detector used in SURF.
  113. // * param nOctaves Number of pyramid octaves the keypoint detector will use.
  114. // * param nOctaveLayers Number of octave layers within each octave.
  115. // * param extended Extended descriptor flag (true - use extended 128-element descriptors; false - use
  116. // * 64-element descriptors).
  117. // * false - compute orientation).
  118. // * return automatically generated
  119. // */
  120. // public static SURF create(double hessianThreshold, int nOctaves, int nOctaveLayers, bool extended)
  121. // {
  122. // return SURF.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_create_11(hessianThreshold, nOctaves, nOctaveLayers, extended)));
  123. // }
  124. // /**
  125. // * param hessianThreshold Threshold for hessian keypoint detector used in SURF.
  126. // * param nOctaves Number of pyramid octaves the keypoint detector will use.
  127. // * param nOctaveLayers Number of octave layers within each octave.
  128. // * 64-element descriptors).
  129. // * false - compute orientation).
  130. // * return automatically generated
  131. // */
  132. // public static SURF create(double hessianThreshold, int nOctaves, int nOctaveLayers)
  133. // {
  134. // return SURF.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_create_12(hessianThreshold, nOctaves, nOctaveLayers)));
  135. // }
  136. // /**
  137. // * param hessianThreshold Threshold for hessian keypoint detector used in SURF.
  138. // * param nOctaves Number of pyramid octaves the keypoint detector will use.
  139. // * 64-element descriptors).
  140. // * false - compute orientation).
  141. // * return automatically generated
  142. // */
  143. // public static SURF create(double hessianThreshold, int nOctaves)
  144. // {
  145. // return SURF.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_create_13(hessianThreshold, nOctaves)));
  146. // }
  147. // /**
  148. // * param hessianThreshold Threshold for hessian keypoint detector used in SURF.
  149. // * 64-element descriptors).
  150. // * false - compute orientation).
  151. // * return automatically generated
  152. // */
  153. // public static SURF create(double hessianThreshold)
  154. // {
  155. // return SURF.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_create_14(hessianThreshold)));
  156. // }
  157. // /**
  158. // * 64-element descriptors).
  159. // * false - compute orientation).
  160. // * return automatically generated
  161. // */
  162. // public static SURF create()
  163. // {
  164. // return SURF.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_create_15()));
  165. // }
  166. // //
  167. // // C++: void cv::xfeatures2d::SURF::setHessianThreshold(double hessianThreshold)
  168. // //
  169. // public void setHessianThreshold(double hessianThreshold)
  170. // {
  171. // ThrowIfDisposed();
  172. // xfeatures2d_SURF_setHessianThreshold_10(nativeObj, hessianThreshold);
  173. // }
  174. // //
  175. // // C++: double cv::xfeatures2d::SURF::getHessianThreshold()
  176. // //
  177. // public double getHessianThreshold()
  178. // {
  179. // ThrowIfDisposed();
  180. // return xfeatures2d_SURF_getHessianThreshold_10(nativeObj);
  181. // }
  182. // //
  183. // // C++: void cv::xfeatures2d::SURF::setNOctaves(int nOctaves)
  184. // //
  185. // public void setNOctaves(int nOctaves)
  186. // {
  187. // ThrowIfDisposed();
  188. // xfeatures2d_SURF_setNOctaves_10(nativeObj, nOctaves);
  189. // }
  190. // //
  191. // // C++: int cv::xfeatures2d::SURF::getNOctaves()
  192. // //
  193. // public int getNOctaves()
  194. // {
  195. // ThrowIfDisposed();
  196. // return xfeatures2d_SURF_getNOctaves_10(nativeObj);
  197. // }
  198. // //
  199. // // C++: void cv::xfeatures2d::SURF::setNOctaveLayers(int nOctaveLayers)
  200. // //
  201. // public void setNOctaveLayers(int nOctaveLayers)
  202. // {
  203. // ThrowIfDisposed();
  204. // xfeatures2d_SURF_setNOctaveLayers_10(nativeObj, nOctaveLayers);
  205. // }
  206. // //
  207. // // C++: int cv::xfeatures2d::SURF::getNOctaveLayers()
  208. // //
  209. // public int getNOctaveLayers()
  210. // {
  211. // ThrowIfDisposed();
  212. // return xfeatures2d_SURF_getNOctaveLayers_10(nativeObj);
  213. // }
  214. // //
  215. // // C++: void cv::xfeatures2d::SURF::setExtended(bool extended)
  216. // //
  217. // public void setExtended(bool extended)
  218. // {
  219. // ThrowIfDisposed();
  220. // xfeatures2d_SURF_setExtended_10(nativeObj, extended);
  221. // }
  222. // //
  223. // // C++: bool cv::xfeatures2d::SURF::getExtended()
  224. // //
  225. // public bool getExtended()
  226. // {
  227. // ThrowIfDisposed();
  228. // return xfeatures2d_SURF_getExtended_10(nativeObj);
  229. // }
  230. // //
  231. // // C++: void cv::xfeatures2d::SURF::setUpright(bool upright)
  232. // //
  233. // public void setUpright(bool upright)
  234. // {
  235. // ThrowIfDisposed();
  236. // xfeatures2d_SURF_setUpright_10(nativeObj, upright);
  237. // }
  238. // //
  239. // // C++: bool cv::xfeatures2d::SURF::getUpright()
  240. // //
  241. // public bool getUpright()
  242. // {
  243. // ThrowIfDisposed();
  244. // return xfeatures2d_SURF_getUpright_10(nativeObj);
  245. // }
  246. // //
  247. // // C++: String cv::xfeatures2d::SURF::getDefaultName()
  248. // //
  249. // public override string getDefaultName()
  250. // {
  251. // ThrowIfDisposed();
  252. // string retVal = Marshal.PtrToStringAnsi(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_getDefaultName_10(nativeObj)));
  253. // return retVal;
  254. // }
  255. //#if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  256. // const string LIBNAME = "__Internal";
  257. //#else
  258. // const string LIBNAME = "opencvforunity";
  259. //#endif
  260. // // C++: static Ptr_SURF cv::xfeatures2d::SURF::create(double hessianThreshold = 100, int nOctaves = 4, int nOctaveLayers = 3, bool extended = false, bool upright = false)
  261. // [DllImport(LIBNAME)]
  262. // private static extern IntPtr xfeatures2d_SURF_create_10(double hessianThreshold, int nOctaves, int nOctaveLayers, [MarshalAs(UnmanagedType.U1)] bool extended, [MarshalAs(UnmanagedType.U1)] bool upright);
  263. // [DllImport(LIBNAME)]
  264. // private static extern IntPtr xfeatures2d_SURF_create_11(double hessianThreshold, int nOctaves, int nOctaveLayers, [MarshalAs(UnmanagedType.U1)] bool extended);
  265. // [DllImport(LIBNAME)]
  266. // private static extern IntPtr xfeatures2d_SURF_create_12(double hessianThreshold, int nOctaves, int nOctaveLayers);
  267. // [DllImport(LIBNAME)]
  268. // private static extern IntPtr xfeatures2d_SURF_create_13(double hessianThreshold, int nOctaves);
  269. // [DllImport(LIBNAME)]
  270. // private static extern IntPtr xfeatures2d_SURF_create_14(double hessianThreshold);
  271. // [DllImport(LIBNAME)]
  272. // private static extern IntPtr xfeatures2d_SURF_create_15();
  273. // // C++: void cv::xfeatures2d::SURF::setHessianThreshold(double hessianThreshold)
  274. // [DllImport(LIBNAME)]
  275. // private static extern void xfeatures2d_SURF_setHessianThreshold_10(IntPtr nativeObj, double hessianThreshold);
  276. // // C++: double cv::xfeatures2d::SURF::getHessianThreshold()
  277. // [DllImport(LIBNAME)]
  278. // private static extern double xfeatures2d_SURF_getHessianThreshold_10(IntPtr nativeObj);
  279. // // C++: void cv::xfeatures2d::SURF::setNOctaves(int nOctaves)
  280. // [DllImport(LIBNAME)]
  281. // private static extern void xfeatures2d_SURF_setNOctaves_10(IntPtr nativeObj, int nOctaves);
  282. // // C++: int cv::xfeatures2d::SURF::getNOctaves()
  283. // [DllImport(LIBNAME)]
  284. // private static extern int xfeatures2d_SURF_getNOctaves_10(IntPtr nativeObj);
  285. // // C++: void cv::xfeatures2d::SURF::setNOctaveLayers(int nOctaveLayers)
  286. // [DllImport(LIBNAME)]
  287. // private static extern void xfeatures2d_SURF_setNOctaveLayers_10(IntPtr nativeObj, int nOctaveLayers);
  288. // // C++: int cv::xfeatures2d::SURF::getNOctaveLayers()
  289. // [DllImport(LIBNAME)]
  290. // private static extern int xfeatures2d_SURF_getNOctaveLayers_10(IntPtr nativeObj);
  291. // // C++: void cv::xfeatures2d::SURF::setExtended(bool extended)
  292. // [DllImport(LIBNAME)]
  293. // private static extern void xfeatures2d_SURF_setExtended_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool extended);
  294. // // C++: bool cv::xfeatures2d::SURF::getExtended()
  295. // [DllImport(LIBNAME)]
  296. // [return: MarshalAs(UnmanagedType.U1)]
  297. // private static extern bool xfeatures2d_SURF_getExtended_10(IntPtr nativeObj);
  298. // // C++: void cv::xfeatures2d::SURF::setUpright(bool upright)
  299. // [DllImport(LIBNAME)]
  300. // private static extern void xfeatures2d_SURF_setUpright_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool upright);
  301. // // C++: bool cv::xfeatures2d::SURF::getUpright()
  302. // [DllImport(LIBNAME)]
  303. // [return: MarshalAs(UnmanagedType.U1)]
  304. // private static extern bool xfeatures2d_SURF_getUpright_10(IntPtr nativeObj);
  305. // // C++: String cv::xfeatures2d::SURF::getDefaultName()
  306. // [DllImport(LIBNAME)]
  307. // private static extern IntPtr xfeatures2d_SURF_getDefaultName_10(IntPtr nativeObj);
  308. // // native support for java finalize()
  309. // [DllImport(LIBNAME)]
  310. // private static extern void xfeatures2d_SURF_delete(IntPtr nativeObj);
  311. // }
  312. //}