Xfeatures2d.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. 
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.Features2dModule;
  4. using OpenCVForUnity.UtilsModule;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Runtime.InteropServices;
  8. namespace OpenCVForUnity.Xfeatures2dModule {
  9. // C++: class Xfeatures2d
  10. //javadoc: Xfeatures2d
  11. public class Xfeatures2d {
  12. //
  13. // C++: void cv::xfeatures2d::matchGMS(Size size1, Size size2, vector_KeyPoint keypoints1, vector_KeyPoint keypoints2, vector_DMatch matches1to2, vector_DMatch& matchesGMS, bool withRotation = false, bool withScale = false, double thresholdFactor = 6.0)
  14. //
  15. //javadoc: matchGMS(size1, size2, keypoints1, keypoints2, matches1to2, matchesGMS, withRotation, withScale, thresholdFactor)
  16. public static void matchGMS(Size size1, Size size2, MatOfKeyPoint keypoints1, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, MatOfDMatch matchesGMS, bool withRotation, bool withScale, double thresholdFactor) {
  17. if (keypoints1 != null) keypoints1.ThrowIfDisposed();
  18. if (keypoints2 != null) keypoints2.ThrowIfDisposed();
  19. if (matches1to2 != null) matches1to2.ThrowIfDisposed();
  20. if (matchesGMS != null) matchesGMS.ThrowIfDisposed();
  21. #if (UNITY_ANDROID && !UNITY_EDITOR)
  22. Mat keypoints1_mat = keypoints1;
  23. Mat keypoints2_mat = keypoints2;
  24. Mat matches1to2_mat = matches1to2;
  25. Mat matchesGMS_mat = matchesGMS;
  26. xfeatures2d_Xfeatures2d_matchGMS_10(size1.width, size1.height, size2.width, size2.height, keypoints1_mat.nativeObj, keypoints2_mat.nativeObj, matches1to2_mat.nativeObj, matchesGMS_mat.nativeObj, withRotation, withScale, thresholdFactor);
  27. return;
  28. #else
  29. return;
  30. #endif
  31. }
  32. //javadoc: matchGMS(size1, size2, keypoints1, keypoints2, matches1to2, matchesGMS, withRotation, withScale)
  33. public static void matchGMS(Size size1, Size size2, MatOfKeyPoint keypoints1, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, MatOfDMatch matchesGMS, bool withRotation, bool withScale) {
  34. if (keypoints1 != null) keypoints1.ThrowIfDisposed();
  35. if (keypoints2 != null) keypoints2.ThrowIfDisposed();
  36. if (matches1to2 != null) matches1to2.ThrowIfDisposed();
  37. if (matchesGMS != null) matchesGMS.ThrowIfDisposed();
  38. #if (UNITY_ANDROID && !UNITY_EDITOR)
  39. Mat keypoints1_mat = keypoints1;
  40. Mat keypoints2_mat = keypoints2;
  41. Mat matches1to2_mat = matches1to2;
  42. Mat matchesGMS_mat = matchesGMS;
  43. xfeatures2d_Xfeatures2d_matchGMS_11(size1.width, size1.height, size2.width, size2.height, keypoints1_mat.nativeObj, keypoints2_mat.nativeObj, matches1to2_mat.nativeObj, matchesGMS_mat.nativeObj, withRotation, withScale);
  44. return;
  45. #else
  46. return;
  47. #endif
  48. }
  49. //javadoc: matchGMS(size1, size2, keypoints1, keypoints2, matches1to2, matchesGMS, withRotation)
  50. public static void matchGMS(Size size1, Size size2, MatOfKeyPoint keypoints1, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, MatOfDMatch matchesGMS, bool withRotation) {
  51. if (keypoints1 != null) keypoints1.ThrowIfDisposed();
  52. if (keypoints2 != null) keypoints2.ThrowIfDisposed();
  53. if (matches1to2 != null) matches1to2.ThrowIfDisposed();
  54. if (matchesGMS != null) matchesGMS.ThrowIfDisposed();
  55. #if (UNITY_ANDROID && !UNITY_EDITOR)
  56. Mat keypoints1_mat = keypoints1;
  57. Mat keypoints2_mat = keypoints2;
  58. Mat matches1to2_mat = matches1to2;
  59. Mat matchesGMS_mat = matchesGMS;
  60. xfeatures2d_Xfeatures2d_matchGMS_12(size1.width, size1.height, size2.width, size2.height, keypoints1_mat.nativeObj, keypoints2_mat.nativeObj, matches1to2_mat.nativeObj, matchesGMS_mat.nativeObj, withRotation);
  61. return;
  62. #else
  63. return;
  64. #endif
  65. }
  66. //javadoc: matchGMS(size1, size2, keypoints1, keypoints2, matches1to2, matchesGMS)
  67. public static void matchGMS(Size size1, Size size2, MatOfKeyPoint keypoints1, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, MatOfDMatch matchesGMS) {
  68. if (keypoints1 != null) keypoints1.ThrowIfDisposed();
  69. if (keypoints2 != null) keypoints2.ThrowIfDisposed();
  70. if (matches1to2 != null) matches1to2.ThrowIfDisposed();
  71. if (matchesGMS != null) matchesGMS.ThrowIfDisposed();
  72. #if (UNITY_ANDROID && !UNITY_EDITOR)
  73. Mat keypoints1_mat = keypoints1;
  74. Mat keypoints2_mat = keypoints2;
  75. Mat matches1to2_mat = matches1to2;
  76. Mat matchesGMS_mat = matchesGMS;
  77. xfeatures2d_Xfeatures2d_matchGMS_13(size1.width, size1.height, size2.width, size2.height, keypoints1_mat.nativeObj, keypoints2_mat.nativeObj, matches1to2_mat.nativeObj, matchesGMS_mat.nativeObj);
  78. return;
  79. #else
  80. return;
  81. #endif
  82. }
  83. #if (UNITY_ANDROID && !UNITY_EDITOR)
  84. const string LIBNAME = "opencvforunity";
  85. // C++: void cv::xfeatures2d::matchGMS(Size size1, Size size2, vector_KeyPoint keypoints1, vector_KeyPoint keypoints2, vector_DMatch matches1to2, vector_DMatch& matchesGMS, bool withRotation = false, bool withScale = false, double thresholdFactor = 6.0)
  86. [DllImport(LIBNAME)]
  87. private static extern void xfeatures2d_Xfeatures2d_matchGMS_10(double size1_width, double size1_height, double size2_width, double size2_height, IntPtr keypoints1_mat_nativeObj, IntPtr keypoints2_mat_nativeObj, IntPtr matches1to2_mat_nativeObj, IntPtr matchesGMS_mat_nativeObj, bool withRotation, bool withScale, double thresholdFactor);
  88. [DllImport(LIBNAME)]
  89. private static extern void xfeatures2d_Xfeatures2d_matchGMS_11(double size1_width, double size1_height, double size2_width, double size2_height, IntPtr keypoints1_mat_nativeObj, IntPtr keypoints2_mat_nativeObj, IntPtr matches1to2_mat_nativeObj, IntPtr matchesGMS_mat_nativeObj, bool withRotation, bool withScale);
  90. [DllImport(LIBNAME)]
  91. private static extern void xfeatures2d_Xfeatures2d_matchGMS_12(double size1_width, double size1_height, double size2_width, double size2_height, IntPtr keypoints1_mat_nativeObj, IntPtr keypoints2_mat_nativeObj, IntPtr matches1to2_mat_nativeObj, IntPtr matchesGMS_mat_nativeObj, bool withRotation);
  92. [DllImport(LIBNAME)]
  93. private static extern void xfeatures2d_Xfeatures2d_matchGMS_13(double size1_width, double size1_height, double size2_width, double size2_height, IntPtr keypoints1_mat_nativeObj, IntPtr keypoints2_mat_nativeObj, IntPtr matches1to2_mat_nativeObj, IntPtr matchesGMS_mat_nativeObj);
  94. #endif
  95. }
  96. }