connectedComponentsWithStatsAsync function

Future<(int, Mat, Mat, Mat)> connectedComponentsWithStatsAsync(
  1. Mat src,
  2. int connectivity,
  3. int ltype,
  4. int ccltype,
)

ConnectedComponentsWithStats computes the connected components labeled image of boolean image and also produces a statistics output for each label.

For further details, please see: https:///docs.opencv.org/master/d3/dc0/group__imgproc__shape.html#ga107a78bf7cd25dec05fb4dfc5c9e765f

Implementation

Future<(int rval, Mat labels, Mat stats, Mat centroids)> connectedComponentsWithStatsAsync(
  Mat src,
  int connectivity,
  int ltype,
  int ccltype,
) async =>
    cvRunAsync4(
      (callback) =>
          cimgproc.ConnectedComponentsWithStats_Async(src.ref, connectivity, ltype, ccltype, callback),
      (completer, p, p1, p2, p3) {
        final rval = p.cast<ffi.Int>().value;
        calloc.free(p);
        final labels = Mat.fromPointer(p1.cast<cimgproc.Mat>());
        final stats = Mat.fromPointer(p2.cast<cimgproc.Mat>());
        final centroids = Mat.fromPointer(p3.cast<cimgproc.Mat>());
        completer.complete((rval, labels, stats, centroids));
      },
    );