Function mola::vision::calcOpticalFlowPyrLK(const mrpt::img::CImage&, const mrpt::img::CImage&, const std::vector<mrpt::math::TPoint2Df>&, std::vector<mrpt::math::TPoint2Df>&, std::vector<TrackStatus>&, const LKParams&)
Defined in File optical_flow.h
Function Documentation
-
void mola::vision::calcOpticalFlowPyrLK(const mrpt::img::CImage &prev, const mrpt::img::CImage &curr, const std::vector<mrpt::math::TPoint2Df> &prev_pts, std::vector<mrpt::math::TPoint2Df> &next_pts, std::vector<TrackStatus> &status, const LKParams ¶ms = {})
Pyramidal Lucas-Kanade optical flow tracker.
Tracks a set of 2D points from
prevtocurrusing the KLT algorithm at multiple pyramid scales (coarse-to-fine).Algorithm (per pyramid level, coarse to fine):
Compute image gradient patch (Ix, Iy) around the predicted position.
Compute the 2x2 spatial gradient matrix G = ΣIx² ΣIxIy / ΣIxIy ΣIy².
Iterate: solve G·v = Σ(It·Ix, It·Iy) for sub-pixel displacement v.
Reject if min eigenvalue of G < min_eig_threshold (flat patch).
Propagate update to next (finer) level × 2.
Output: tracked positions
next_ptsand per-pointstatus.Note: builds image pyramids internally; for repeated tracking on the same frame, use the overload accepting pre-built CImagePyramid objects.
Adapted from: lightweight_vio (MIT License), KLT tracker core. Algorithm reference: Bouguet, “Pyramidal Implementation of the Lucas Kanade
Feature Tracker”, Intel Corp., 2001.