EigenFaceRecognizer.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 EigenFaceRecognizer
  9. //javadoc: EigenFaceRecognizer
  10. public class EigenFaceRecognizer : BasicFaceRecognizer {
  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_EigenFaceRecognizer_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal EigenFaceRecognizer(IntPtr addr) : base(addr) { }
  29. // internal usage only
  30. public static new EigenFaceRecognizer __fromPtr__(IntPtr addr) { return new EigenFaceRecognizer(addr); }
  31. //
  32. // C++: static Ptr_EigenFaceRecognizer cv::face::EigenFaceRecognizer::create(int num_components = 0, double threshold = DBL_MAX)
  33. //
  34. //javadoc: EigenFaceRecognizer::create(num_components, threshold)
  35. public static EigenFaceRecognizer create(int num_components, double threshold) {
  36. #if (UNITY_ANDROID && !UNITY_EDITOR)
  37. EigenFaceRecognizer retVal = EigenFaceRecognizer.__fromPtr__(face_EigenFaceRecognizer_create_10(num_components, threshold));
  38. return retVal;
  39. #else
  40. return null;
  41. #endif
  42. }
  43. //javadoc: EigenFaceRecognizer::create(num_components)
  44. public static EigenFaceRecognizer create(int num_components) {
  45. #if (UNITY_ANDROID && !UNITY_EDITOR)
  46. EigenFaceRecognizer retVal = EigenFaceRecognizer.__fromPtr__(face_EigenFaceRecognizer_create_11(num_components));
  47. return retVal;
  48. #else
  49. return null;
  50. #endif
  51. }
  52. //javadoc: EigenFaceRecognizer::create()
  53. public static EigenFaceRecognizer create() {
  54. #if (UNITY_ANDROID && !UNITY_EDITOR)
  55. EigenFaceRecognizer retVal = EigenFaceRecognizer.__fromPtr__(face_EigenFaceRecognizer_create_12());
  56. return retVal;
  57. #else
  58. return null;
  59. #endif
  60. }
  61. #if (UNITY_ANDROID && !UNITY_EDITOR)
  62. const string LIBNAME = "opencvforunity";
  63. // C++: static Ptr_EigenFaceRecognizer cv::face::EigenFaceRecognizer::create(int num_components = 0, double threshold = DBL_MAX)
  64. [DllImport(LIBNAME)]
  65. private static extern IntPtr face_EigenFaceRecognizer_create_10(int num_components, double threshold);
  66. [DllImport(LIBNAME)]
  67. private static extern IntPtr face_EigenFaceRecognizer_create_11(int num_components);
  68. [DllImport(LIBNAME)]
  69. private static extern IntPtr face_EigenFaceRecognizer_create_12();
  70. // native support for java finalize()
  71. [DllImport(LIBNAME)]
  72. private static extern void face_EigenFaceRecognizer_delete(IntPtr nativeObj);
  73. #endif
  74. }
  75. }