EM class
The class implements the Expectation Maximization algorithm. https://docs.opencv.org/4.x/d1/dfb/classcv_1_1ml_1_1EM.html
Constructors
- EM.create()
-
Creates an empty model. Use one of the train methods to train it, or EM.load.
factory
- EM.fromPointer(EMPtr ptr, [bool attach = true])
-
factory
- EM.load(String filepath)
-
Loads a model saved with save from
filepath. Throws CvException when the file does not hold a valid model.factory - EM.loadFromString(String strModel, {String objname = ''})
-
Loads a model from the content of a file saved with save (e.g. a Flutter asset).
factory
Properties
- clustersNumber ↔ int
-
The number of mixture components in the Gaussian mixture model, must be >= 1.
getter/setter pair
- covarianceMatrixType ↔ int
-
Constraint on covariance matrices, one of the
COV_MAT_*types.getter/setter pair - covs → VecMat
-
The covariance matrices of the mixture components, one dims x dims Mat per component.
no setter
- defaultName → String
-
The name used when saving the model,
opencv_ml_em.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isClassifier → bool
-
Whether the model is a classifier (false for a regressor).
no setter
- isDisposed → bool
-
Whether this object has been disposed.
no setterinherited
- isEmpty → bool
-
no setter
- isTrained → bool
-
no setter
- means → Mat
-
The cluster centers (means of the Gaussian mixture), clustersNumber x dims.
no setter
-
props
→ List<
Object?> -
no setterinherited
-
ptr
↔ Pointer<
EM> -
getter/setter pairinherited
- ref → EM
-
A view of the native memory behind ptr, not a copy.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- termCriteria ↔ TermCriteria
-
Termination criteria of the training algorithm.
getter/setter pair
- varCount → int
-
Number of variables in training samples.
no setter
- weights → Mat
-
The weights of the mixtures, a 1 x clustersNumber vector.
no setter
Methods
-
calcError(
TrainData data, bool test) → (double, Mat) -
Computes the error on the training (
testfalse) or test (testtrue) part ofdata. -
calcErrorAsync(
TrainData data, bool test) → Future< (double, Mat)> -
clear(
) → void - Clears the model, it becomes untrained.
-
dispose(
) → void -
Releases the underlying native resources. Idempotent: calling it more
than once is safe, but the object must not be used after dispose.
inherited
-
freeNative(
) → void -
Frees the native resources owned by this object. Subclasses implement the
concrete free logic here; callers must use dispose instead.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
predict(
Mat samples, {int flags = 0}) → Mat -
Predicts the response for each row of
samples, one row of the returned Mat per sample. -
predict2(
Mat sample) → (double, int, Mat) -
Predicts the likelihood logarithm and the most probable mixture component of
sample(a single row), and the posterior probability of each component. -
predict2Async(
Mat sample) → Future< (double, int, Mat)> -
predictAsync(
Mat samples, {int flags = 0}) → Future< Mat> -
save(
String filename) → void -
Saves the model to
filename(.xml, .yml or .json). -
toString(
) → String -
A string representation of this object.
inherited
-
train(
Mat samples, int layout, Mat responses) → bool -
Trains the model on
samples(CV_32F, one sample per row for ROW_SAMPLE). -
trainAsync(
Mat samples, int layout, Mat responses) → Future< bool> -
trainE(
Mat samples, Mat means0, {VecMat? covs0, Mat? weights0}) → (bool, Mat, Mat, Mat) -
Like trainEM, starting with the Expectation step from the initial means
means0and the optional initial covariance matricescovs0and weightsweights0. -
trainEAsync(
Mat samples, Mat means0, {VecMat? covs0, Mat? weights0}) → Future< (bool, Mat, Mat, Mat)> -
trainEM(
Mat samples) → (bool, Mat, Mat, Mat) -
Estimates the Gaussian mixture parameters from
samples, starting with the Expectation step from initial values computed by k-means. -
trainEMAsync(
Mat samples) → Future< (bool, Mat, Mat, Mat)> -
trainM(
Mat samples, Mat probs0) → (bool, Mat, Mat, Mat) -
Like trainEM, starting with the Maximization step from the initial probabilities
probs0. -
trainMAsync(
Mat samples, Mat probs0) → Future< (bool, Mat, Mat, Mat)> -
trainWithData(
TrainData data, {int flags = 0}) → bool -
Trains the model on
data,flagsmay be StatModel.UPDATE_MODEL or model-specific flags. -
trainWithDataAsync(
TrainData data, {int flags = 0}) → Future< bool>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- finalizer → NativeFinalizer
-
final
Constants
- COV_MAT_DEFAULT → const int
- COV_MAT_DIAGONAL → const int
- COV_MAT_GENERIC → const int
- COV_MAT_SPHERICAL → const int
- DEFAULT_MAX_ITERS → const int
- DEFAULT_NCLUSTERS → const int
- START_AUTO_STEP → const int
- START_E_STEP → const int
- START_M_STEP → const int