FREAK.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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 FREAK
  10. /**
  11. * Class implementing the FREAK (*Fast Retina Keypoint*) keypoint descriptor, described in CITE: AOV12 .
  12. *
  13. * The algorithm propose a novel keypoint descriptor inspired by the human visual system and more
  14. * precisely the retina, coined Fast Retina Key- point (FREAK). A cascade of binary strings is
  15. * computed by efficiently comparing image intensities over a retinal sampling pattern. FREAKs are in
  16. * general faster to compute with lower memory load and also more robust than SIFT, SURF or BRISK.
  17. * They are competitive alternatives to existing keypoints in particular for embedded applications.
  18. *
  19. * <b>Note:</b>
  20. * <ul>
  21. * <li>
  22. * An example on how to use the FREAK descriptor can be found at
  23. * opencv_source_code/samples/cpp/freak_demo.cpp
  24. * </li>
  25. * </ul>
  26. */
  27. public class FREAK : Feature2D
  28. {
  29. protected override void Dispose(bool disposing)
  30. {
  31. try
  32. {
  33. if (disposing)
  34. {
  35. }
  36. if (IsEnabledDispose)
  37. {
  38. if (nativeObj != IntPtr.Zero)
  39. xfeatures2d_FREAK_delete(nativeObj);
  40. nativeObj = IntPtr.Zero;
  41. }
  42. }
  43. finally
  44. {
  45. base.Dispose(disposing);
  46. }
  47. }
  48. protected internal FREAK(IntPtr addr) : base(addr) { }
  49. // internal usage only
  50. public static new FREAK __fromPtr__(IntPtr addr) { return new FREAK(addr); }
  51. //
  52. // C++: static Ptr_FREAK cv::xfeatures2d::FREAK::create(bool orientationNormalized = true, bool scaleNormalized = true, float patternScale = 22.0f, int nOctaves = 4, vector_int selectedPairs = std::vector<int>())
  53. //
  54. /**
  55. * param orientationNormalized Enable orientation normalization.
  56. * param scaleNormalized Enable scale normalization.
  57. * param patternScale Scaling of the description pattern.
  58. * param nOctaves Number of octaves covered by the detected keypoints.
  59. * param selectedPairs (Optional) user defined selected pairs indexes,
  60. * return automatically generated
  61. */
  62. public static FREAK create(bool orientationNormalized, bool scaleNormalized, float patternScale, int nOctaves, MatOfInt selectedPairs)
  63. {
  64. if (selectedPairs != null) selectedPairs.ThrowIfDisposed();
  65. Mat selectedPairs_mat = selectedPairs;
  66. return FREAK.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_FREAK_create_10(orientationNormalized, scaleNormalized, patternScale, nOctaves, selectedPairs_mat.nativeObj)));
  67. }
  68. /**
  69. * param orientationNormalized Enable orientation normalization.
  70. * param scaleNormalized Enable scale normalization.
  71. * param patternScale Scaling of the description pattern.
  72. * param nOctaves Number of octaves covered by the detected keypoints.
  73. * return automatically generated
  74. */
  75. public static FREAK create(bool orientationNormalized, bool scaleNormalized, float patternScale, int nOctaves)
  76. {
  77. return FREAK.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_FREAK_create_11(orientationNormalized, scaleNormalized, patternScale, nOctaves)));
  78. }
  79. /**
  80. * param orientationNormalized Enable orientation normalization.
  81. * param scaleNormalized Enable scale normalization.
  82. * param patternScale Scaling of the description pattern.
  83. * return automatically generated
  84. */
  85. public static FREAK create(bool orientationNormalized, bool scaleNormalized, float patternScale)
  86. {
  87. return FREAK.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_FREAK_create_12(orientationNormalized, scaleNormalized, patternScale)));
  88. }
  89. /**
  90. * param orientationNormalized Enable orientation normalization.
  91. * param scaleNormalized Enable scale normalization.
  92. * return automatically generated
  93. */
  94. public static FREAK create(bool orientationNormalized, bool scaleNormalized)
  95. {
  96. return FREAK.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_FREAK_create_13(orientationNormalized, scaleNormalized)));
  97. }
  98. /**
  99. * param orientationNormalized Enable orientation normalization.
  100. * return automatically generated
  101. */
  102. public static FREAK create(bool orientationNormalized)
  103. {
  104. return FREAK.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_FREAK_create_14(orientationNormalized)));
  105. }
  106. /**
  107. * return automatically generated
  108. */
  109. public static FREAK create()
  110. {
  111. return FREAK.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_FREAK_create_15()));
  112. }
  113. //
  114. // C++: void cv::xfeatures2d::FREAK::setOrientationNormalized(bool orientationNormalized)
  115. //
  116. public void setOrientationNormalized(bool orientationNormalized)
  117. {
  118. ThrowIfDisposed();
  119. xfeatures2d_FREAK_setOrientationNormalized_10(nativeObj, orientationNormalized);
  120. }
  121. //
  122. // C++: bool cv::xfeatures2d::FREAK::getOrientationNormalized()
  123. //
  124. public bool getOrientationNormalized()
  125. {
  126. ThrowIfDisposed();
  127. return xfeatures2d_FREAK_getOrientationNormalized_10(nativeObj);
  128. }
  129. //
  130. // C++: void cv::xfeatures2d::FREAK::setScaleNormalized(bool scaleNormalized)
  131. //
  132. public void setScaleNormalized(bool scaleNormalized)
  133. {
  134. ThrowIfDisposed();
  135. xfeatures2d_FREAK_setScaleNormalized_10(nativeObj, scaleNormalized);
  136. }
  137. //
  138. // C++: bool cv::xfeatures2d::FREAK::getScaleNormalized()
  139. //
  140. public bool getScaleNormalized()
  141. {
  142. ThrowIfDisposed();
  143. return xfeatures2d_FREAK_getScaleNormalized_10(nativeObj);
  144. }
  145. //
  146. // C++: void cv::xfeatures2d::FREAK::setPatternScale(double patternScale)
  147. //
  148. public void setPatternScale(double patternScale)
  149. {
  150. ThrowIfDisposed();
  151. xfeatures2d_FREAK_setPatternScale_10(nativeObj, patternScale);
  152. }
  153. //
  154. // C++: double cv::xfeatures2d::FREAK::getPatternScale()
  155. //
  156. public double getPatternScale()
  157. {
  158. ThrowIfDisposed();
  159. return xfeatures2d_FREAK_getPatternScale_10(nativeObj);
  160. }
  161. //
  162. // C++: void cv::xfeatures2d::FREAK::setNOctaves(int nOctaves)
  163. //
  164. public void setNOctaves(int nOctaves)
  165. {
  166. ThrowIfDisposed();
  167. xfeatures2d_FREAK_setNOctaves_10(nativeObj, nOctaves);
  168. }
  169. //
  170. // C++: int cv::xfeatures2d::FREAK::getNOctaves()
  171. //
  172. public int getNOctaves()
  173. {
  174. ThrowIfDisposed();
  175. return xfeatures2d_FREAK_getNOctaves_10(nativeObj);
  176. }
  177. //
  178. // C++: String cv::xfeatures2d::FREAK::getDefaultName()
  179. //
  180. public override string getDefaultName()
  181. {
  182. ThrowIfDisposed();
  183. string retVal = Marshal.PtrToStringAnsi(DisposableObject.ThrowIfNullIntPtr(xfeatures2d_FREAK_getDefaultName_10(nativeObj)));
  184. return retVal;
  185. }
  186. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  187. const string LIBNAME = "__Internal";
  188. #else
  189. const string LIBNAME = "opencvforunity";
  190. #endif
  191. // C++: static Ptr_FREAK cv::xfeatures2d::FREAK::create(bool orientationNormalized = true, bool scaleNormalized = true, float patternScale = 22.0f, int nOctaves = 4, vector_int selectedPairs = std::vector<int>())
  192. [DllImport(LIBNAME)]
  193. private static extern IntPtr xfeatures2d_FREAK_create_10([MarshalAs(UnmanagedType.U1)] bool orientationNormalized, [MarshalAs(UnmanagedType.U1)] bool scaleNormalized, float patternScale, int nOctaves, IntPtr selectedPairs_mat_nativeObj);
  194. [DllImport(LIBNAME)]
  195. private static extern IntPtr xfeatures2d_FREAK_create_11([MarshalAs(UnmanagedType.U1)] bool orientationNormalized, [MarshalAs(UnmanagedType.U1)] bool scaleNormalized, float patternScale, int nOctaves);
  196. [DllImport(LIBNAME)]
  197. private static extern IntPtr xfeatures2d_FREAK_create_12([MarshalAs(UnmanagedType.U1)] bool orientationNormalized, [MarshalAs(UnmanagedType.U1)] bool scaleNormalized, float patternScale);
  198. [DllImport(LIBNAME)]
  199. private static extern IntPtr xfeatures2d_FREAK_create_13([MarshalAs(UnmanagedType.U1)] bool orientationNormalized, [MarshalAs(UnmanagedType.U1)] bool scaleNormalized);
  200. [DllImport(LIBNAME)]
  201. private static extern IntPtr xfeatures2d_FREAK_create_14([MarshalAs(UnmanagedType.U1)] bool orientationNormalized);
  202. [DllImport(LIBNAME)]
  203. private static extern IntPtr xfeatures2d_FREAK_create_15();
  204. // C++: void cv::xfeatures2d::FREAK::setOrientationNormalized(bool orientationNormalized)
  205. [DllImport(LIBNAME)]
  206. private static extern void xfeatures2d_FREAK_setOrientationNormalized_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool orientationNormalized);
  207. // C++: bool cv::xfeatures2d::FREAK::getOrientationNormalized()
  208. [DllImport(LIBNAME)]
  209. [return: MarshalAs(UnmanagedType.U1)]
  210. private static extern bool xfeatures2d_FREAK_getOrientationNormalized_10(IntPtr nativeObj);
  211. // C++: void cv::xfeatures2d::FREAK::setScaleNormalized(bool scaleNormalized)
  212. [DllImport(LIBNAME)]
  213. private static extern void xfeatures2d_FREAK_setScaleNormalized_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool scaleNormalized);
  214. // C++: bool cv::xfeatures2d::FREAK::getScaleNormalized()
  215. [DllImport(LIBNAME)]
  216. [return: MarshalAs(UnmanagedType.U1)]
  217. private static extern bool xfeatures2d_FREAK_getScaleNormalized_10(IntPtr nativeObj);
  218. // C++: void cv::xfeatures2d::FREAK::setPatternScale(double patternScale)
  219. [DllImport(LIBNAME)]
  220. private static extern void xfeatures2d_FREAK_setPatternScale_10(IntPtr nativeObj, double patternScale);
  221. // C++: double cv::xfeatures2d::FREAK::getPatternScale()
  222. [DllImport(LIBNAME)]
  223. private static extern double xfeatures2d_FREAK_getPatternScale_10(IntPtr nativeObj);
  224. // C++: void cv::xfeatures2d::FREAK::setNOctaves(int nOctaves)
  225. [DllImport(LIBNAME)]
  226. private static extern void xfeatures2d_FREAK_setNOctaves_10(IntPtr nativeObj, int nOctaves);
  227. // C++: int cv::xfeatures2d::FREAK::getNOctaves()
  228. [DllImport(LIBNAME)]
  229. private static extern int xfeatures2d_FREAK_getNOctaves_10(IntPtr nativeObj);
  230. // C++: String cv::xfeatures2d::FREAK::getDefaultName()
  231. [DllImport(LIBNAME)]
  232. private static extern IntPtr xfeatures2d_FREAK_getDefaultName_10(IntPtr nativeObj);
  233. // native support for java finalize()
  234. [DllImport(LIBNAME)]
  235. private static extern void xfeatures2d_FREAK_delete(IntPtr nativeObj);
  236. }
  237. }