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 =>
    cvRunAsync2((callback) => cimgproc.Subdiv2D_FindNearest_Async(ref, pt.ref, callback),
        (completer, p, p1) {
      final rval = p.cast<ffi.Int>().value;
      calloc.free(p);
      completer.complete((rval, Point2f.fromPointer(p1.cast<cimgproc.Point2f>())));
    });