123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.UtilsModule;
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- namespace OpenCVForUnity.MlModule
- {
- // C++: class SVMSGD
- /**
- * *************************************************************************************\
- * Stochastic Gradient Descent SVM Classifier *
- * \***************************************************************************************
- */
- public class SVMSGD : StatModel
- {
- protected override void Dispose(bool disposing)
- {
- try
- {
- if (disposing)
- {
- }
- if (IsEnabledDispose)
- {
- if (nativeObj != IntPtr.Zero)
- ml_SVMSGD_delete(nativeObj);
- nativeObj = IntPtr.Zero;
- }
- }
- finally
- {
- base.Dispose(disposing);
- }
- }
- protected internal SVMSGD(IntPtr addr) : base(addr) { }
- // internal usage only
- public static new SVMSGD __fromPtr__(IntPtr addr) { return new SVMSGD(addr); }
- // C++: enum cv.ml.SVMSGD.MarginType
- public const int SOFT_MARGIN = 0;
- public const int HARD_MARGIN = 1;
- // C++: enum cv.ml.SVMSGD.SvmsgdType
- public const int SGD = 0;
- public const int ASGD = 1;
- //
- // C++: Mat cv::ml::SVMSGD::getWeights()
- //
- /**
- * return the weights of the trained model (decision function f(x) = weights * x + shift).
- */
- public Mat getWeights()
- {
- ThrowIfDisposed();
- return new Mat(DisposableObject.ThrowIfNullIntPtr(ml_SVMSGD_getWeights_10(nativeObj)));
- }
- //
- // C++: float cv::ml::SVMSGD::getShift()
- //
- /**
- * return the shift of the trained model (decision function f(x) = weights * x + shift).
- */
- public float getShift()
- {
- ThrowIfDisposed();
- return ml_SVMSGD_getShift_10(nativeObj);
- }
- //
- // C++: static Ptr_SVMSGD cv::ml::SVMSGD::create()
- //
- /**
- * Creates empty model.
- * Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to
- * find the best parameters for your problem or use setOptimalParameters() to set some default parameters.
- * return automatically generated
- */
- public static SVMSGD create()
- {
- return SVMSGD.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_SVMSGD_create_10()));
- }
- //
- // C++: static Ptr_SVMSGD cv::ml::SVMSGD::load(String filepath, String nodeName = String())
- //
- /**
- * Loads and creates a serialized SVMSGD from a file
- *
- * Use SVMSGD::save to serialize and store an SVMSGD to disk.
- * Load the SVMSGD 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 SVMSGD
- * param nodeName name of node containing the classifier
- * return automatically generated
- */
- public static SVMSGD load(string filepath, string nodeName)
- {
- return SVMSGD.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_SVMSGD_load_10(filepath, nodeName)));
- }
- /**
- * Loads and creates a serialized SVMSGD from a file
- *
- * Use SVMSGD::save to serialize and store an SVMSGD to disk.
- * Load the SVMSGD 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 SVMSGD
- * return automatically generated
- */
- public static SVMSGD load(string filepath)
- {
- return SVMSGD.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(ml_SVMSGD_load_11(filepath)));
- }
- //
- // C++: void cv::ml::SVMSGD::setOptimalParameters(int svmsgdType = SVMSGD::ASGD, int marginType = SVMSGD::SOFT_MARGIN)
- //
- /**
- * Function sets optimal parameters values for chosen SVM SGD model.
- * param svmsgdType is the type of SVMSGD classifier.
- * param marginType is the type of margin constraint.
- */
- public void setOptimalParameters(int svmsgdType, int marginType)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setOptimalParameters_10(nativeObj, svmsgdType, marginType);
- }
- /**
- * Function sets optimal parameters values for chosen SVM SGD model.
- * param svmsgdType is the type of SVMSGD classifier.
- */
- public void setOptimalParameters(int svmsgdType)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setOptimalParameters_11(nativeObj, svmsgdType);
- }
- /**
- * Function sets optimal parameters values for chosen SVM SGD model.
- */
- public void setOptimalParameters()
- {
- ThrowIfDisposed();
- ml_SVMSGD_setOptimalParameters_12(nativeObj);
- }
- //
- // C++: int cv::ml::SVMSGD::getSvmsgdType()
- //
- /**
- * SEE: setSvmsgdType
- * return automatically generated
- */
- public int getSvmsgdType()
- {
- ThrowIfDisposed();
- return ml_SVMSGD_getSvmsgdType_10(nativeObj);
- }
- //
- // C++: void cv::ml::SVMSGD::setSvmsgdType(int svmsgdType)
- //
- /**
- * getSvmsgdType SEE: getSvmsgdType
- * param svmsgdType automatically generated
- */
- public void setSvmsgdType(int svmsgdType)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setSvmsgdType_10(nativeObj, svmsgdType);
- }
- //
- // C++: int cv::ml::SVMSGD::getMarginType()
- //
- /**
- * SEE: setMarginType
- * return automatically generated
- */
- public int getMarginType()
- {
- ThrowIfDisposed();
- return ml_SVMSGD_getMarginType_10(nativeObj);
- }
- //
- // C++: void cv::ml::SVMSGD::setMarginType(int marginType)
- //
- /**
- * getMarginType SEE: getMarginType
- * param marginType automatically generated
- */
- public void setMarginType(int marginType)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setMarginType_10(nativeObj, marginType);
- }
- //
- // C++: float cv::ml::SVMSGD::getMarginRegularization()
- //
- /**
- * SEE: setMarginRegularization
- * return automatically generated
- */
- public float getMarginRegularization()
- {
- ThrowIfDisposed();
- return ml_SVMSGD_getMarginRegularization_10(nativeObj);
- }
- //
- // C++: void cv::ml::SVMSGD::setMarginRegularization(float marginRegularization)
- //
- /**
- * getMarginRegularization SEE: getMarginRegularization
- * param marginRegularization automatically generated
- */
- public void setMarginRegularization(float marginRegularization)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setMarginRegularization_10(nativeObj, marginRegularization);
- }
- //
- // C++: float cv::ml::SVMSGD::getInitialStepSize()
- //
- /**
- * SEE: setInitialStepSize
- * return automatically generated
- */
- public float getInitialStepSize()
- {
- ThrowIfDisposed();
- return ml_SVMSGD_getInitialStepSize_10(nativeObj);
- }
- //
- // C++: void cv::ml::SVMSGD::setInitialStepSize(float InitialStepSize)
- //
- /**
- * getInitialStepSize SEE: getInitialStepSize
- * param InitialStepSize automatically generated
- */
- public void setInitialStepSize(float InitialStepSize)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setInitialStepSize_10(nativeObj, InitialStepSize);
- }
- //
- // C++: float cv::ml::SVMSGD::getStepDecreasingPower()
- //
- /**
- * SEE: setStepDecreasingPower
- * return automatically generated
- */
- public float getStepDecreasingPower()
- {
- ThrowIfDisposed();
- return ml_SVMSGD_getStepDecreasingPower_10(nativeObj);
- }
- //
- // C++: void cv::ml::SVMSGD::setStepDecreasingPower(float stepDecreasingPower)
- //
- /**
- * getStepDecreasingPower SEE: getStepDecreasingPower
- * param stepDecreasingPower automatically generated
- */
- public void setStepDecreasingPower(float stepDecreasingPower)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setStepDecreasingPower_10(nativeObj, stepDecreasingPower);
- }
- //
- // C++: TermCriteria cv::ml::SVMSGD::getTermCriteria()
- //
- /**
- * SEE: setTermCriteria
- * return automatically generated
- */
- public TermCriteria getTermCriteria()
- {
- ThrowIfDisposed();
- double[] tmpArray = new double[3];
- ml_SVMSGD_getTermCriteria_10(nativeObj, tmpArray);
- TermCriteria retVal = new TermCriteria(tmpArray);
- return retVal;
- }
- //
- // C++: void cv::ml::SVMSGD::setTermCriteria(TermCriteria val)
- //
- /**
- * getTermCriteria SEE: getTermCriteria
- * param val automatically generated
- */
- public void setTermCriteria(TermCriteria val)
- {
- ThrowIfDisposed();
- ml_SVMSGD_setTermCriteria_10(nativeObj, val.type, val.maxCount, val.epsilon);
- }
- #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
- const string LIBNAME = "__Internal";
- #else
- const string LIBNAME = "opencvforunity";
- #endif
- // C++: Mat cv::ml::SVMSGD::getWeights()
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_SVMSGD_getWeights_10(IntPtr nativeObj);
- // C++: float cv::ml::SVMSGD::getShift()
- [DllImport(LIBNAME)]
- private static extern float ml_SVMSGD_getShift_10(IntPtr nativeObj);
- // C++: static Ptr_SVMSGD cv::ml::SVMSGD::create()
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_SVMSGD_create_10();
- // C++: static Ptr_SVMSGD cv::ml::SVMSGD::load(String filepath, String nodeName = String())
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_SVMSGD_load_10(string filepath, string nodeName);
- [DllImport(LIBNAME)]
- private static extern IntPtr ml_SVMSGD_load_11(string filepath);
- // C++: void cv::ml::SVMSGD::setOptimalParameters(int svmsgdType = SVMSGD::ASGD, int marginType = SVMSGD::SOFT_MARGIN)
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setOptimalParameters_10(IntPtr nativeObj, int svmsgdType, int marginType);
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setOptimalParameters_11(IntPtr nativeObj, int svmsgdType);
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setOptimalParameters_12(IntPtr nativeObj);
- // C++: int cv::ml::SVMSGD::getSvmsgdType()
- [DllImport(LIBNAME)]
- private static extern int ml_SVMSGD_getSvmsgdType_10(IntPtr nativeObj);
- // C++: void cv::ml::SVMSGD::setSvmsgdType(int svmsgdType)
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setSvmsgdType_10(IntPtr nativeObj, int svmsgdType);
- // C++: int cv::ml::SVMSGD::getMarginType()
- [DllImport(LIBNAME)]
- private static extern int ml_SVMSGD_getMarginType_10(IntPtr nativeObj);
- // C++: void cv::ml::SVMSGD::setMarginType(int marginType)
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setMarginType_10(IntPtr nativeObj, int marginType);
- // C++: float cv::ml::SVMSGD::getMarginRegularization()
- [DllImport(LIBNAME)]
- private static extern float ml_SVMSGD_getMarginRegularization_10(IntPtr nativeObj);
- // C++: void cv::ml::SVMSGD::setMarginRegularization(float marginRegularization)
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setMarginRegularization_10(IntPtr nativeObj, float marginRegularization);
- // C++: float cv::ml::SVMSGD::getInitialStepSize()
- [DllImport(LIBNAME)]
- private static extern float ml_SVMSGD_getInitialStepSize_10(IntPtr nativeObj);
- // C++: void cv::ml::SVMSGD::setInitialStepSize(float InitialStepSize)
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setInitialStepSize_10(IntPtr nativeObj, float InitialStepSize);
- // C++: float cv::ml::SVMSGD::getStepDecreasingPower()
- [DllImport(LIBNAME)]
- private static extern float ml_SVMSGD_getStepDecreasingPower_10(IntPtr nativeObj);
- // C++: void cv::ml::SVMSGD::setStepDecreasingPower(float stepDecreasingPower)
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setStepDecreasingPower_10(IntPtr nativeObj, float stepDecreasingPower);
- // C++: TermCriteria cv::ml::SVMSGD::getTermCriteria()
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_getTermCriteria_10(IntPtr nativeObj, double[] retVal);
- // C++: void cv::ml::SVMSGD::setTermCriteria(TermCriteria val)
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_setTermCriteria_10(IntPtr nativeObj, int val_type, int val_maxCount, double val_epsilon);
- // native support for java finalize()
- [DllImport(LIBNAME)]
- private static extern void ml_SVMSGD_delete(IntPtr nativeObj);
- }
- }
|