123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
-
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.UtilsModule;
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- namespace OpenCVForUnity.MlModule {
- // C++: class StatModel
- //javadoc: StatModel
- public class StatModel : Algorithm {
- protected override void Dispose(bool disposing) {
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- try {
- if (disposing) {
- }
- if (IsEnabledDispose) {
- if (nativeObj != IntPtr.Zero)
- ml_StatModel_delete(nativeObj);
- nativeObj = IntPtr.Zero;
- }
- } finally {
- base.Dispose(disposing);
- }
- #else
- return;
- #endif
- }
- protected internal StatModel(IntPtr addr)
- : base(addr) {
- }
- // internal usage only
- public static new StatModel __fromPtr__(IntPtr addr) {
- return new StatModel(addr);
- }
- // C++: enum Flags
- public const int UPDATE_MODEL = 1;
- public const int RAW_OUTPUT = 1;
- public const int COMPRESSED_INPUT = 2;
- public const int PREPROCESSED_INPUT = 4;
- //
- // C++: bool cv::ml::StatModel::empty()
- //
- //javadoc: StatModel::empty()
- public override bool empty() {
- ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- bool retVal = ml_StatModel_empty_10(nativeObj);
- return retVal;
- #else
- return false;
- #endif
- }
- //
- // C++: bool cv::ml::StatModel::isClassifier()
- //
- //javadoc: StatModel::isClassifier()
- public bool isClassifier() {
- ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- bool retVal = ml_StatModel_isClassifier_10(nativeObj);
- return retVal;
- #else
- return false;
- #endif
- }
- //
- // C++: bool cv::ml::StatModel::isTrained()
- //
- //javadoc: StatModel::isTrained()
- public bool isTrained() {
- ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- bool retVal = ml_StatModel_isTrained_10(nativeObj);
- return retVal;
- #else
- return false;
- #endif
- }
- //
- // C++: bool cv::ml::StatModel::train(Mat samples, int layout, Mat responses)
- //
- //javadoc: StatModel::train(samples, layout, responses)
- public bool train(Mat samples, int layout, Mat responses) {
- ThrowIfDisposed();
- if (samples != null)
- samples.ThrowIfDisposed();
- if (responses != null)
- responses.ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- bool retVal = ml_StatModel_train_10(nativeObj, samples.nativeObj, layout, responses.nativeObj);
- return retVal;
- #else
- return false;
- #endif
- }
- //
- // C++: bool cv::ml::StatModel::train(Ptr_TrainData trainData, int flags = 0)
- //
- //javadoc: StatModel::train(trainData, flags)
- public bool train(TrainData trainData, int flags) {
- ThrowIfDisposed();
- if (trainData != null)
- trainData.ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- bool retVal = ml_StatModel_train_11(nativeObj, trainData.getNativeObjAddr(), flags);
- return retVal;
- #else
- return false;
- #endif
- }
- //javadoc: StatModel::train(trainData)
- public bool train(TrainData trainData) {
- ThrowIfDisposed();
- if (trainData != null)
- trainData.ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- bool retVal = ml_StatModel_train_12(nativeObj, trainData.getNativeObjAddr());
- return retVal;
- #else
- return false;
- #endif
- }
- //
- // C++: float cv::ml::StatModel::calcError(Ptr_TrainData data, bool test, Mat& resp)
- //
- //javadoc: StatModel::calcError(data, test, resp)
- public float calcError(TrainData data, bool test, Mat resp) {
- ThrowIfDisposed();
- if (data != null)
- data.ThrowIfDisposed();
- if (resp != null)
- resp.ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- float retVal = ml_StatModel_calcError_10(nativeObj, data.getNativeObjAddr(), test, resp.nativeObj);
- return retVal;
- #else
- return -1;
- #endif
- }
- //
- // C++: float cv::ml::StatModel::predict(Mat samples, Mat& results = Mat(), int flags = 0)
- //
- //javadoc: StatModel::predict(samples, results, flags)
- public virtual float predict(Mat samples, Mat results, int flags) {
- ThrowIfDisposed();
- if (samples != null)
- samples.ThrowIfDisposed();
- if (results != null)
- results.ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- float retVal = ml_StatModel_predict_10(nativeObj, samples.nativeObj, results.nativeObj, flags);
- return retVal;
- #else
- return -1;
- #endif
- }
- //javadoc: StatModel::predict(samples, results)
- public virtual float predict(Mat samples, Mat results) {
- ThrowIfDisposed();
- if (samples != null)
- samples.ThrowIfDisposed();
- if (results != null)
- results.ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- float retVal = ml_StatModel_predict_11(nativeObj, samples.nativeObj, results.nativeObj);
- return retVal;
- #else
- return -1;
- #endif
- }
- //javadoc: StatModel::predict(samples)
- public virtual float predict(Mat samples) {
- ThrowIfDisposed();
- if (samples != null)
- samples.ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- float retVal = ml_StatModel_predict_12(nativeObj, samples.nativeObj);
- return retVal;
- #else
- return -1;
- #endif
- }
- //
- // C++: int cv::ml::StatModel::getVarCount()
- //
- //javadoc: StatModel::getVarCount()
- public int getVarCount() {
- ThrowIfDisposed();
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- int retVal = ml_StatModel_getVarCount_10(nativeObj);
- return retVal;
- #else
- return -1;
- #endif
- }
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- const string LIBNAME = "opencvforunity";
- // C++: bool cv::ml::StatModel::empty()
- [DllImport(LIBNAME)]
- private static extern bool ml_StatModel_empty_10(IntPtr nativeObj);
- // C++: bool cv::ml::StatModel::isClassifier()
- [DllImport(LIBNAME)]
- private static extern bool ml_StatModel_isClassifier_10(IntPtr nativeObj);
- // C++: bool cv::ml::StatModel::isTrained()
- [DllImport(LIBNAME)]
- private static extern bool ml_StatModel_isTrained_10(IntPtr nativeObj);
- // C++: bool cv::ml::StatModel::train(Mat samples, int layout, Mat responses)
- [DllImport(LIBNAME)]
- private static extern bool ml_StatModel_train_10(IntPtr nativeObj, IntPtr samples_nativeObj, int layout, IntPtr responses_nativeObj);
- // C++: bool cv::ml::StatModel::train(Ptr_TrainData trainData, int flags = 0)
- [DllImport(LIBNAME)]
- private static extern bool ml_StatModel_train_11(IntPtr nativeObj, IntPtr trainData_nativeObj, int flags);
- [DllImport(LIBNAME)]
- private static extern bool ml_StatModel_train_12(IntPtr nativeObj, IntPtr trainData_nativeObj);
- // C++: float cv::ml::StatModel::calcError(Ptr_TrainData data, bool test, Mat& resp)
- [DllImport(LIBNAME)]
- private static extern float ml_StatModel_calcError_10(IntPtr nativeObj, IntPtr data_nativeObj, bool test, IntPtr resp_nativeObj);
- // C++: float cv::ml::StatModel::predict(Mat samples, Mat& results = Mat(), int flags = 0)
- [DllImport(LIBNAME)]
- private static extern float ml_StatModel_predict_10(IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr results_nativeObj, int flags);
- [DllImport(LIBNAME)]
- private static extern float ml_StatModel_predict_11(IntPtr nativeObj, IntPtr samples_nativeObj, IntPtr results_nativeObj);
- [DllImport(LIBNAME)]
- private static extern float ml_StatModel_predict_12(IntPtr nativeObj, IntPtr samples_nativeObj);
- // C++: int cv::ml::StatModel::getVarCount()
- [DllImport(LIBNAME)]
- private static extern int ml_StatModel_getVarCount_10(IntPtr nativeObj);
- // native support for java finalize()
- [DllImport(LIBNAME)]
- private static extern void ml_StatModel_delete(IntPtr nativeObj);
- #endif
- }
- }
|