NormalBayesClassifier.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.MlModule
  8. {
  9. // C++: class NormalBayesClassifier
  10. //javadoc: NormalBayesClassifier
  11. public class NormalBayesClassifier : StatModel
  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. ml_NormalBayesClassifier_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal NormalBayesClassifier (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new NormalBayesClassifier __fromPtr__ (IntPtr addr) { return new NormalBayesClassifier (addr); }
  34. //
  35. // C++: static Ptr_NormalBayesClassifier cv::ml::NormalBayesClassifier::create()
  36. //
  37. //javadoc: NormalBayesClassifier::create()
  38. public static NormalBayesClassifier create ()
  39. {
  40. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  41. NormalBayesClassifier retVal = NormalBayesClassifier.__fromPtr__(ml_NormalBayesClassifier_create_10());
  42. return retVal;
  43. #else
  44. return null;
  45. #endif
  46. }
  47. //
  48. // C++: static Ptr_NormalBayesClassifier cv::ml::NormalBayesClassifier::load(String filepath, String nodeName = String())
  49. //
  50. //javadoc: NormalBayesClassifier::load(filepath, nodeName)
  51. public static NormalBayesClassifier load (string filepath, string nodeName)
  52. {
  53. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  54. NormalBayesClassifier retVal = NormalBayesClassifier.__fromPtr__(ml_NormalBayesClassifier_load_10(filepath, nodeName));
  55. return retVal;
  56. #else
  57. return null;
  58. #endif
  59. }
  60. //javadoc: NormalBayesClassifier::load(filepath)
  61. public static NormalBayesClassifier load (string filepath)
  62. {
  63. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  64. NormalBayesClassifier retVal = NormalBayesClassifier.__fromPtr__(ml_NormalBayesClassifier_load_11(filepath));
  65. return retVal;
  66. #else
  67. return null;
  68. #endif
  69. }
  70. //
  71. // C++: float cv::ml::NormalBayesClassifier::predictProb(Mat inputs, Mat& outputs, Mat& outputProbs, int flags = 0)
  72. //
  73. //javadoc: NormalBayesClassifier::predictProb(inputs, outputs, outputProbs, flags)
  74. public float predictProb (Mat inputs, Mat outputs, Mat outputProbs, int flags)
  75. {
  76. ThrowIfDisposed ();
  77. if (inputs != null) inputs.ThrowIfDisposed ();
  78. if (outputs != null) outputs.ThrowIfDisposed ();
  79. if (outputProbs != null) outputProbs.ThrowIfDisposed ();
  80. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  81. float retVal = ml_NormalBayesClassifier_predictProb_10(nativeObj, inputs.nativeObj, outputs.nativeObj, outputProbs.nativeObj, flags);
  82. return retVal;
  83. #else
  84. return -1;
  85. #endif
  86. }
  87. //javadoc: NormalBayesClassifier::predictProb(inputs, outputs, outputProbs)
  88. public float predictProb (Mat inputs, Mat outputs, Mat outputProbs)
  89. {
  90. ThrowIfDisposed ();
  91. if (inputs != null) inputs.ThrowIfDisposed ();
  92. if (outputs != null) outputs.ThrowIfDisposed ();
  93. if (outputProbs != null) outputProbs.ThrowIfDisposed ();
  94. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  95. float retVal = ml_NormalBayesClassifier_predictProb_11(nativeObj, inputs.nativeObj, outputs.nativeObj, outputProbs.nativeObj);
  96. return retVal;
  97. #else
  98. return -1;
  99. #endif
  100. }
  101. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  102. const string LIBNAME = "__Internal";
  103. #else
  104. const string LIBNAME = "opencvforunity";
  105. #endif
  106. // C++: static Ptr_NormalBayesClassifier cv::ml::NormalBayesClassifier::create()
  107. [DllImport (LIBNAME)]
  108. private static extern IntPtr ml_NormalBayesClassifier_create_10 ();
  109. // C++: static Ptr_NormalBayesClassifier cv::ml::NormalBayesClassifier::load(String filepath, String nodeName = String())
  110. [DllImport (LIBNAME)]
  111. private static extern IntPtr ml_NormalBayesClassifier_load_10 (string filepath, string nodeName);
  112. [DllImport (LIBNAME)]
  113. private static extern IntPtr ml_NormalBayesClassifier_load_11 (string filepath);
  114. // C++: float cv::ml::NormalBayesClassifier::predictProb(Mat inputs, Mat& outputs, Mat& outputProbs, int flags = 0)
  115. [DllImport (LIBNAME)]
  116. private static extern float ml_NormalBayesClassifier_predictProb_10 (IntPtr nativeObj, IntPtr inputs_nativeObj, IntPtr outputs_nativeObj, IntPtr outputProbs_nativeObj, int flags);
  117. [DllImport (LIBNAME)]
  118. private static extern float ml_NormalBayesClassifier_predictProb_11 (IntPtr nativeObj, IntPtr inputs_nativeObj, IntPtr outputs_nativeObj, IntPtr outputProbs_nativeObj);
  119. // native support for java finalize()
  120. [DllImport (LIBNAME)]
  121. private static extern void ml_NormalBayesClassifier_delete (IntPtr nativeObj);
  122. }
  123. }