123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 |
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.UtilsModule;
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- namespace OpenCVForUnity.MlModule
- {
- // C++: class DTrees
- /**
- * The class represents a single decision tree or a collection of decision trees.
- *
- * The current public interface of the class allows user to train only a single decision tree, however
- * the class is capable of storing multiple decision trees and using them for prediction (by summing
- * responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost)
- * use this capability to implement decision tree ensembles.
- *
- * SEE: REF: ml_intro_trees
- */
- public class DTrees : StatModel
- {
- protected override void Dispose(bool disposing)
- {
- try
- {
- if (disposing)
- {
- }
- if (IsEnabledDispose)
- {
- if (nativeObj != IntPtr.Zero)
- ml_DTrees_delete(nativeObj);
- nativeObj = IntPtr.Zero;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- }
- protected internal DTrees(IntPtr addr) : base(addr) { }
- // internal usage only
- public static new DTrees __fromPtr__(IntPtr addr) { return new DTrees(addr); }
- // C++: enum cv.ml.DTrees.Flags
- public const int PREDICT_AUTO = 0;
- public const int PREDICT_SUM = (1 << 8);
- public const int PREDICT_MAX_VOTE = (2 << 8);
- public const int PREDICT_MASK = (3 << 8);
- //
- // C++: int cv::ml::DTrees::getMaxCategories()
- //
- /**
- * SEE: setMaxCategories
- * return automatically generated
- */
- public int getMaxCategories()
- {
- ThrowIfDisposed();
- return ml_DTrees_getMaxCategories_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setMaxCategories(int val)
- //
- /**
- * getMaxCategories SEE: getMaxCategories
- * param val automatically generated
- */
- public void setMaxCategories(int val)
- {
- ThrowIfDisposed();
- ml_DTrees_setMaxCategories_10(nativeObj, val);
- }
- //
- // C++: int cv::ml::DTrees::getMaxDepth()
- //
- /**
- * SEE: setMaxDepth
- * return automatically generated
- */
- public int getMaxDepth()
- {
- ThrowIfDisposed();
- return ml_DTrees_getMaxDepth_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setMaxDepth(int val)
- //
- /**
- * getMaxDepth SEE: getMaxDepth
- * param val automatically generated
- */
- public void setMaxDepth(int val)
- {
- ThrowIfDisposed();
- ml_DTrees_setMaxDepth_10(nativeObj, val);
- }
- //
- // C++: int cv::ml::DTrees::getMinSampleCount()
- //
- /**
- * SEE: setMinSampleCount
- * return automatically generated
- */
- public int getMinSampleCount()
- {
- ThrowIfDisposed();
- return ml_DTrees_getMinSampleCount_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setMinSampleCount(int val)
- //
- /**
- * getMinSampleCount SEE: getMinSampleCount
- * param val automatically generated
- */
- public void setMinSampleCount(int val)
- {
- ThrowIfDisposed();
- ml_DTrees_setMinSampleCount_10(nativeObj, val);
- }
- //
- // C++: int cv::ml::DTrees::getCVFolds()
- //
- /**
- * SEE: setCVFolds
- * return automatically generated
- */
- public int getCVFolds()
- {
- ThrowIfDisposed();
- return ml_DTrees_getCVFolds_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setCVFolds(int val)
- //
- /**
- * getCVFolds SEE: getCVFolds
- * param val automatically generated
- */
- public void setCVFolds(int val)
- {
- ThrowIfDisposed();
- ml_DTrees_setCVFolds_10(nativeObj, val);
- }
- //
- // C++: bool cv::ml::DTrees::getUseSurrogates()
- //
- /**
- * SEE: setUseSurrogates
- * return automatically generated
- */
- public bool getUseSurrogates()
- {
- ThrowIfDisposed();
- return ml_DTrees_getUseSurrogates_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setUseSurrogates(bool val)
- //
- /**
- * getUseSurrogates SEE: getUseSurrogates
- * param val automatically generated
- */
- public void setUseSurrogates(bool val)
- {
- ThrowIfDisposed();
- ml_DTrees_setUseSurrogates_10(nativeObj, val);
- }
- //
- // C++: bool cv::ml::DTrees::getUse1SERule()
- //
- /**
- * SEE: setUse1SERule
- * return automatically generated
- */
- public bool getUse1SERule()
- {
- ThrowIfDisposed();
- return ml_DTrees_getUse1SERule_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setUse1SERule(bool val)
- //
- /**
- * getUse1SERule SEE: getUse1SERule
- * param val automatically generated
- */
- public void setUse1SERule(bool val)
- {
- ThrowIfDisposed();
- ml_DTrees_setUse1SERule_10(nativeObj, val);
- }
- //
- // C++: bool cv::ml::DTrees::getTruncatePrunedTree()
- //
- /**
- * SEE: setTruncatePrunedTree
- * return automatically generated
- */
- public bool getTruncatePrunedTree()
- {
- ThrowIfDisposed();
- return ml_DTrees_getTruncatePrunedTree_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setTruncatePrunedTree(bool val)
- //
- /**
- * getTruncatePrunedTree SEE: getTruncatePrunedTree
- * param val automatically generated
- */
- public void setTruncatePrunedTree(bool val)
- {
- ThrowIfDisposed();
- ml_DTrees_setTruncatePrunedTree_10(nativeObj, val);
- }
- //
- // C++: float cv::ml::DTrees::getRegressionAccuracy()
- //
- /**
- * SEE: setRegressionAccuracy
- * return automatically generated
- */
- public float getRegressionAccuracy()
- {
- ThrowIfDisposed();
- return ml_DTrees_getRegressionAccuracy_10(nativeObj);
- }
- //
- // C++: void cv::ml::DTrees::setRegressionAccuracy(float val)
- //
- /**
- * getRegressionAccuracy SEE: getRegressionAccuracy
- * param val automatically generated
- */
- public void setRegressionAccuracy(float val)
- {
- ThrowIfDisposed();
- ml_DTrees_setRegressionAccuracy_10(nativeObj, val);
- }
- //
- // C++: Mat cv::ml::DTrees::getPriors()
- //
- /**
- * SEE: setPriors
- * return automatically generated
- */
- public Mat getPriors()
- {
- ThrowIfDisposed();
- return new Mat(DisposableObject.ThrowIfNullIntPtr(ml_DTrees_getPriors_10(nativeObj)));
- }
- //
- // C++: void cv::ml::DTrees::setPriors(Mat val)
- //
- /**
- * getPriors SEE: getPriors
- * param val automatically generated
- */
- public void setPriors(Mat val)
- {
- ThrowIfDisposed();
- if (val != null) val.ThrowIfDisposed();
- ml_DTrees_setPriors_10(nativeObj, val.nativeObj);
- }
- //
- // C++: static Ptr_DTrees cv::ml::DTrees::create()
- //
- /**
- * Creates the empty model
- *
- * The static method creates empty decision tree with the specified parameters. It should be then
- * trained using train method (see StatModel::train). Alternatively, you can load the model from
- * file using Algorithm::load<DTrees>(filename).
- * return automatically generated
- */
- public static DTrees create()
- {
- return DTrees.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_DTrees_create_10()));
- }
- //
- // C++: static Ptr_DTrees cv::ml::DTrees::load(String filepath, String nodeName = String())
- //
- /**
- * Loads and creates a serialized DTrees from a file
- *
- * Use DTree::save to serialize and store an DTree to disk.
- * Load the DTree from this file again, by calling this function with the path to the file.
- * Optionally specify the node for the file containing the classifier
- *
- * param filepath path to serialized DTree
- * param nodeName name of node containing the classifier
- * return automatically generated
- */
- public static DTrees load(string filepath, string nodeName)
- {
- return DTrees.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_DTrees_load_10(filepath, nodeName)));
- }
- /**
- * Loads and creates a serialized DTrees from a file
- *
- * Use DTree::save to serialize and store an DTree to disk.
- * Load the DTree from this file again, by calling this function with the path to the file.
- * Optionally specify the node for the file containing the classifier
- *
- * param filepath path to serialized DTree
- * return automatically generated
- */
- public static DTrees load(string filepath)
- {
- return DTrees.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_DTrees_load_11(filepath)));
- }
- #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
- const string LIBNAME = "__Internal";
- #else
- const string LIBNAME = "opencvforunity";
- #endif
- // C++: int cv::ml::DTrees::getMaxCategories()
- [DllImport(LIBNAME)]
- private static extern int ml_DTrees_getMaxCategories_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setMaxCategories(int val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setMaxCategories_10(IntPtr nativeObj, int val);
- // C++: int cv::ml::DTrees::getMaxDepth()
- [DllImport(LIBNAME)]
- private static extern int ml_DTrees_getMaxDepth_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setMaxDepth(int val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setMaxDepth_10(IntPtr nativeObj, int val);
- // C++: int cv::ml::DTrees::getMinSampleCount()
- [DllImport(LIBNAME)]
- private static extern int ml_DTrees_getMinSampleCount_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setMinSampleCount(int val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setMinSampleCount_10(IntPtr nativeObj, int val);
- // C++: int cv::ml::DTrees::getCVFolds()
- [DllImport(LIBNAME)]
- private static extern int ml_DTrees_getCVFolds_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setCVFolds(int val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setCVFolds_10(IntPtr nativeObj, int val);
- // C++: bool cv::ml::DTrees::getUseSurrogates()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool ml_DTrees_getUseSurrogates_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setUseSurrogates(bool val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setUseSurrogates_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool val);
- // C++: bool cv::ml::DTrees::getUse1SERule()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool ml_DTrees_getUse1SERule_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setUse1SERule(bool val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setUse1SERule_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool val);
- // C++: bool cv::ml::DTrees::getTruncatePrunedTree()
- [DllImport(LIBNAME)]
- [return: MarshalAs(UnmanagedType.U1)]
- private static extern bool ml_DTrees_getTruncatePrunedTree_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setTruncatePrunedTree(bool val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setTruncatePrunedTree_10(IntPtr nativeObj, [MarshalAs(UnmanagedType.U1)] bool val);
- // C++: float cv::ml::DTrees::getRegressionAccuracy()
- [DllImport(LIBNAME)]
- private static extern float ml_DTrees_getRegressionAccuracy_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setRegressionAccuracy(float val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setRegressionAccuracy_10(IntPtr nativeObj, float val);
- // C++: Mat cv::ml::DTrees::getPriors()
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_DTrees_getPriors_10(IntPtr nativeObj);
- // C++: void cv::ml::DTrees::setPriors(Mat val)
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_setPriors_10(IntPtr nativeObj, IntPtr val_nativeObj);
- // C++: static Ptr_DTrees cv::ml::DTrees::create()
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_DTrees_create_10();
- // C++: static Ptr_DTrees cv::ml::DTrees::load(String filepath, String nodeName = String())
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_DTrees_load_10(string filepath, string nodeName);
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_DTrees_load_11(string filepath);
- // native support for java finalize()
- [DllImport(LIBNAME)]
- private static extern void ml_DTrees_delete(IntPtr nativeObj);
- }
- }
|