optical flow i - sci.utah.edugerig/cs6320-s2013/materials/cs6320-cv-s201… · optical flow i guido...

109
Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256 / K.H. Shafique, UCSF, CAP5415 / S. Narasimhan, CMU / Bahadir K. Gunturk, EE 7730 / Bradski&Thrun, Stanford CS223

Upload: others

Post on 22-Aug-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow I

Guido Gerig CS 6320, Spring 2013

(credits: Marc Pollefeys UNC Chapel Hill, Comp 256 / K.H. Shafique, UCSF, CAP5415 / S. Narasimhan, CMU / Bahadir

K. Gunturk, EE 7730 / Bradski&Thrun, Stanford CS223

Page 2: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Materials • Gary Bradski & Sebastian Thrun, Stanford CS223

http://robots.stanford.edu/cs223b/index.html • S. Narasimhan, CMU: http://www.cs.cmu.edu/afs/cs/academic/class/15385-

s06/lectures/ppts/lec-16.ppt • M. Pollefeys, ETH Zurich/UNC Chapel Hill:

http://www.cs.unc.edu/Research/vision/comp256/vision10.ppt • K.H. Shafique, UCSF: http://www.cs.ucf.edu/courses/cap6411/cap5415/

– Lecture 18 (March 25, 2003), Slides: PDF/ PPT • Jepson, Toronto:

http://www.cs.toronto.edu/pub/jepson/teaching/vision/2503/opticalFlow.pdf • Original paper Horn&Schunck 1981:

http://www.csd.uwo.ca/faculty/beau/CS9645/PAPERS/Horn-Schunck.pdf • MIT AI Memo Horn& Schunck 1980:

http://people.csail.mit.edu/bkph/AIM/AIM-572.pdf • Bahadir K. Gunturk, EE 7730 Image Analysis II • Some slides and illustrations from L. Van Gool, T. Darell, B. Horn, Y. Weiss, P.

Anandan, M. Black, K. Toyama

Page 3: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking – Rigid Objects

Page 4: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

What is Optical Flow (OF)?

}{),( iptI

1p

2p

3p

4p

Page 5: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

)1( +tI

What is Optical Flow (OF)?

}{),( iptI

1p

2p

3p

4p

Page 6: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

)1( +tI

What is Optical Flow (OF)?

Optical Flow

}{),( iptI

1p

2p

3p

4p

Page 7: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

)1( +tI

What is Optical Flow (OF)?

Optical Flow

}{),( iptI

1p

2p

3p

4p

1vr2vr

3vr

4vr

}{ ivrVelocity vectors

Page 8: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

)1( +tI

What is Optical Flow (OF)?

Optical Flow

}{),( iptI

1p

2p

3p

4p

1vr2vr

3vr

4vr

}{ ivrVelocity vectors

Optical flow is the relation of the motion field: • the 2D projection of the physical movement of points relative to the observer

to 2D displacement of pixel patches on the image plane.

Page 9: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

)1( +tI

What is Optical Flow (OF)?

Optical Flow

}{),( iptI

1p

2p

3p

4p

1vr2vr

3vr

4vr

}{ ivrVelocity vectors

Common assumption: The appearance of the image patches do not change (brightness constancy)

)1,(),( ++= tvpItpI iiir

Optical flow is the relation of the motion field: • the 2D projection of the physical movement of points relative to the observer

to 2D displacement of pixel patches on the image plane.

Page 10: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

)1( +tI

What is Optical Flow (OF)?

Optical Flow

}{),( iptI

1p

2p

3p

4p

1vr2vr

3vr

4vr

}{ ivrVelocity vectors

Common assumption: The appearance of the image patches do not change (brightness constancy)

)1,(),( ++= tvpItpI iiir

Note: more elaborate tracking models can be adopted if more frames are process all at once

Optical flow is the relation of the motion field: • the 2D projection of the physical movement of points relative to the observer

to 2D displacement of pixel patches on the image plane.

Page 11: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow

• Brightness Constancy • The Aperture problem • Regularization • Lucas-Kanade • Coarse-to-fine • Parametric motion models • Direct depth • SSD tracking • Robust flow • Bayesian flow

Page 12: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow and Motion

• We are interested in finding the movement of scene objects from time-varying images (videos).

• Lots of uses – Motion detection – Track objects – Correct for camera jitter (stabilization) – Align images (mosaics) – 3D shape reconstruction – Special effects – Games: http://www.youtube.com/watch?v=JlLkkom6tWw

– User Interfaces: http://www.youtube.com/watch?v=Q3gT52sHDI4

– Video compression

Page 13: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

13

Optical Flow: Where do pixels move to?

Page 14: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Related to: Optical flow

Where do pixels move?

Page 15: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Related to: Optical flow

Where do pixels move?

Page 16: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking – Non-rigid Objects

(Comaniciu et al, Siemens)

Page 17: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking – Non-rigid Objects

Page 18: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow: Correspondence

Basic question: Which Pixel went where?

Page 19: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow is NOT 3D motion field

http://of-eval.sourceforge.net/

Optical flow: Pixel motion field as observed in image.

Page 20: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Structure from Motion?

• Known: optical flow (instantaneous velocity)

• Motion of camera / object?

Page 21: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow is NOT 3D motion field

http://en.wikipedia.org/wiki/File:Opticfloweg.png

Page 22: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

22

Definition of optical flow

OPTICAL FLOW = apparent motion of brightness patterns

Ideally, the optical flow is the projection of the three-dimensional velocity vectors on the image

è

Page 23: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

23

Optical Flow

• Brightness Constancy • The Aperture problem • Regularization • Lucas-Kanade • Coarse-to-fine • Parametric motion models • Direct depth • SSD tracking • Robust flow • Bayesian flow

Page 24: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Start with an Equation: Brightness Constancy

Point moves (small), but its brightness remains constant:

𝐼𝑡𝑡(𝑥, 𝑦) = 𝐼𝑡𝑡(𝑥 + 𝑢, 𝑦 + 𝑣)

𝐼 = 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 → 𝑑𝐼𝑑𝑐

= 0

𝐼𝑡 𝐼𝑡

Time: t Time: t + dt

Page 25: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Mathematical formulation

I (x(t),y(t),t) = brightness at (x,y) at time t

Optical flow constraint equation (chain rule):

0

=¶¶

+¶¶

+¶¶

=tI

dtdy

yI

dtdx

xI

dtdI

),,(),,( tyxItttdtdyyt

dtdxxI =+++ ddd

Brightness constancy assumption (shift of location but brightness stays same):

Page 26: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

The aperture problem

0 =++ tyx IvIuI

, =dtdxu

dtdyv =

, ¶¶

=yII x ,

¶¶

=yII y t

IIt ¶¶

=

Horn and Schunck optical flow equation

Page 27: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

The aperture problem

0 =++ tyx IvIuI

1 equation in 2 unknowns

, =dtdxu

dtdyv =

, ¶¶

=yII x ,

¶¶

=yII y t

IIt ¶¶

=

Horn and Schunck optical flow equation

Page 28: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow: 1D Case Brightness Constancy Assumption:

)),(()),(()( dttdttxIttxItf ++=º

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 29: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow: 1D Case Brightness Constancy Assumption:

)),(()),(()( dttdttxIttxItf ++=º { 0)(

¶txf

Because no change in brightness with time

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 30: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow: 1D Case Brightness Constancy Assumption:

)),(()),(()( dttdttxIttxItf ++=º

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

txt tI

tx

xI

{ 0)(

¶txf

Because no change in brightness with time

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 31: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow: 1D Case Brightness Constancy Assumption:

)),(()),(()( dttdttxIttxItf ++=º

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

txt tI

tx

xI

Ix v It

{ 0)(

¶txf

Because no change in brightness with time

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 32: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow: 1D Case Brightness Constancy Assumption:

)),(()),(()( dttdttxIttxItf ++=º

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

txt tI

tx

xI

Ix v It

x

t

IIv -=Þ

{ 0)(

¶txf

Because no change in brightness with time

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 33: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

33

Tracking in the 1D case:

x

),( txI

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 34: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

34

Tracking in the 1D case:

x

),( txI )1,( +txI

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 35: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

35

Tracking in the 1D case:

x

),( txI )1,( +txI

p

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 36: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

36

vr ?

Tracking in the 1D case:

x

),( txI )1,( +txI

p

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 37: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking in the 1D case:

x

),( txI )1,( +txI

p

Page 38: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

xI

Spatial derivative

Tracking in the 1D case:

x

),( txI )1,( +txI

p

Page 39: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

xI

Spatial derivative

Temporal derivative tI

Tracking in the 1D case:

x

),( txI )1,( +txI

p

Page 40: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

xI

Spatial derivative

Temporal derivative tI

Tracking in the 1D case:

x

),( txI )1,( +txI

p

Page 41: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

vr

xI

Spatial derivative

Temporal derivative tI

Tracking in the 1D case:

x

),( txI )1,( +txI

p

Page 42: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

vr

xI

Spatial derivative

Temporal derivative tI

Tracking in the 1D case:

x

),( txI )1,( +txI

p

tx x

II¶¶

=px

t tII

=¶¶

=x

t

IIv -»

rAssumptions: • Brightness constancy • Small motion

Page 43: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking in the 1D case:

x

),( txI )1,( +txI

p

xI

tI

Iterating helps refining the velocity vector

Page 44: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking in the 1D case:

x

),( txI )1,( +txI

p

xI

tI

Temporal derivative at 2nd iteration

Iterating helps refining the velocity vector

Page 45: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking in the 1D case:

x

),( txI )1,( +txI

p

xI

tI

Temporal derivative at 2nd iteration

Iterating helps refining the velocity vector

Can keep the same estimate for spatial derivative

Page 46: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking in the 1D case:

x

),( txI )1,( +txI

p

xI

tI

Temporal derivative at 2nd iteration

Iterating helps refining the velocity vector

Can keep the same estimate for spatial derivative

x

tprevious I

Ivv -¬rr

Page 47: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Tracking in the 1D case:

x

),( txI )1,( +txI

p

xI

tI

Temporal derivative at 2nd iteration

Iterating helps refining the velocity vector

Can keep the same estimate for spatial derivative

x

tprevious I

Ivv -¬rr

Converges in about 5 iterations

Page 48: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

From 1D to 2D tracking

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

txt tI

tx

xI

1D:

Page 49: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

From 1D to 2D tracking

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

txt tI

tx

xI

1D:

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

+÷øö

çèæ

¶¶

¶¶

txtt tI

ty

yI

tx

xI

2D:

Page 50: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

From 1D to 2D tracking

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

txt tI

tx

xI

1D:

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

+÷øö

çèæ

¶¶

¶¶

txtt tI

ty

yI

tx

xI

2D:

0)(

=¶¶

+¶¶

+¶¶

txtt tIv

yIu

xI

Page 51: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

From 1D to 2D tracking

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

txt tI

tx

xI

1D:

0)(

=¶¶

+÷øö

çèæ

¶¶

¶¶

+÷øö

çèæ

¶¶

¶¶

txtt tI

ty

yI

tx

xI

2D:

0)(

=¶¶

+¶¶

+¶¶

txtt tIv

yIu

xI

Shoot! One equation, two velocity (u,v) unknowns…

Page 52: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow vs. Motion: Aperture Problem

Barber shop pole: http://www.youtube.com/watch?v=VmqQs613SbE

Page 53: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow vs. Motion: Aperture Problem

Barber shop pole: http://www.youtube.com/watch?v=VmqQs613SbE

Page 54: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

54

Optical Flow

• Brightness Constancy • The Aperture problem • Regularization • Lucas-Kanade • Coarse-to-fine • Parametric motion models • Direct depth • SSD tracking • Robust flow • Bayesian flow

Page 55: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 56: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 57: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 58: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 59: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 60: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 61: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 62: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 63: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 64: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 65: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 66: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 67: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 68: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 69: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 70: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 71: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 72: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 73: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 74: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 75: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 76: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

How does this show up visually? Known as the “Aperture Problem”

Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 77: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Aperture Problem Exposed

Motion along just an edge is ambiguous Gary Bradski & Sebastian Thrun, Stanford CS223 http://robots.stanford.edu/cs223b/index.html

Page 78: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

78

Aperture Problem in Real Life

Page 79: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

79

Normal Flow

* Slide from Michael Black, CS143 2003

We get at most “Normal Flow” – with one point we can only detect movement perpendicular to the brightness gradient. Solution is to take a patch of pixels Around the pixel of interest.

Page 80: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Aperture Problem

Page 81: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Aperture Problem

Page 82: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

82

Page 83: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Aperture Problem and Normal Flow

Page 84: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Computing True Flow

• Horn & Schunck • Schunck • Lukas and Kanade

Page 85: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Possible Solution: Neighbors

Two adjacent pixels which are part of the same rigid object: • we can calculate normal flows vn1 and vn2

• Two OF equations for 2 parameters of flow: �̅� = 𝑣𝑢

𝛻𝐼𝑡. �̅� − 𝐼𝑡𝑡 = 0 𝛻𝐼𝑡. �̅� − 𝐼𝑡𝑡 = 0

Page 86: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Considering Neighbor Pixels

Page 87: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Considering Neighbor Pixels

Jepson, Toronto: http://www.cs.toronto.edu/pub/jepson/teaching/vision/2503/opticalFlow.pdf

Cluster center provides velocity vector common for all pixels in patch.

Page 88: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

88

Optical Flow

• Brightness Constancy • The Aperture problem • Regularization: Horn & Schunck • Lucas-Kanade • Coarse-to-fine • Parametric motion models • Direct depth • SSD tracking • Robust flow • Bayesian flow

Page 89: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

89

Horn & Schunck algorithm

è

Page 90: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

90

Horn & Schunck algorithm

Additional smoothness constraint (usually motion field varies smoothly in the image → penalize departure from smoothness) :

,))()(( 2222 dxdyvvuue yxyxs +++= òòOF constraint equation term (formulate error in optical flow constraint) : ,)( 2 dxdyIvIuIe tyxc ++= òòminimize es+lec

è

Page 91: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

91

Horn & Schunck algorithm

è

Variational calculus: Pair of second order differential equations that can be solved iteratively.

Page 92: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

92

Horn & Schunck algorithm

è

Page 93: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

93

Horn & Schunck

The Euler-Lagrange equations :

0

0

=¶¶

-¶¶

-

=¶¶

-¶¶

-

yx

yx

vvv

uuu

Fy

Fx

F

Fy

Fx

F

In our case ,

,)()()( 22222tyxyxyx IvIuIvvuuF ++++++= l

so the Euler-Lagrange equations are

,)(,)(

ytyx

xtyx

IIvIuIvIIvIuIu

++=D

++=D

l

l

2

2

2

2

yx ¶¶

+¶¶

=D is the Laplacian operator

è

Page 94: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

94

Horn & Schunck

Remarks :

1. Coupled PDEs solved using iterative methods and finite differences

2. More than two frames allow a better estimation of It

3. Information spreads from corner-type patterns

è

,)(

,)(

ytyx

xtyx

IIvIuIvtv

IIvIuIutu

++-D=¶¶

++-D=¶¶

l

l

Page 95: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Discrete Optical Flow Algorithm Consider image pixel

• Departure from Smoothness Constraint:

•Error in Optical Flow constraint equation: • We seek the set that minimize: åå +=

i jijij cse )( l

])()(

)()[(41

2,1,

2,,1

2,1,

2,,1

jijijiji

jijijijiij

vvvv

uuuus

-+-

+-+-=

++

++

2)( tij

ijyij

ijxij

ij EvEuEc ++=}{&}{ ijij vu

NOTE: show up in more than one term

}{&}{ ijij vu

),( ji

Page 96: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Discrete Optical Flow Algorithm • Differentiating w.r.t and setting to zero:

• are averages of around pixel

e0)(2)(2 =+++-=

¶¶ kl

xkltkl

klykl

klxklkl

kl

EEvEuEuuue l

0)(2)(2 =+++-=¶¶ kl

ykltkl

klykl

klxklkl

kl

EEvEuEvvve l

klkl uv &

klkl uv & ),( lk),( vu

klxkl

yklx

klt

nkl

kly

nkl

klxn

klnkl E

EEEvEuE

uu])()[(1 22

1

++

++-=+

l

klykl

yklx

klt

nkl

kly

nkl

klxn

klnkl E

EEEvEuE

vv])()[(1 22

1

++

++-=+

l

Update Rule:

Page 97: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Horn-Schunck Algorithm : Discrete Case

• Derivatives (and error functionals) are approximated by difference operators

• Leads to an iterative solution:

yn

ijnij

xn

ijnij

Evv

Euu

a

a

-=

-=+

+

1

1

)(1 22yx

tn

ijyn

ijx

EEEvEuE

++

++=

la

neighbors of valuesof average theis ,vu

Page 98: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Intuition of the Iterative Scheme

u

v (Ex,Ey)

Constraint line

(u,v)

),( vu

The new value of (u,v) at a point is equal to the average of surrounding values minus an adjustment in the direction of the brightness gradient

Page 99: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Horn - Schunck Algorithm

Page 100: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Example

http://of-eval.sourceforge.net/

Page 101: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Results

Page 102: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Results

Page 103: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Optical Flow Result

Page 104: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

10

Horn & Schunck, remarks

1. Errors at boundaries

2. Example of regularisation (selection principle for the solution of illposed problems)

è

Page 105: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Results of an enhanced system

Page 107: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

Results http://www.cs.utexas.edu/users/jmugan/GraphicsProject/OpticalFlow/

Page 108: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256

10

Optical Flow

• Brightness Constancy • The Aperture problem • Regularization • Lucas-Kanade • Coarse-to-fine • Parametric motion models • Direct depth • SSD tracking • Robust flow • Bayesian flow

Page 109: Optical Flow I - sci.utah.edugerig/CS6320-S2013/Materials/CS6320-CV-S201… · Optical Flow I Guido Gerig CS 6320, Spring 2013 (credits: Marc Pollefeys UNC Chapel Hill, Comp 256