Farneback dense optical flow
Estimate a displacement vector at every pixel using local polynomial approximations.
The object moves right and upward; most of the background remains still.
Approximate each local neighbourhood with a quadratic polynomial.
Infer displacement from how polynomial coefficients change.
Mint vectors follow the moving object. Grey vectors represent the nearly static background; each vector belongs to an image location.
Average and refine the field across pyramid levels.
Illustrative example. The stages explain the method; they are not a live OpenCV execution.
Try it on an image
Experiment at pixel level
Estimate dense motion from input to second image. Colour gives direction, brightness gives speed; inspect dx and dy in pixels.
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
Visualize dense motion, align neighbouring frames, or initialize motion-aware processing.
How it works
- 01Approximate each local neighbourhood with a quadratic polynomial.
- 02Infer displacement from how polynomial coefficients change.
- 03Average and refine the field across pyramid levels.
dense output: (horizontal displacement, vertical displacement) per pixel
What to tune
pyr_scale and levels set motion range; winsize sets support; poly_n/poly_sigma tune the local polynomial approximation.
Where it breaks down
A dense field includes uncertain pixels too. Occlusion, uniform areas and illumination changes need separate confidence handling.
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
Lucas-Kanade optical flow
Follow selected points by finding the small displacement that best aligns each local patch.
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.