Computer Vision · Advanced level

Advanced level · Module 4: Object Tracking and Localization · Lesson 1 of 4

Motion Estimation with Optical Flow

Learners estimate motion between frames with Lucas-Kanade sparse optical flow and Farneback dense flow, and visualise direction and speed.

In this lesson you will

  • Compute sparse and dense optical flow
  • Visualise and interpret motion

Key concepts

optical flowbrightness constancycv2.calcOpticalFlowPyrLKcv2.calcOpticalFlowFarnebackflow visualisation

The lesson

Optical flow estimates how pixels move between consecutive frames, assuming that a point keeps roughly the same brightness as it moves. Lucas-Kanade tracks a set of good feature points; Farneback computes flow for every pixel.

Dense flow is often shown as a colour image where hue encodes direction and brightness encodes speed. Sparse flow is drawn as tracks of points over time.

Flow is useful for detecting movement, estimating traffic direction, and stabilising shaky phone video, but it struggles with fast motion, lighting changes and textureless surfaces.

Step by step

  1. Record or download a short public road or field video without identifiable people.
  2. Track good features with Lucas-Kanade and draw their paths.
  3. Compute dense Farneback flow and display it in colour.
  4. Note where the flow fails.

Practice activity

Produce sparse and dense flow visualisations for a short video.

Expected result: Correct visualisations and a note on failure cases.

Check your understanding

  1. What assumption does optical flow rely on?

    Show answer

    A moving point keeps roughly the same brightness between frames.

  2. What does dense optical flow compute?

    Show answer

    A motion vector for every pixel.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.