Skip to content

Motion Estimation ​

Source: CS1674 Ch.8. Motion arises whenever light, object, or camera changes. We estimate it via optical flow, primarily the Lucas–Kanade method, and handle large motion with a coarse-to-fine pyramid.

1. Causes of Motion ​

Motion = change across frames, caused by varying one of three imaging factors: Light, Object, Camera.

ScenarioCameraSceneLight
Surveillancestaticmovingstatic
3D capture / mappingmovingstaticstatic
Sports / moviemovingmovingstatic
Time-lapsestaticmovingmoving

Recovering motion can be done by:

  • Feature matching (sparse) — match corners/textured regions across frames.
  • Tracking / optical flow (dense) — estimate motion at every pixel from spatio-temporal brightness.

2. What is Optical Flow? ​

Optical flow is the dense motion field: a 2D vector (u,v) per pixel giving how each point moved between two frames. Uses: motion estimation, object tracking, visual odometry (robot pose).

Feature matching vs. optical flow ​

MethodProsCons
Feature matchingscale/rotation (≈) invariant, lighting (≈) invariant, handles large motionsparse, alignment not exact, low accuracy
Optical flowdense, accurate locallyassumes small motion, brightness constancy

Feature matching alone "doesn't work very well to compute the flow" densely → we use Lucas–Kanade.


3. Lucas–Kanade Optical Flow ​

3.1 Key assumptions ​

  1. Brightness constancy: a projected point has the same intensity in every frame.
  2. Small motion: points move less than ~1 pixel (so linearization is valid).
  3. Spatial coherence: neighboring pixels have (approximately) the same (u,v).

3.2 Brightness constancy constraint ​

I(x,y,t)=I(x+u,y+v,t+1)

Taylor-expand the RHS about (x,y,t):

I(x+u,y+v,t+1)≈I(x,y,t)+Ixu+Iyv+It

Subtracting I(x,y,t) and using constancy (0=Ixu+Iyv+It):

Ixu+Iyv=−It

or in vector form: ∇I⊤d=−It, where d=(u,v)⊤, ∇I=(Ix,Iy), and It is the frame difference.

3.3 The aperture problem ​

Per pixel we have one equation, two unknowns (u,v). The component of motion parallel to an edge (perpendicular to the gradient) is unobservable — the aperture problem (e.g., barber-pole illusion: vertical stripes appear to move up-right while actually moving right).

3.4 Resolving the ambiguity — spatial coherence → least squares ​

Assume the K×K neighborhood shares (u,v). Stack equations for all pixels in the window:

[Ix1Iy1⋮⋮IxK2IyK2][uv]=[−It1⋮−ItK2]⇒Ad=b

Least-squares solution:

d∗=(A⊤A)−1A⊤b

where

A⊤A=∑(x,y)∈W[Ix2IxIyIxIyIy2]=[∑Ix2∑IxIy∑IxIy∑Iy2]

This A⊤A is the same second-moment matrix as in the Harris detector!

3.5 Conditions for solvability (good features to track) ​

  • A⊤A must be invertible.
  • Its eigenvalues λ1,λ2 must not be too small (enough gradient).
  • The ratio λ1/λ2 must not be too large (well-conditioned; both directions have gradient).

⇒ Corners are good to track; flat regions (no gradient) and edges (one dominant eigenvalue) are bad. This is exactly the Harris cornerness criterion — Tomasi & Kanade's "good features to track."

3.6 When LK fails ​

Lighting changes, large movement (>1px), specularities, no good features, aperture problem. "Estimating motion is very challenging, even today."


4. Coarse-to-Fine (Pyramid) Optical Flow ​

Large motion breaks the small-motion assumption. Fix by working on a Gaussian pyramid:

  1. Build Gaussian pyramids of frame t and t+1.
  2. At the top (coarsest) level, run LK → a coarse flow field.
  3. Warp frame t toward frame t+1 by that flow; re-run LK on the warped pair; iterate to convergence.
  4. Upsample the flow to the next-finer level as the initial guess; repeat down to full resolution.

This propagates a rough large displacement from coarse levels down to refine at fine levels — LK with pyramids succeeds where plain LK fails on large motion.


5. Evaluating Optical Flow ​

  • Middlebury flow (vision.middlebury.edu/flow) — standard benchmark with ground truth.
  • KITTI 2015 scene flow.
  • MPI Sintel dataset.

Compare predicted flow to ground-truth flow (e.g., average endpoint error).


6. Summary ​

  • Optical flow = per-pixel motion; computed by LK from brightness constancy + spatial coherence.
  • Single pixel is ambiguous (aperture problem); solve over a window via least squares with A⊤A (the Harris structure tensor).
  • Track corners (good features); handle large motion with coarse-to-fine pyramids.
  • Major contributors: Lucas, Tomasi, Kanade (KLT tracker).

Core equation: Ixu+Iyv=−It, solved as d=(A⊤A)−1A⊤b over a window.


7. Horn–Schunck: Global Optical Flow ​

Lucas–Kanade is local (per window). Horn–Schunck (1981) is global: it assumes the flow is smooth everywhere and minimizes an energy combining a data term and a smoothness term:

E=∬(Ixu+Iyv+It)2+λ((∇u)2+(∇v)2)dxdy
  • The first term enforces brightness constancy; the second penalizes large spatial derivatives of the flow (smoothness).
  • Solved iteratively (e.g., via Jacobi/Gauss–Seidel). Fills dense flow even in textureless regions (at the cost of oversmoothing boundaries).
Lucas–KanadeHorn–Schunck
Scopelocal windowglobal
Outputsparse/dense (per window)dense
Needsgood features (corners)smoothness prior

8. The Aperture Problem (Formal) ​

Along an edge, the gradient is perpendicular to the edge; brightness constancy only constrains the flow component along the gradient:

Ixu+Iyv=−It⇒only (u,v)⋅(Ix,Iy)∥(Ix,Iy)∥ is determined

The component parallel to the edge is unconstrained → the true motion is ambiguous through a small aperture. Resolving it requires integrating over a neighborhood (LK) or multiple orientations.


9. Multi-Scale Refinement ​

Plain LK fails when motion exceeds ~1 px. Coarse-to-fine pyramids (§5) estimate a rough flow at low resolution, warp, then refine at higher resolution — effectively handling large displacements while keeping each LK step small.


10. Evaluation & Modern Methods ​

  • Metrics: EPE (endpoint error, mean ∥flowpred−flowgt∥); Fl-all (percentage of pixels with EPE > 3 or > 5%).
  • Benchmarks: Middlebury, KITTI (driving), MPI Sintel (synthetic, large motion/occlusion).
  • Deep methods: FlowNet (CNN regressor), RAFT (recurrent all-pairs + iterative refinement) now surpass classical LK by large margins — but LK remains the conceptual foundation and is still used for feature tracking (KLT).

Optical flow = dense motion field from brightness constancy + spatial coherence; classical (LK/HS) vs. modern (RAFT) — the math in §3 is where both begin.