OpenCV for Unity 2.6.5
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.MlModule.StatModel Class Reference

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

Public Member Functions

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

Static Public Attributes

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

Protected Member Functions

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

Additional Inherited Members

- Package Functions inherited from OpenCVForUnity.CoreModule.Algorithm
- Package Attributes inherited from OpenCVForUnity.DisposableOpenCVObject
- 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)
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.EM, and OpenCVForUnity.MlModule.LogisticRegression.

◆ 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.EM, and OpenCVForUnity.MlModule.LogisticRegression.

◆ predict() [3/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.EM, and OpenCVForUnity.MlModule.LogisticRegression.

◆ train() [1/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.

◆ 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 ( 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).

Member Data Documentation

◆ COMPRESSED_INPUT

const int OpenCVForUnity.MlModule.StatModel.COMPRESSED_INPUT = 2
static

◆ PREPROCESSED_INPUT

const int OpenCVForUnity.MlModule.StatModel.PREPROCESSED_INPUT = 4
static

◆ RAW_OUTPUT

const int OpenCVForUnity.MlModule.StatModel.RAW_OUTPUT = 1
static

◆ UPDATE_MODEL

const int OpenCVForUnity.MlModule.StatModel.UPDATE_MODEL = 1
static

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