Skip to content

Optical flow

PruebasVisilab edited this page Feb 6, 2017 · 4 revisions
  1. Introduction
  2. OpenCV iterative version
  3. Example's explanation
  4. Demo videos
    1. LK optical flow
    2. LK optical flow (optimized)

Introduction

Optical flow is the pattern of apparent motion of image objects between two consecutive frames caused by the movement of object or camera. It is 2D vector field where each vector is a displacement vector showing the movement of points from the first frame to the second.

The objective in this task is to obtain the functionality of Lucas-Kanade point tracking.

OpenCV iterative version

OpenCV provides a sparse iterative version of the Lucas-Kanade optical flow in pyramids in a single function, calcOpticalFlowPyrLK(). To select the points to track, goodFeaturesToTrack() function is used. First, the algorithm takes the first frame, detects Harris corner points in it, and then iteratively tracks those points using Lucas-Kanade optical flow.

calcOpticalFlowPyrLK() receives the previous frame, previous points and the next frame, returning the next points along with status numbers which have a value of 1 if next point was found, and zero otherwise. In the next step, these points are passed as previous points.

Example's explanation

This example takes around 2 seconds to calculate the initial points, and 0.35 seconds for each new picture in the included picture example. Changing the parameters and depending on the configuration necessary for its application, these values can be reduced up to 1 second for the initial point calculation and 0.09 seconds per each new image.

opticalFlow

Demo videos

LK optical flow

lk_op_flow

LK optical flow (optimized)

lk_op_flow_optimized

Clone this wiki locally