kmeansByPointsAsync function
        
Future<(double, Mat, Mat)> 
kmeansByPointsAsync(
    
- VecPoint2f pts,
- int K,
- InputOutputArray bestLabels,
- (int, int, double) criteria,
- int attempts,
- int flags, {
- OutputArray? centers,
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, {
  OutputArray? centers,
}) async {
  centers ??= Mat.empty();
  final p = calloc<ffi.Double>();
  return cvRunAsync0(
    (callback) => ccore.cv_kmeans_points(
      pts.ref,
      K,
      bestLabels.ref,
      TermCriteria.fromRecord(criteria).ref,
      attempts,
      flags,
      centers!.ref,
      p,
      callback,
    ),
    (c) {
      final rval = p.value;
      calloc.free(p);
      return c.complete((rval, bestLabels, centers!));
    },
  );
}