Skip to content

Lucas-Kanade optical flow

Follow selected points by finding the small displacement that best aligns each local patch.

Try it on your image ↓

VISUAL WALKTHROUGHMotion
REFERENCE INPUTTwo consecutive frames

The object moves right and upward; most of the background remains still.

RESULTSparse point tracks

Only selected points receive tracks. A real call also returns status and error; a plausible vector alone does not prove a valid track.

STEP 03 / 03

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

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

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.

Input448 × 320
OutputWaiting for a result

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
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Track feature points between nearby frames, estimate motion, or maintain an object pose after detection.

How it works

  1. 01Build a coarse-to-fine image pyramid.
  2. 02Solve local brightness-constancy equations for each patch.
  3. 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.