OpenCV for Unity  2.6.0
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.9.0/index.html ) for the details of the argument of the method.
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
OpenCVForUnity.MlModule.StatModel Class Reference

Base class for statistical models in OpenCV ML. More...

Inheritance diagram for OpenCVForUnity.MlModule.StatModel:
OpenCVForUnity.CoreModule.Algorithm OpenCVForUnity.DisposableOpenCVObject OpenCVForUnity.DisposableObject OpenCVForUnity.MlModule.ANN_MLP OpenCVForUnity.MlModule.DTrees OpenCVForUnity.MlModule.EM OpenCVForUnity.MlModule.KNearest OpenCVForUnity.MlModule.LogisticRegression OpenCVForUnity.MlModule.NormalBayesClassifier OpenCVForUnity.MlModule.SVM OpenCVForUnity.MlModule.SVMSGD

Public Member Functions

int getVarCount ()
 Returns the number of variables in training samples. More...
 
override bool empty ()
 Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. More...
 
bool isTrained ()
 Returns true if the model is trained. More...
 
bool isClassifier ()
 Returns true if the model is classifier. More...
 
bool train (TrainData trainData, int flags)
 Trains the statistical model. More...
 
bool train (TrainData trainData)
 Trains the statistical model. More...
 
bool train (Mat samples, int layout, Mat responses)
 Trains the statistical model. More...
 
float calcError (TrainData data, bool test, Mat resp)
 Computes error on the training or test dataset. More...
 
virtual float predict (Mat samples, Mat results, int flags)
 Predicts response(s) for the provided sample(s) More...
 
virtual float predict (Mat samples, Mat results)
 Predicts response(s) for the provided sample(s) More...
 
virtual float predict (Mat samples)
 Predicts response(s) for the provided sample(s) More...
 
- Public Member Functions inherited from OpenCVForUnity.CoreModule.Algorithm
IntPtr getNativeObjAddr ()
 
virtual void clear ()
 Clears the algorithm state. More...
 
void save (string filename)
 
virtual string getDefaultName ()
 
- Public Member Functions inherited from OpenCVForUnity.DisposableObject
void Dispose ()
 
void ThrowIfDisposed ()
 

Static Public Member Functions

static new StatModel __fromPtr__ (IntPtr addr)
 
- Static Public Member Functions inherited from OpenCVForUnity.CoreModule.Algorithm
static Algorithm __fromPtr__ (IntPtr addr)
 
- Static Public Member Functions inherited from OpenCVForUnity.DisposableObject
static IntPtr ThrowIfNullIntPtr (IntPtr ptr)
 

Public Attributes

const int UPDATE_MODEL = 1
 
const int RAW_OUTPUT = 1
 
const int COMPRESSED_INPUT = 2
 
const int PREPROCESSED_INPUT = 4
 

Protected Member Functions

override void Dispose (bool disposing)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableOpenCVObject
 DisposableOpenCVObject ()
 
 DisposableOpenCVObject (IntPtr ptr)
 
 DisposableOpenCVObject (bool isEnabledDispose)
 
 DisposableOpenCVObject (IntPtr ptr, bool isEnabledDispose)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableObject
 DisposableObject ()
 
 DisposableObject (bool isEnabledDispose)
 

Additional Inherited Members

- Properties inherited from OpenCVForUnity.DisposableObject
bool IsDisposed [get, protected set]
 
bool IsEnabledDispose [get, set]
 

Detailed Description

Base class for statistical models in OpenCV ML.

Member Function Documentation

◆ __fromPtr__()

static new StatModel OpenCVForUnity.MlModule.StatModel.__fromPtr__ ( IntPtr  addr)
static

◆ calcError()

float OpenCVForUnity.MlModule.StatModel.calcError ( TrainData  data,
bool  test,
Mat  resp 
)

Computes error on the training or test dataset.

Parameters
datathe training data
testif true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.
respthe optional output responses.
The method uses StatModel::predict to compute the error. For regression models the error is
computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).

◆ Dispose()

override void OpenCVForUnity.MlModule.StatModel.Dispose ( bool  disposing)
protectedvirtual

◆ empty()

override bool OpenCVForUnity.MlModule.StatModel.empty ( )
virtual

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read.

Reimplemented from OpenCVForUnity.CoreModule.Algorithm.

◆ getVarCount()

int OpenCVForUnity.MlModule.StatModel.getVarCount ( )

Returns the number of variables in training samples.

◆ isClassifier()

bool OpenCVForUnity.MlModule.StatModel.isClassifier ( )

Returns true if the model is classifier.

◆ isTrained()

bool OpenCVForUnity.MlModule.StatModel.isTrained ( )

Returns true if the model is trained.

◆ predict() [1/3]

virtual float OpenCVForUnity.MlModule.StatModel.predict ( Mat  samples,
Mat  results,
int  flags 
)
virtual

Predicts response(s) for the provided sample(s)

Parameters
samplesThe input samples, floating-point matrix
resultsThe optional output matrix of results.
flagsThe optional flags, model-dependent. See cv::ml::StatModel::Flags.

Reimplemented in OpenCVForUnity.MlModule.LogisticRegression, and OpenCVForUnity.MlModule.EM.

◆ predict() [2/3]

virtual float OpenCVForUnity.MlModule.StatModel.predict ( Mat  samples,
Mat  results 
)
virtual

Predicts response(s) for the provided sample(s)

Parameters
samplesThe input samples, floating-point matrix
resultsThe optional output matrix of results.
flagsThe optional flags, model-dependent. See cv::ml::StatModel::Flags.

Reimplemented in OpenCVForUnity.MlModule.LogisticRegression, and OpenCVForUnity.MlModule.EM.

◆ predict() [3/3]

virtual float OpenCVForUnity.MlModule.StatModel.predict ( Mat  samples)
virtual

Predicts response(s) for the provided sample(s)

Parameters
samplesThe input samples, floating-point matrix
resultsThe optional output matrix of results.
flagsThe optional flags, model-dependent. See cv::ml::StatModel::Flags.

Reimplemented in OpenCVForUnity.MlModule.LogisticRegression, and OpenCVForUnity.MlModule.EM.

◆ train() [1/3]

bool OpenCVForUnity.MlModule.StatModel.train ( TrainData  trainData,
int  flags 
)

Trains the statistical model.

Parameters
trainDatatraining data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.
flagsoptional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).

◆ train() [2/3]

bool OpenCVForUnity.MlModule.StatModel.train ( TrainData  trainData)

Trains the statistical model.

Parameters
trainDatatraining data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.
flagsoptional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).

◆ train() [3/3]

bool OpenCVForUnity.MlModule.StatModel.train ( Mat  samples,
int  layout,
Mat  responses 
)

Trains the statistical model.

Parameters
samplestraining samples
layoutSee ml::SampleTypes.
responsesvector of responses associated with the training samples.

Member Data Documentation

◆ COMPRESSED_INPUT

const int OpenCVForUnity.MlModule.StatModel.COMPRESSED_INPUT = 2

◆ PREPROCESSED_INPUT

const int OpenCVForUnity.MlModule.StatModel.PREPROCESSED_INPUT = 4

◆ RAW_OUTPUT

const int OpenCVForUnity.MlModule.StatModel.RAW_OUTPUT = 1

◆ UPDATE_MODEL

const int OpenCVForUnity.MlModule.StatModel.UPDATE_MODEL = 1

The documentation for this class was generated from the following file: