trainE method

(bool, Mat, Mat, Mat) trainE(
  1. Mat samples,
  2. Mat means0, {
  3. VecMat? covs0,
  4. Mat? weights0,
})

Like trainEM, starting with the Expectation step from the initial means means0 and the optional initial covariance matrices covs0 and weights weights0.

Unless both covs0 and weights0 are given, OpenCV initializes the model with k-means seeded by means0, so the order of the resulting components may differ from means0.

Implementation

(bool, Mat logLikelihoods, Mat labels, Mat probs) trainE(
  Mat samples,
  Mat means0, {
  VecMat? covs0,
  Mat? weights0,
}) {
  final covs = covs0 ?? VecMat();
  final weights = weights0 ?? Mat.empty();
  try {
    return _train(
      (l, lb, pr, p) => cml.cv_ml_EM_trainE(
        ref,
        samples.ref,
        means0.ref,
        covs.ref,
        weights.ref,
        l,
        lb,
        pr,
        p,
        ffi.nullptr,
      ),
    );
  } finally {
    if (covs0 == null) covs.dispose();
    if (weights0 == null) weights.dispose();
  }
}