BIF.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.FaceModule
  8. {
  9. // C++: class BIF
  10. //javadoc: BIF
  11. public class BIF : 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. face_BIF_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal BIF (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new BIF __fromPtr__ (IntPtr addr) { return new BIF (addr); }
  34. //
  35. // C++: static Ptr_BIF cv::face::BIF::create(int num_bands = 8, int num_rotations = 12)
  36. //
  37. //javadoc: BIF::create(num_bands, num_rotations)
  38. public static BIF create (int num_bands, int num_rotations)
  39. {
  40. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  41. BIF retVal = BIF.__fromPtr__(face_BIF_create_10(num_bands, num_rotations));
  42. return retVal;
  43. #else
  44. return null;
  45. #endif
  46. }
  47. //javadoc: BIF::create(num_bands)
  48. public static BIF create (int num_bands)
  49. {
  50. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  51. BIF retVal = BIF.__fromPtr__(face_BIF_create_11(num_bands));
  52. return retVal;
  53. #else
  54. return null;
  55. #endif
  56. }
  57. //javadoc: BIF::create()
  58. public static BIF create ()
  59. {
  60. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  61. BIF retVal = BIF.__fromPtr__(face_BIF_create_12());
  62. return retVal;
  63. #else
  64. return null;
  65. #endif
  66. }
  67. //
  68. // C++: int cv::face::BIF::getNumBands()
  69. //
  70. //javadoc: BIF::getNumBands()
  71. public int getNumBands ()
  72. {
  73. ThrowIfDisposed ();
  74. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  75. int retVal = face_BIF_getNumBands_10(nativeObj);
  76. return retVal;
  77. #else
  78. return -1;
  79. #endif
  80. }
  81. //
  82. // C++: int cv::face::BIF::getNumRotations()
  83. //
  84. //javadoc: BIF::getNumRotations()
  85. public int getNumRotations ()
  86. {
  87. ThrowIfDisposed ();
  88. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  89. int retVal = face_BIF_getNumRotations_10(nativeObj);
  90. return retVal;
  91. #else
  92. return -1;
  93. #endif
  94. }
  95. //
  96. // C++: void cv::face::BIF::compute(Mat image, Mat& features)
  97. //
  98. //javadoc: BIF::compute(image, features)
  99. public void compute (Mat image, Mat features)
  100. {
  101. ThrowIfDisposed ();
  102. if (image != null) image.ThrowIfDisposed ();
  103. if (features != null) features.ThrowIfDisposed ();
  104. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  105. face_BIF_compute_10(nativeObj, image.nativeObj, features.nativeObj);
  106. return;
  107. #else
  108. return;
  109. #endif
  110. }
  111. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  112. const string LIBNAME = "__Internal";
  113. #else
  114. const string LIBNAME = "opencvforunity";
  115. #endif
  116. // C++: static Ptr_BIF cv::face::BIF::create(int num_bands = 8, int num_rotations = 12)
  117. [DllImport (LIBNAME)]
  118. private static extern IntPtr face_BIF_create_10 (int num_bands, int num_rotations);
  119. [DllImport (LIBNAME)]
  120. private static extern IntPtr face_BIF_create_11 (int num_bands);
  121. [DllImport (LIBNAME)]
  122. private static extern IntPtr face_BIF_create_12 ();
  123. // C++: int cv::face::BIF::getNumBands()
  124. [DllImport (LIBNAME)]
  125. private static extern int face_BIF_getNumBands_10 (IntPtr nativeObj);
  126. // C++: int cv::face::BIF::getNumRotations()
  127. [DllImport (LIBNAME)]
  128. private static extern int face_BIF_getNumRotations_10 (IntPtr nativeObj);
  129. // C++: void cv::face::BIF::compute(Mat image, Mat& features)
  130. [DllImport (LIBNAME)]
  131. private static extern void face_BIF_compute_10 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr features_nativeObj);
  132. // native support for java finalize()
  133. [DllImport (LIBNAME)]
  134. private static extern void face_BIF_delete (IntPtr nativeObj);
  135. }
  136. }