BIF.cs 4.3 KB

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