calcOpticalFlowPyrLK function

(VecPoint2f, VecUChar?, VecF32?) calcOpticalFlowPyrLK(
  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

(VecPoint2f nextPts, VecUChar? status, VecF32? error) calcOpticalFlowPyrLK(
  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<cvideo.VecUChar>();
  final e = err?.ptr ?? calloc<cvideo.VecF32>();
  cvRun(
    () => cvideo.CalcOpticalFlowPyrLKWithParams(
      prevImg.ref,
      nextImg.ref,
      prevPts.ref,
      nextPts.ptr,
      s,
      e,
      winSize.cvd.ref,
      maxLevel,
      criteria.toTermCriteria().ref,
      flags,
      minEigThreshold,
    ),
  );
  nextPts.reattach();
  return (nextPts, status ?? VecUChar.fromPointer(s), VecF32.fromPointer(e));
}