findNearestAsync method

Future<(int, Point2f)> findNearestAsync(
  1. Point2f pt
)

Finds the subdivision vertex closest to the given point.

The function is another function that locates the input point within the subdivision. It finds the subdivision vertex that is the closest to the input point. It is not necessarily one of vertices of the facet containing the input point, though the facet (located using locate() ) is used as a starting point.

https://docs.opencv.org/4.x/df/dbf/classcv_1_1Subdiv2D.html#a3ec256af000e129e08eb5f269ccdeb0f

Implementation

Future<(int rval, Point2f nearestPt)> findNearestAsync(Point2f pt) async {
  final pp = calloc<cvg.CvPoint2f>();
  final p = calloc<ffi.Int>();
  return cvRunAsync0(
    (callback) => cimgproc.cv_Subdiv2D_findNearest(ref, pt.ref, pp, p, callback),
    (c) {
      final rval = (p.value, Point2f.fromPointer(pp));
      calloc.free(p);
      return c.complete(rval);
    },
  );
}