kmeansByPointsAsync function

Future<(double, Mat, Mat)> kmeansByPointsAsync(
  1. VecPoint2f pts,
  2. int K,
  3. InputOutputArray bestLabels,
  4. (int, int, double) criteria,
  5. int attempts,
  6. int flags,
)

KMeansPoints finds centers of clusters and groups input samples around the clusters.

For further details, please see: https://docs.opencv.org/master/d5/d38/group__core__cluster.html#ga9a34dc06c6ec9460e90860f15bcd2f88

Implementation

Future<(double rval, Mat bestLabels, Mat centers)> kmeansByPointsAsync(
  VecPoint2f pts,
  int K,
  InputOutputArray bestLabels,
  (int, int, double) criteria,
  int attempts,
  int flags,
) async =>
    cvRunAsync2(
        (callback) => cffi.core_KMeans_Points_Async(
              pts.ref,
              K,
              bestLabels.ref,
              criteria.cvd.ref,
              attempts,
              flags,
              callback,
            ), (completer, p, p1) {
      final rval = p.cast<ffi.Double>().value;
      calloc.free(p);
      completer.complete((rval, bestLabels, Mat.fromPointer(p1.cast<cvg.Mat>())));
    });