Lucas-Kanade optical flow
Follow selected points by finding the small displacement that best aligns each local patch.
The object moves right and upward; most of the background remains still.
Build a coarse-to-fine image pyramid.
Solve local brightness-constancy equations for each patch.
Only selected points receive tracks. A real call also returns status and error; a plausible vector alone does not prove a valid track.
Refine at finer levels and return status/error for each point.
Illustrative example. The stages explain the method; they are not a live OpenCV execution.
Try it on an image
Experiment at pixel level
Track Shi-Tomasi corners from the first image into the second. Lines show estimated motion at accepted points.
The engine loads on your first run. Your images stay in this browser.
Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.
Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Select a pixel
Select a pixel
When to use it
Track feature points between nearby frames, estimate motion, or maintain an object pose after detection.
How it works
- 01Build a coarse-to-fine image pyramid.
- 02Solve local brightness-constancy equations for each patch.
- 03Refine at finer levels and return status/error for each point.
Ix·u + Iy·v + It ≈ 0
What to tune
winSize controls patch support; maxLevel handles larger motion; criteria controls refinement. Forward-backward checking can reveal inconsistent tracks.
Where it breaks down
Points on flat regions or edges may be underconstrained. Occluded or failed points must be rejected using status and further consistency checks.
TypeScript API
Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.
All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.
Related methods
Farneback dense optical flow
Estimate a displacement vector at every pixel using local polynomial approximations.
DIS dense optical flow
Combine fast patch alignment with spatial propagation and dense refinement.
Dual TV-L1 optical flow
Estimate flow with a robust data term and a total-variation smoothness penalty.
MOG2 background subtraction
Learn a mixture of colour distributions at each pixel and flag observations that do not fit the background.