Feature2D.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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.Features2dModule
  8. {
  9. // C++: class Feature2D
  10. //javadoc: Feature2D
  11. public class Feature2D : Algorithm
  12. {
  13. protected override void Dispose (bool disposing)
  14. {
  15. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  16. try {
  17. if (disposing) {
  18. }
  19. if (IsEnabledDispose) {
  20. if (nativeObj != IntPtr.Zero)
  21. features2d_Feature2D_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal Feature2D (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new Feature2D __fromPtr__ (IntPtr addr) { return new Feature2D (addr); }
  34. //
  35. // C++: String cv::Feature2D::getDefaultName()
  36. //
  37. //javadoc: Feature2D::getDefaultName()
  38. public override string getDefaultName ()
  39. {
  40. ThrowIfDisposed ();
  41. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  42. string retVal = Marshal.PtrToStringAnsi (features2d_Feature2D_getDefaultName_10(nativeObj));
  43. return retVal;
  44. #else
  45. return null;
  46. #endif
  47. }
  48. //
  49. // C++: bool cv::Feature2D::empty()
  50. //
  51. //javadoc: Feature2D::empty()
  52. public override bool empty ()
  53. {
  54. ThrowIfDisposed ();
  55. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  56. bool retVal = features2d_Feature2D_empty_10(nativeObj);
  57. return retVal;
  58. #else
  59. return false;
  60. #endif
  61. }
  62. //
  63. // C++: int cv::Feature2D::defaultNorm()
  64. //
  65. //javadoc: Feature2D::defaultNorm()
  66. public int defaultNorm ()
  67. {
  68. ThrowIfDisposed ();
  69. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  70. int retVal = features2d_Feature2D_defaultNorm_10(nativeObj);
  71. return retVal;
  72. #else
  73. return -1;
  74. #endif
  75. }
  76. //
  77. // C++: int cv::Feature2D::descriptorSize()
  78. //
  79. //javadoc: Feature2D::descriptorSize()
  80. public int descriptorSize ()
  81. {
  82. ThrowIfDisposed ();
  83. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  84. int retVal = features2d_Feature2D_descriptorSize_10(nativeObj);
  85. return retVal;
  86. #else
  87. return -1;
  88. #endif
  89. }
  90. //
  91. // C++: int cv::Feature2D::descriptorType()
  92. //
  93. //javadoc: Feature2D::descriptorType()
  94. public int descriptorType ()
  95. {
  96. ThrowIfDisposed ();
  97. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  98. int retVal = features2d_Feature2D_descriptorType_10(nativeObj);
  99. return retVal;
  100. #else
  101. return -1;
  102. #endif
  103. }
  104. //
  105. // C++: void cv::Feature2D::compute(Mat image, vector_KeyPoint& keypoints, Mat& descriptors)
  106. //
  107. //javadoc: Feature2D::compute(image, keypoints, descriptors)
  108. public void compute (Mat image, MatOfKeyPoint keypoints, Mat descriptors)
  109. {
  110. ThrowIfDisposed ();
  111. if (image != null) image.ThrowIfDisposed ();
  112. if (keypoints != null) keypoints.ThrowIfDisposed ();
  113. if (descriptors != null) descriptors.ThrowIfDisposed ();
  114. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  115. Mat keypoints_mat = keypoints;
  116. features2d_Feature2D_compute_10(nativeObj, image.nativeObj, keypoints_mat.nativeObj, descriptors.nativeObj);
  117. return;
  118. #else
  119. return;
  120. #endif
  121. }
  122. //
  123. // C++: void cv::Feature2D::compute(vector_Mat images, vector_vector_KeyPoint& keypoints, vector_Mat& descriptors)
  124. //
  125. //javadoc: Feature2D::compute(images, keypoints, descriptors)
  126. public void compute (List<Mat> images, List<MatOfKeyPoint> keypoints, List<Mat> descriptors)
  127. {
  128. ThrowIfDisposed ();
  129. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  130. Mat images_mat = Converters.vector_Mat_to_Mat(images);
  131. List<Mat> keypoints_tmplm = new List<Mat>((keypoints != null) ? keypoints.Count : 0);
  132. Mat keypoints_mat = Converters.vector_vector_KeyPoint_to_Mat(keypoints, keypoints_tmplm);
  133. Mat descriptors_mat = new Mat();
  134. features2d_Feature2D_compute_11(nativeObj, images_mat.nativeObj, keypoints_mat.nativeObj, descriptors_mat.nativeObj);
  135. Converters.Mat_to_vector_vector_KeyPoint(keypoints_mat, keypoints);
  136. keypoints_mat.release();
  137. Converters.Mat_to_vector_Mat(descriptors_mat, descriptors);
  138. descriptors_mat.release();
  139. return;
  140. #else
  141. return;
  142. #endif
  143. }
  144. //
  145. // C++: void cv::Feature2D::detect(Mat image, vector_KeyPoint& keypoints, Mat mask = Mat())
  146. //
  147. //javadoc: Feature2D::detect(image, keypoints, mask)
  148. public void detect (Mat image, MatOfKeyPoint keypoints, Mat mask)
  149. {
  150. ThrowIfDisposed ();
  151. if (image != null) image.ThrowIfDisposed ();
  152. if (keypoints != null) keypoints.ThrowIfDisposed ();
  153. if (mask != null) mask.ThrowIfDisposed ();
  154. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  155. Mat keypoints_mat = keypoints;
  156. features2d_Feature2D_detect_10(nativeObj, image.nativeObj, keypoints_mat.nativeObj, mask.nativeObj);
  157. return;
  158. #else
  159. return;
  160. #endif
  161. }
  162. //javadoc: Feature2D::detect(image, keypoints)
  163. public void detect (Mat image, MatOfKeyPoint keypoints)
  164. {
  165. ThrowIfDisposed ();
  166. if (image != null) image.ThrowIfDisposed ();
  167. if (keypoints != null) keypoints.ThrowIfDisposed ();
  168. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  169. Mat keypoints_mat = keypoints;
  170. features2d_Feature2D_detect_11(nativeObj, image.nativeObj, keypoints_mat.nativeObj);
  171. return;
  172. #else
  173. return;
  174. #endif
  175. }
  176. //
  177. // C++: void cv::Feature2D::detect(vector_Mat images, vector_vector_KeyPoint& keypoints, vector_Mat masks = vector_Mat())
  178. //
  179. //javadoc: Feature2D::detect(images, keypoints, masks)
  180. public void detect (List<Mat> images, List<MatOfKeyPoint> keypoints, List<Mat> masks)
  181. {
  182. ThrowIfDisposed ();
  183. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  184. Mat images_mat = Converters.vector_Mat_to_Mat(images);
  185. Mat keypoints_mat = new Mat();
  186. Mat masks_mat = Converters.vector_Mat_to_Mat(masks);
  187. features2d_Feature2D_detect_12(nativeObj, images_mat.nativeObj, keypoints_mat.nativeObj, masks_mat.nativeObj);
  188. Converters.Mat_to_vector_vector_KeyPoint(keypoints_mat, keypoints);
  189. keypoints_mat.release();
  190. return;
  191. #else
  192. return;
  193. #endif
  194. }
  195. //javadoc: Feature2D::detect(images, keypoints)
  196. public void detect (List<Mat> images, List<MatOfKeyPoint> keypoints)
  197. {
  198. ThrowIfDisposed ();
  199. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  200. Mat images_mat = Converters.vector_Mat_to_Mat(images);
  201. Mat keypoints_mat = new Mat();
  202. features2d_Feature2D_detect_13(nativeObj, images_mat.nativeObj, keypoints_mat.nativeObj);
  203. Converters.Mat_to_vector_vector_KeyPoint(keypoints_mat, keypoints);
  204. keypoints_mat.release();
  205. return;
  206. #else
  207. return;
  208. #endif
  209. }
  210. //
  211. // C++: void cv::Feature2D::detectAndCompute(Mat image, Mat mask, vector_KeyPoint& keypoints, Mat& descriptors, bool useProvidedKeypoints = false)
  212. //
  213. //javadoc: Feature2D::detectAndCompute(image, mask, keypoints, descriptors, useProvidedKeypoints)
  214. public void detectAndCompute (Mat image, Mat mask, MatOfKeyPoint keypoints, Mat descriptors, bool useProvidedKeypoints)
  215. {
  216. ThrowIfDisposed ();
  217. if (image != null) image.ThrowIfDisposed ();
  218. if (mask != null) mask.ThrowIfDisposed ();
  219. if (keypoints != null) keypoints.ThrowIfDisposed ();
  220. if (descriptors != null) descriptors.ThrowIfDisposed ();
  221. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  222. Mat keypoints_mat = keypoints;
  223. features2d_Feature2D_detectAndCompute_10(nativeObj, image.nativeObj, mask.nativeObj, keypoints_mat.nativeObj, descriptors.nativeObj, useProvidedKeypoints);
  224. return;
  225. #else
  226. return;
  227. #endif
  228. }
  229. //javadoc: Feature2D::detectAndCompute(image, mask, keypoints, descriptors)
  230. public void detectAndCompute (Mat image, Mat mask, MatOfKeyPoint keypoints, Mat descriptors)
  231. {
  232. ThrowIfDisposed ();
  233. if (image != null) image.ThrowIfDisposed ();
  234. if (mask != null) mask.ThrowIfDisposed ();
  235. if (keypoints != null) keypoints.ThrowIfDisposed ();
  236. if (descriptors != null) descriptors.ThrowIfDisposed ();
  237. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  238. Mat keypoints_mat = keypoints;
  239. features2d_Feature2D_detectAndCompute_11(nativeObj, image.nativeObj, mask.nativeObj, keypoints_mat.nativeObj, descriptors.nativeObj);
  240. return;
  241. #else
  242. return;
  243. #endif
  244. }
  245. //
  246. // C++: void cv::Feature2D::read(FileNode arg1)
  247. //
  248. // Unknown type 'FileNode' (I), skipping the function
  249. //
  250. // C++: void cv::Feature2D::read(String fileName)
  251. //
  252. //javadoc: Feature2D::read(fileName)
  253. public void read (string fileName)
  254. {
  255. ThrowIfDisposed ();
  256. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  257. features2d_Feature2D_read_10(nativeObj, fileName);
  258. return;
  259. #else
  260. return;
  261. #endif
  262. }
  263. //
  264. // C++: void cv::Feature2D::write(Ptr_FileStorage fs, String name = String())
  265. //
  266. // Unknown type 'Ptr_FileStorage' (I), skipping the function
  267. //
  268. // C++: void cv::Feature2D::write(String fileName)
  269. //
  270. //javadoc: Feature2D::write(fileName)
  271. public void write (string fileName)
  272. {
  273. ThrowIfDisposed ();
  274. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  275. features2d_Feature2D_write_10(nativeObj, fileName);
  276. return;
  277. #else
  278. return;
  279. #endif
  280. }
  281. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  282. const string LIBNAME = "__Internal";
  283. #else
  284. const string LIBNAME = "opencvforunity";
  285. #endif
  286. // C++: String cv::Feature2D::getDefaultName()
  287. [DllImport (LIBNAME)]
  288. private static extern IntPtr features2d_Feature2D_getDefaultName_10 (IntPtr nativeObj);
  289. // C++: bool cv::Feature2D::empty()
  290. [DllImport (LIBNAME)]
  291. private static extern bool features2d_Feature2D_empty_10 (IntPtr nativeObj);
  292. // C++: int cv::Feature2D::defaultNorm()
  293. [DllImport (LIBNAME)]
  294. private static extern int features2d_Feature2D_defaultNorm_10 (IntPtr nativeObj);
  295. // C++: int cv::Feature2D::descriptorSize()
  296. [DllImport (LIBNAME)]
  297. private static extern int features2d_Feature2D_descriptorSize_10 (IntPtr nativeObj);
  298. // C++: int cv::Feature2D::descriptorType()
  299. [DllImport (LIBNAME)]
  300. private static extern int features2d_Feature2D_descriptorType_10 (IntPtr nativeObj);
  301. // C++: void cv::Feature2D::compute(Mat image, vector_KeyPoint& keypoints, Mat& descriptors)
  302. [DllImport (LIBNAME)]
  303. private static extern void features2d_Feature2D_compute_10 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr keypoints_mat_nativeObj, IntPtr descriptors_nativeObj);
  304. // C++: void cv::Feature2D::compute(vector_Mat images, vector_vector_KeyPoint& keypoints, vector_Mat& descriptors)
  305. [DllImport (LIBNAME)]
  306. private static extern void features2d_Feature2D_compute_11 (IntPtr nativeObj, IntPtr images_mat_nativeObj, IntPtr keypoints_mat_nativeObj, IntPtr descriptors_mat_nativeObj);
  307. // C++: void cv::Feature2D::detect(Mat image, vector_KeyPoint& keypoints, Mat mask = Mat())
  308. [DllImport (LIBNAME)]
  309. private static extern void features2d_Feature2D_detect_10 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr keypoints_mat_nativeObj, IntPtr mask_nativeObj);
  310. [DllImport (LIBNAME)]
  311. private static extern void features2d_Feature2D_detect_11 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr keypoints_mat_nativeObj);
  312. // C++: void cv::Feature2D::detect(vector_Mat images, vector_vector_KeyPoint& keypoints, vector_Mat masks = vector_Mat())
  313. [DllImport (LIBNAME)]
  314. private static extern void features2d_Feature2D_detect_12 (IntPtr nativeObj, IntPtr images_mat_nativeObj, IntPtr keypoints_mat_nativeObj, IntPtr masks_mat_nativeObj);
  315. [DllImport (LIBNAME)]
  316. private static extern void features2d_Feature2D_detect_13 (IntPtr nativeObj, IntPtr images_mat_nativeObj, IntPtr keypoints_mat_nativeObj);
  317. // C++: void cv::Feature2D::detectAndCompute(Mat image, Mat mask, vector_KeyPoint& keypoints, Mat& descriptors, bool useProvidedKeypoints = false)
  318. [DllImport (LIBNAME)]
  319. private static extern void features2d_Feature2D_detectAndCompute_10 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr mask_nativeObj, IntPtr keypoints_mat_nativeObj, IntPtr descriptors_nativeObj, bool useProvidedKeypoints);
  320. [DllImport (LIBNAME)]
  321. private static extern void features2d_Feature2D_detectAndCompute_11 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr mask_nativeObj, IntPtr keypoints_mat_nativeObj, IntPtr descriptors_nativeObj);
  322. // C++: void cv::Feature2D::read(String fileName)
  323. [DllImport (LIBNAME)]
  324. private static extern void features2d_Feature2D_read_10 (IntPtr nativeObj, string fileName);
  325. // C++: void cv::Feature2D::write(String fileName)
  326. [DllImport (LIBNAME)]
  327. private static extern void features2d_Feature2D_write_10 (IntPtr nativeObj, string fileName);
  328. // native support for java finalize()
  329. [DllImport (LIBNAME)]
  330. private static extern void features2d_Feature2D_delete (IntPtr nativeObj);
  331. }
  332. }