SURF_CUDA.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. //using OpenCVForUnity.CoreModule;
  2. //using OpenCVForUnity.UtilsModule;
  3. //using System;
  4. //using System.Collections.Generic;
  5. //using System.Runtime.InteropServices;
  6. //namespace OpenCVForUnity.Xfeatures2dModule
  7. //{
  8. // // C++: class SURF_CUDA
  9. // /**
  10. // * Class used for extracting Speeded Up Robust Features (SURF) from an image. :
  11. // *
  12. // * The class SURF_CUDA implements Speeded Up Robust Features descriptor. There is a fast multi-scale
  13. // * Hessian keypoint detector that can be used to find the keypoints (which is the default option). But
  14. // * the descriptors can also be computed for the user-specified keypoints. Only 8-bit grayscale images
  15. // * are supported.
  16. // *
  17. // * The class SURF_CUDA can store results in the GPU and CPU memory. It provides functions to convert
  18. // * results between CPU and GPU version ( uploadKeypoints, downloadKeypoints, downloadDescriptors ). The
  19. // * format of CPU results is the same as SURF results. GPU results are stored in GpuMat. The keypoints
  20. // * matrix is \(\texttt{nFeatures} \times 7\) matrix with the CV_32FC1 type.
  21. // *
  22. // * <ul>
  23. // * <li>
  24. // * keypoints.ptr&lt;float&gt;(X_ROW)[i] contains x coordinate of the i-th feature.
  25. // * </li>
  26. // * <li>
  27. // * keypoints.ptr&lt;float&gt;(Y_ROW)[i] contains y coordinate of the i-th feature.
  28. // * </li>
  29. // * <li>
  30. // * keypoints.ptr&lt;float&gt;(LAPLACIAN_ROW)[i] contains the laplacian sign of the i-th feature.
  31. // * </li>
  32. // * <li>
  33. // * keypoints.ptr&lt;float&gt;(OCTAVE_ROW)[i] contains the octave of the i-th feature.
  34. // * </li>
  35. // * <li>
  36. // * keypoints.ptr&lt;float&gt;(SIZE_ROW)[i] contains the size of the i-th feature.
  37. // * </li>
  38. // * <li>
  39. // * keypoints.ptr&lt;float&gt;(ANGLE_ROW)[i] contain orientation of the i-th feature.
  40. // * </li>
  41. // * <li>
  42. // * keypoints.ptr&lt;float&gt;(HESSIAN_ROW)[i] contains the response of the i-th feature.
  43. // * </li>
  44. // * </ul>
  45. // *
  46. // * The descriptors matrix is \(\texttt{nFeatures} \times \texttt{descriptorSize}\) matrix with the
  47. // * CV_32FC1 type.
  48. // *
  49. // * The class SURF_CUDA uses some buffers and provides access to it. All buffers can be safely released
  50. // * between function calls.
  51. // *
  52. // * SEE: SURF
  53. // *
  54. // * <b>Note:</b>
  55. // * <ul>
  56. // * <li>
  57. // * An example for using the SURF keypoint matcher on GPU can be found at
  58. // * opencv_source_code/samples/gpu/surf_keypoint_matcher.cpp
  59. // * </li>
  60. // * </ul>
  61. // */
  62. // public class SURF_CUDA : DisposableOpenCVObject
  63. // {
  64. // protected override void Dispose(bool disposing)
  65. // {
  66. // try
  67. // {
  68. // if (disposing)
  69. // {
  70. // }
  71. // if (IsEnabledDispose)
  72. // {
  73. // if (nativeObj != IntPtr.Zero)
  74. // xfeatures2d_SURF_1CUDA_delete(nativeObj);
  75. // nativeObj = IntPtr.Zero;
  76. // }
  77. // }
  78. // finally
  79. // {
  80. // base.Dispose(disposing);
  81. // }
  82. // }
  83. // protected internal SURF_CUDA(IntPtr addr) : base(addr) { }
  84. // public IntPtr getNativeObjAddr() { return nativeObj; }
  85. // // internal usage only
  86. // public static SURF_CUDA __fromPtr__(IntPtr addr) { return new SURF_CUDA(addr); }
  87. // // C++: enum cv.cuda.SURF_CUDA.KeypointLayout
  88. // public const int X_ROW = 0;
  89. // public const int Y_ROW = 0 + 1;
  90. // public const int LAPLACIAN_ROW = 0 + 2;
  91. // public const int OCTAVE_ROW = 0 + 3;
  92. // public const int SIZE_ROW = 0 + 4;
  93. // public const int ANGLE_ROW = 0 + 5;
  94. // public const int HESSIAN_ROW = 0 + 6;
  95. // public const int ROWS_COUNT = 0 + 7;
  96. // //
  97. // // C++: static Ptr_SURF_CUDA cv::cuda::SURF_CUDA::create(double _hessianThreshold, int _nOctaves = 4, int _nOctaveLayers = 2, bool _extended = false, float _keypointsRatio = 0.01f, bool _upright = false)
  98. // //
  99. // /**
  100. // * param _hessianThreshold Threshold for hessian keypoint detector used in SURF.
  101. // * param _nOctaves Number of pyramid octaves the keypoint detector will use.
  102. // * param _nOctaveLayers Number of octave layers within each octave.
  103. // * param _extended Extended descriptor flag (true - use extended 128-element descriptors; false - use
  104. // * 64-element descriptors).
  105. // * param _keypointsRatio Limits a maximum number of features
  106. // * param _upright Up-right or rotated features flag (true - do not compute orientation of features;
  107. // * false - compute orientation).
  108. // * return automatically generated
  109. // */
  110. // public static SURF_CUDA create(double _hessianThreshold, int _nOctaves, int _nOctaveLayers, bool _extended, float _keypointsRatio, bool _upright)
  111. // {
  112. // return SURF_CUDA.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_1CUDA_create_10(_hessianThreshold, _nOctaves, _nOctaveLayers, _extended, _keypointsRatio, _upright)));
  113. // }
  114. // /**
  115. // * param _hessianThreshold Threshold for hessian keypoint detector used in SURF.
  116. // * param _nOctaves Number of pyramid octaves the keypoint detector will use.
  117. // * param _nOctaveLayers Number of octave layers within each octave.
  118. // * param _extended Extended descriptor flag (true - use extended 128-element descriptors; false - use
  119. // * 64-element descriptors).
  120. // * param _keypointsRatio Limits a maximum number of features
  121. // * false - compute orientation).
  122. // * return automatically generated
  123. // */
  124. // public static SURF_CUDA create(double _hessianThreshold, int _nOctaves, int _nOctaveLayers, bool _extended, float _keypointsRatio)
  125. // {
  126. // return SURF_CUDA.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_1CUDA_create_11(_hessianThreshold, _nOctaves, _nOctaveLayers, _extended, _keypointsRatio)));
  127. // }
  128. // /**
  129. // * param _hessianThreshold Threshold for hessian keypoint detector used in SURF.
  130. // * param _nOctaves Number of pyramid octaves the keypoint detector will use.
  131. // * param _nOctaveLayers Number of octave layers within each octave.
  132. // * param _extended Extended descriptor flag (true - use extended 128-element descriptors; false - use
  133. // * 64-element descriptors).
  134. // * false - compute orientation).
  135. // * return automatically generated
  136. // */
  137. // public static SURF_CUDA create(double _hessianThreshold, int _nOctaves, int _nOctaveLayers, bool _extended)
  138. // {
  139. // return SURF_CUDA.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_1CUDA_create_12(_hessianThreshold, _nOctaves, _nOctaveLayers, _extended)));
  140. // }
  141. // /**
  142. // * param _hessianThreshold Threshold for hessian keypoint detector used in SURF.
  143. // * param _nOctaves Number of pyramid octaves the keypoint detector will use.
  144. // * param _nOctaveLayers Number of octave layers within each octave.
  145. // * 64-element descriptors).
  146. // * false - compute orientation).
  147. // * return automatically generated
  148. // */
  149. // public static SURF_CUDA create(double _hessianThreshold, int _nOctaves, int _nOctaveLayers)
  150. // {
  151. // return SURF_CUDA.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_1CUDA_create_13(_hessianThreshold, _nOctaves, _nOctaveLayers)));
  152. // }
  153. // /**
  154. // * param _hessianThreshold Threshold for hessian keypoint detector used in SURF.
  155. // * param _nOctaves Number of pyramid octaves the keypoint detector will use.
  156. // * 64-element descriptors).
  157. // * false - compute orientation).
  158. // * return automatically generated
  159. // */
  160. // public static SURF_CUDA create(double _hessianThreshold, int _nOctaves)
  161. // {
  162. // return SURF_CUDA.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_1CUDA_create_14(_hessianThreshold, _nOctaves)));
  163. // }
  164. // /**
  165. // * param _hessianThreshold Threshold for hessian keypoint detector used in SURF.
  166. // * 64-element descriptors).
  167. // * false - compute orientation).
  168. // * return automatically generated
  169. // */
  170. // public static SURF_CUDA create(double _hessianThreshold)
  171. // {
  172. // return SURF_CUDA.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_SURF_1CUDA_create_15(_hessianThreshold)));
  173. // }
  174. // //
  175. // // C++: int cv::cuda::SURF_CUDA::descriptorSize()
  176. // //
  177. // public int descriptorSize()
  178. // {
  179. // ThrowIfDisposed();
  180. // return xfeatures2d_SURF_1CUDA_descriptorSize_10(nativeObj);
  181. // }
  182. // //
  183. // // C++: int cv::cuda::SURF_CUDA::defaultNorm()
  184. // //
  185. // public int defaultNorm()
  186. // {
  187. // ThrowIfDisposed();
  188. // return xfeatures2d_SURF_1CUDA_defaultNorm_10(nativeObj);
  189. // }
  190. // //
  191. // // C++: void cv::cuda::SURF_CUDA::downloadKeypoints(GpuMat keypointsGPU, vector_KeyPoint& keypoints)
  192. // //
  193. // // Unknown type 'GpuMat' (I), skipping the function
  194. // //
  195. // // C++: void cv::cuda::SURF_CUDA::detect(GpuMat img, GpuMat mask, GpuMat& keypoints)
  196. // //
  197. // // Unknown type 'GpuMat' (I), skipping the function
  198. // //
  199. // // C++: void cv::cuda::SURF_CUDA::detectWithDescriptors(GpuMat img, GpuMat mask, GpuMat& keypoints, GpuMat& descriptors, bool useProvidedKeypoints = false)
  200. // //
  201. // // Unknown type 'GpuMat' (I), skipping the function
  202. // //
  203. // // C++: double SURF_CUDA::hessianThreshold
  204. // //
  205. // public double get_hessianThreshold()
  206. // {
  207. // ThrowIfDisposed();
  208. // return xfeatures2d_SURF_1CUDA_get_1hessianThreshold_10(nativeObj);
  209. // }
  210. // //
  211. // // C++: int SURF_CUDA::nOctaves
  212. // //
  213. // public int get_nOctaves()
  214. // {
  215. // ThrowIfDisposed();
  216. // return xfeatures2d_SURF_1CUDA_get_1nOctaves_10(nativeObj);
  217. // }
  218. // //
  219. // // C++: int SURF_CUDA::nOctaveLayers
  220. // //
  221. // public int get_nOctaveLayers()
  222. // {
  223. // ThrowIfDisposed();
  224. // return xfeatures2d_SURF_1CUDA_get_1nOctaveLayers_10(nativeObj);
  225. // }
  226. // //
  227. // // C++: bool SURF_CUDA::extended
  228. // //
  229. // public bool get_extended()
  230. // {
  231. // ThrowIfDisposed();
  232. // return xfeatures2d_SURF_1CUDA_get_1extended_10(nativeObj);
  233. // }
  234. // //
  235. // // C++: bool SURF_CUDA::upright
  236. // //
  237. // public bool get_upright()
  238. // {
  239. // ThrowIfDisposed();
  240. // return xfeatures2d_SURF_1CUDA_get_1upright_10(nativeObj);
  241. // }
  242. // //
  243. // // C++: float SURF_CUDA::keypointsRatio
  244. // //
  245. // public float get_keypointsRatio()
  246. // {
  247. // ThrowIfDisposed();
  248. // return xfeatures2d_SURF_1CUDA_get_1keypointsRatio_10(nativeObj);
  249. // }
  250. //#if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  251. // const string LIBNAME = "__Internal";
  252. //#else
  253. // const string LIBNAME = "opencvforunity";
  254. //#endif
  255. // // C++: static Ptr_SURF_CUDA cv::cuda::SURF_CUDA::create(double _hessianThreshold, int _nOctaves = 4, int _nOctaveLayers = 2, bool _extended = false, float _keypointsRatio = 0.01f, bool _upright = false)
  256. // [DllImport(LIBNAME)]
  257. // private static extern IntPtr xfeatures2d_SURF_1CUDA_create_10(double _hessianThreshold, int _nOctaves, int _nOctaveLayers, [MarshalAs(UnmanagedType.U1)] bool _extended, float _keypointsRatio, [MarshalAs(UnmanagedType.U1)] bool _upright);
  258. // [DllImport(LIBNAME)]
  259. // private static extern IntPtr xfeatures2d_SURF_1CUDA_create_11(double _hessianThreshold, int _nOctaves, int _nOctaveLayers, [MarshalAs(UnmanagedType.U1)] bool _extended, float _keypointsRatio);
  260. // [DllImport(LIBNAME)]
  261. // private static extern IntPtr xfeatures2d_SURF_1CUDA_create_12(double _hessianThreshold, int _nOctaves, int _nOctaveLayers, [MarshalAs(UnmanagedType.U1)] bool _extended);
  262. // [DllImport(LIBNAME)]
  263. // private static extern IntPtr xfeatures2d_SURF_1CUDA_create_13(double _hessianThreshold, int _nOctaves, int _nOctaveLayers);
  264. // [DllImport(LIBNAME)]
  265. // private static extern IntPtr xfeatures2d_SURF_1CUDA_create_14(double _hessianThreshold, int _nOctaves);
  266. // [DllImport(LIBNAME)]
  267. // private static extern IntPtr xfeatures2d_SURF_1CUDA_create_15(double _hessianThreshold);
  268. // // C++: int cv::cuda::SURF_CUDA::descriptorSize()
  269. // [DllImport(LIBNAME)]
  270. // private static extern int xfeatures2d_SURF_1CUDA_descriptorSize_10(IntPtr nativeObj);
  271. // // C++: int cv::cuda::SURF_CUDA::defaultNorm()
  272. // [DllImport(LIBNAME)]
  273. // private static extern int xfeatures2d_SURF_1CUDA_defaultNorm_10(IntPtr nativeObj);
  274. // // C++: double SURF_CUDA::hessianThreshold
  275. // [DllImport(LIBNAME)]
  276. // private static extern double xfeatures2d_SURF_1CUDA_get_1hessianThreshold_10(IntPtr nativeObj);
  277. // // C++: int SURF_CUDA::nOctaves
  278. // [DllImport(LIBNAME)]
  279. // private static extern int xfeatures2d_SURF_1CUDA_get_1nOctaves_10(IntPtr nativeObj);
  280. // // C++: int SURF_CUDA::nOctaveLayers
  281. // [DllImport(LIBNAME)]
  282. // private static extern int xfeatures2d_SURF_1CUDA_get_1nOctaveLayers_10(IntPtr nativeObj);
  283. // // C++: bool SURF_CUDA::extended
  284. // [DllImport(LIBNAME)]
  285. // [return: MarshalAs(UnmanagedType.U1)]
  286. // private static extern bool xfeatures2d_SURF_1CUDA_get_1extended_10(IntPtr nativeObj);
  287. // // C++: bool SURF_CUDA::upright
  288. // [DllImport(LIBNAME)]
  289. // [return: MarshalAs(UnmanagedType.U1)]
  290. // private static extern bool xfeatures2d_SURF_1CUDA_get_1upright_10(IntPtr nativeObj);
  291. // // C++: float SURF_CUDA::keypointsRatio
  292. // [DllImport(LIBNAME)]
  293. // private static extern float xfeatures2d_SURF_1CUDA_get_1keypointsRatio_10(IntPtr nativeObj);
  294. // // native support for java finalize()
  295. // [DllImport(LIBNAME)]
  296. // private static extern void xfeatures2d_SURF_1CUDA_delete(IntPtr nativeObj);
  297. // }
  298. //}