NormalBayesClassifier.cs 5.1 KB

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