calcOpticalFlowPyrLKAsync function

Future<(VecPoint2f, VecUChar, VecF32)> calcOpticalFlowPyrLKAsync(
  1. InputArray prevImg,
  2. InputArray nextImg,
  3. VecPoint2f prevPts,
  4. VecPoint2f nextPts, {
  5. VecUChar? status,
  6. VecF32? err,
  7. (int, int) winSize = (21, 21),
  8. int maxLevel = 3,
  9. (int, int, double) criteria = (TERM_COUNT + TERM_EPS, 30, 1e-4),
  10. int flags = 0,
  11. double minEigThreshold = 1e-4,
})

CalcOpticalFlowPyrLK calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.

For further details, please see: https://docs.opencv.org/master/dc/d6b/group__video__track.html#ga473e4b886d0bcc6b65831eb88ed93323

Implementation

Future<(VecPoint2f nextPts, VecUChar status, VecF32 error)> calcOpticalFlowPyrLKAsync(
  InputArray prevImg,
  InputArray nextImg,
  VecPoint2f prevPts,
  VecPoint2f nextPts, {
  VecUChar? status,
  VecF32? err,
  (int, int) winSize = (21, 21),
  int maxLevel = 3,
  (int, int, double) criteria = (TERM_COUNT + TERM_EPS, 30, 1e-4),
  int flags = 0,
  double minEigThreshold = 1e-4,
}) {
  final s = status?.ptr ?? calloc<cvg.VecUChar>();
  final e = err?.ptr ?? calloc<cvg.VecF32>();
  return cvRunAsync0(
    (callback) => cvideo.cv_calcOpticalFlowPyrLK_1(
      prevImg.ref,
      nextImg.ref,
      prevPts.ref,
      nextPts.ptr,
      s,
      e,
      winSize.cvd.ref,
      maxLevel,
      criteria.toTermCriteria().ref,
      flags,
      minEigThreshold,
      callback,
    ),
    (c) {
      nextPts.reattach();
      return c.complete((nextPts, status ?? VecUChar.fromPointer(s), VecF32.fromPointer(e)));
    },
  );
}