optic flow and direct motion t. darrell

27
6.801/866 Optic Flow and Direct Motion T. Darrell Material kindly adapted from B. Horn, Y. Weiss, P. Anandan, M. Black, K. Toyama Topics Brightness Constancy The Aperture problem Regularization Lucas-Kanade Coarse-to-fine Parametric motion models Direct depth SSD tracking Robust flow Bayesian flow

Upload: others

Post on 10-Jan-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Optic Flow and Direct Motion T. Darrell

6.801/866

Optic Flow and Direct Motion

T. Darrell

Material kindly adapted from B. Horn, Y. Weiss, P. Anandan, M. Black, K. Toyama

Topics

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

Page 2: Optic Flow and Direct Motion T. Darrell

Applications

• tracking• recognition• structure from motion• segmentation• stabilization• compression• mosaicing...

Page 3: Optic Flow and Direct Motion T. Darrell

Review: The Essential Matrix

Matrix that relates image of point in one camera to a second camera, given translation and rotation.

5 independent parameters (up to scale)Assumes intrinsic parameters are known.

baba x

rrr ][=×

ℜ= ][ xtε

Review: Instantaneous case

For small motion given translation and rotation velocity:

See F&P, chapter 10

Review: FOE for translating camera Review: FOE for translating camera

Page 4: Optic Flow and Direct Motion T. Darrell

Planar motion examples

• Ideal motion of a plane

translationin X

translationin Z

rotationaround Z

rotationaround Y

How to find motion?

• Track features (as in stereo)?– exhaustive search can be slow– usually just return best match; no uncertainty

• Differential approach– match gradients– usually limited by first-order Taylor series

approximation– most common in CV literature

Differential approach:Optical flow constraint equation

),,(),,( tyxItttvytuxI =+++ δδδBrightness should stay constant as you track motion

),,(),,( tyxItItIvtIutyxI tyx =+++ δδδ

1st order Taylor series, valid for small tδ

0=++ tyx IvIuIConstraint equation

“BCCE” - Brightness Change Constraint Equation

Page 5: Optic Flow and Direct Motion T. Darrell

Brightness constancy constraint line

uIx + vIy + It = 0:one equation, two unknowns!

Weiss and Fleet, in Rao and Sejnowski(ed) Statistical Theories of the Cortex. MIT Press

Aperture Problem and Normal Flow Aperture Problem and Normal Flow

Page 6: Optic Flow and Direct Motion T. Darrell

Aperture Problem and Normal Flow Aperture Problem and Normal Flow

Aperture Problem and Normal Flow Aperture Problem and Normal Flow

Page 7: Optic Flow and Direct Motion T. Darrell

Aperture Problem and Normal Flow

0

0

=•∇

=++

UI

IvIuI tyxr

The gradient constraint:

Defines a line in the (u,v) space

u

v

II

IIu t

∇∇

∇−=⊥

Normal Flow:

Local Patch Analysis

Combining Local Constraints

u

v 11tIUI −=•∇

22tIUI −=•∇33tIUI −=•∇

etc.

What is Optic Flow, anyway?

• Estimate of observed projected motion field• Not always well defined!• Compare:

– Motion Field (or Scene Flow)projection of 3-D motion field

– Normal Flowobserved tangent motion

– Optic Flowapparent motion of the brightness pattern(hopefully equal to motion field)

• Consider Barber pole illusion

Page 8: Optic Flow and Direct Motion T. Darrell

Planar motion examples

• Ideal motion of a plane

translationin X

translationin Z

rotationaround Z

rotationaround YWhat is the

motion here?

Scene Flow:Normal Flow:Optic Flow:

undef?, probably 0

Topics

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

Solutions to “the aperture problem”

• Regularize the solution: add a velocity smoothness constraint (eg, Horn 12.6).

• Integrate over a larger region in image (e.g., Lukas and Kanade).

• More sophisticated scene models: segment object boundaries, specularities, textureless regions, etc.

Horn and Schunck

Page 9: Optic Flow and Direct Motion T. Darrell

Horn and Schunck Horn and Schunck

Horn and Schunck Horn and Schunck

Page 10: Optic Flow and Direct Motion T. Darrell

Horn and Schunck

Final estimate Actual motionProblems:

–edges

–large uniform regions

–can require many iterations

Lucas-Kanade: Integrate over a Patch

( )∑Ω∈

++=yx

tyx IvyxIuyxIvuE,

2),(),(),(

Solve with:

Assume a single velocity for all pixels within an image patch

−=

∑∑

∑∑∑∑

ty

tx

yyx

yxx

IIII

vu

IIIIII2

2

( ) tT IIUII ∑∑ ∇−=∇∇

r

On the LHS: sum of the 2x2 outer product tensor of the gradient vector

Lucas-Kanade: Singularities and the Aperture Problem

( )( )∑ ∇∇= TIIMLet

• Algorithm: At each pixel compute by solving

• M is singular if all gradient vectors point in the same direction-- e.g., along an edge-- of course, trivially singular if the summation is over a single pixel-- i.e., only normal flow is available (aperture problem)

• Corners and textured areas are OK

and

−−

= ∑∑

ty

tx

IIII

b

U bMU=

Page 11: Optic Flow and Direct Motion T. Darrell

Iterative Refinement

• Estimate velocity at each pixel using one iteration of Lucas and Kanade estimation

• Warp one image toward the other using the estimated flow field(easier said than done)

• Refine estimate by repeating the process

Motion and Gradients

Consider 1-d signal; assume linear function of x

x

I t=0t=1

u dtdI

t

x

t

tx

IIu

IuI

udt

dI

dxdI

−=

+=

−=

0

“shift by u to accountfor Ix with It”

Iterative refinement

x

t

x

t

t

x

BUT!!

Topics

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

Page 12: Optic Flow and Direct Motion T. Darrell

Limits of the (local) gradient method

1. Fails when intensity structure within window is poor

2. Fails when the displacement is large (typical operating range is motion of 1 pixel per iteration!)

– Linearization of brightness is suitable only for small displacements

Also, brightness is not strictly constant in images– actually less problematic than it appears, since we

can pre-filter images to make them look similar

Pyramid / “Coarse-to-fine”

image Iimage J

av

Jwwarp refine

av

a?v

+

Pyramid of image J Pyramid of image I

image Iimage J

Coarse-to-Fine Estimation

u=10 pixels

u=5 pixels

u=2.5 pixels

u=1.25 pixels

0≈+⋅+⋅ tyx IvIuI ==> small u and v ...Parametric (Global) Motion

Models

Global motion models offer – more constrained solutions than smoothness (Horn-

Schunck)– integration over a larger area than a translation-only

model can accommodate (Lucas-Kanade)

Page 13: Optic Flow and Direct Motion T. Darrell

Parametric (Global) Motion Models

2D Models:(Translation)AffineQuadraticPlanar projective transform (Homography)

3D Models:Instantaneous camera motion models Homography+epipolePlane+Parallax

h ) = Σx R

(E [I( x ) - (x ]2)+ h I0

• Transformations/warping of image

h ) = Σx R

(E [I( x ) - I0(x ]2)+ h

Translations:

=

yxδδ

h

What about other types of motion?

Page 14: Optic Flow and Direct Motion T. Darrell

Generalization

• Transformations/warping of image

A, h) = Σx R

(E [I(Ax ) - (x ]2)+h

Affine:

=

dcba

A

=

yxδδ

h

I0

Generalization

Affine:

=

dcba

A

=

yxδδ

h

0)()( 654321 ≈++++++ tyx IyaxaaIyaxaaI

Example: Affine Motion

Substituting into the B.C. Equation:

yaxaayxvyaxaayxu

654

321

),(),(

++=++=

Each pixel provides 1 linear constraint in 6 global unknowns

0≈+⋅+⋅ tyx IvIuI

(minimum 6 pixels necessary)

[ ] 2∑ ++++++= tyx IyaxaaIyaxaaIaErr )()()( 654321r

Least Square Minimization (over all pixels):

Page 15: Optic Flow and Direct Motion T. Darrell

Generalization

• Transformations/warping of image

A ) = Σx R

(E [I( A x ) - (x ]2)

Planar perspective:

=

187

654

321

aaaaaaaa

A

I0

Generalization

Planar perspective:

=

187

654

321

aaaaaaaa

A

Affine +

Generalization

• Transformations/warping of image

h ) = Σx R

(E [I( f(x, h)) - (x ]2)

Other parametrized transformations

I0

Page 16: Optic Flow and Direct Motion T. Darrell

Generalization

Other parametrized transformations

Quadratic – instantaneousapproximation to planar motion

2D Motion Models summary

287654

82

7321

yqxyqyqxqqvxyqxqyqxqqu

++++=

++++=

yyvxxu

yhxhhyhxhhy

yhxhhyhxhhx

−=−=

++++

=

++++=

','and

'

'

987

654

987

321

Projective – exact planar motion

3D Motion Models summary

ZxTTxxyyvZxTTyxxyu

ZYZYX

ZXZYX

)()1(

)()1(2

2

−+Ω−Ω+Ω+−=

−+Ω−Ω++Ω−=

yyvxxuthyhxhthyhxhy

thyhxhthyhxhx

−=−=++++++

=

++++++

=

',':and

'

'

3987

1654

3987

1321

γγγγ

)(1

)(1

233

133

tytt

xyv

txtt

xxu

w

w

−+

=−=

−+

=−=

γγγγ

Local Parameter:

ZYXZYX TTT ,,,,, ΩΩΩ

),( yxZ

Instantaneous camera motion:Global parameters:

Global parameters: 32191 ,,,,, ttthh K

),( yxγ

Homography+Epipole

Local Parameter:

Residual Planar Parallax MotionGlobal parameters: 321 ,, ttt

),( yxγLocal Parameter:

Original sequence Plane-aligned sequence Recovered shape

Block sequence from [Kumar-Anandan-Hanna’94]

“Given two views where motion of points on a parametric surface has been compensated, the residual parallax is an epipolar field”

Residual Planar Parallax Motion(Plane+Parallax)

Page 17: Optic Flow and Direct Motion T. Darrell

Residual Planar Parallax Motion

Brightness Constancy constraint

The intersection of the two line constraintsuniquely defines the displacement.

Epipolar line

epipole

p

0=++ TYX IvIuI

Dense 3D Reconstruction(Plane+Parallax)

Originalsequence

Plane-alignedsequence

Recovered shape

Rigid pose estimation

• Head pose model: 6 DOF

=

z

y

x

TTT

T

z

y

x

ωωω

|||| Ω

O

=

ZYX

P

ZCZ Z −='

Optic flow for rigid motion

• 3-D velocity:

Ω

−−

−=

=

T

XYXZYZ

VVV

V

z

y

x

01000010

0001

[ ]

Ω

−=Ω−=×Ω+=T

TPTV PIP ˆˆ

[ ]xPP =ˆ(skew-sym.)

(See Horn, 17.2)

Page 18: Optic Flow and Direct Motion T. Darrell

Optic flow for rigid motion

• Perspective projection

−−

=

z

y

x

y

x

VVV

Zyfxf

v

v

'1

00

Optic flow for rigid motion

• Combine

−−

=

z

y

x

y

x

VVV

Zyfxf

v

v

'1

00

Ω

−−

−=

=

T

XYXZYZ

VVV

V

z

y

x

01000010

0001

Optic flow for rigid motion

• Rigid Motion (for small v):

Ω

=

Tv

v

y

xH

−−

−−

=0100

00100001

'1

00

XYXZYZ

Zyfxf

H

3-D velocity at point PPerspective projectionof 3-D velocity

Hard to solve with just optic flow vectors! (but see Horn 17.3-17.5).Instead, Direct method combines constraint linearly with BCCE!

Direct Rigid Motion Estimation

• Brightness Change Constraint

)1,,(),,( +++= tvyvxItyxI yx

0=++dtdIv

dydIv

dxdI

yx

=

y

x

v

v

dydI

dxdI

dtdI

Page 19: Optic Flow and Direct Motion T. Darrell

Direct Rigid Motion Estimation

• Brightness Change Constraint

• Rigid Motion Model

=

y

x

v

v

dydI

dxdI

dtdI

−−

−−

=0100

00100001

'1

00

XYXZYZ

Zyfxf

H

Ω

=

Tv

v

y

xH

Direct Motion Estimation

• One equation per pixel:

Ω

−−

−−

=

T

01000010

0001

'1

00

XYXZYZ

Zyfxf

dydI

dxdI

dtdI

First, convert X,Y from screen coordinates to pixel coordinates….

Direct Motion Estimation

• One equation per pixel:

Ω

−−

−−

=

T

0/'/'100/'0010/'0001

'1

00

fxZfyZfxZZfyZZ

Zyfxf

dydI

dxdI

dtdI

Direct Motion Estimation

• One equation per pixel:

• Still hard!• Z unknown; assume surface shape…

– Negahdaripour & Horn - Planar– Black and Yacoob - Affine– Basu and Pentland; Bregler and Malik - Ellipsoidal– Essa et al. - Polygonal approximation– ...

Ω

−−

−−

=

T

0/'/'100/'0010/'0001

'1

00

fxZfyZfxZZfyZZ

Zyfxf

dydI

dxdI

dtdI

Page 20: Optic Flow and Direct Motion T. Darrell

“Direct Depth”

Use real-time stereo!• Gives Z directly; no approximate model needed • Express Direct Constraint on Depth Gradient

zyx vtvyvxZtyxZ −+++= )1,,(),,(

0=−++ zyx vdtdZv

dydZv

dxdZ

)1,,(),,( +++= tvyvxItyxI yx

Direct Depth

3-D Depth and Brightness Constraint Equations:• Orthographic

• Perspective

=

−−

z

y

x

vvv

dydZdxdZdydIdxdI

dtdZdtdI

1//0//

//

−−−

=

−−

z

y

x

vvv

ZdyfdZdxfdZdxxdIdyydIdyfdIdxfdI

dtdZdtdI

'1

1//////

//

Direct Depth

Combined with rigid motion model:• Orthographic

• Perspective

One system per pixel, same Τ,Ω. Solve with QR or SVD.

Ω

−−

−−−

=

−− T

0/'/'100/'0010/'0001

'1

1//////

//

fxZfyZfxZZfyZZ

ZdyfdZdxfdZdxxdIdyydIdyfdIdxfdI

dtdZdtdI

Ω

−−

=

−− T

01000010

0001

1//0//

//

xyxZyZ

dydZdxdZdydIdxdI

dtdZdtdI

[Harville et. al]

Input to Pose Tracking

Page 21: Optic Flow and Direct Motion T. Darrell

Pose Results Application

Track users’ head gaze for hands-free pointing…

Topics

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

Correlation and SSD

• For large displacements, do template matching as was used in stereo disparity search.– Define a small area around a pixel as the template– Match the template against each pixel within a search

area in next image.– Use a match measure such as correlation, normalized

correlation, or sum-of-squares difference– Choose the maximum (or minimum) as the match– Sub-pixel interpolation also possible

Page 22: Optic Flow and Direct Motion T. Darrell

SSD Surface – Textured area SSD Surface -- Edge

SSD Surface – homogeneous area Discrete Search vs. Gradient Based Estimation

Consider image I translated by

21

,00

2

,1

)),(),(),((

)),(),((),(

yxvvyuuxIyxI

vyuxIyxIvuE

yx

yx

η−+−+−−=

++−=

00 ,vu

),(),(),(),(),(

1001

0

yxyxIvyuxIyxIyxI

η+=++=

Discrete search simply searches for the best estimate.Gradient method linearizes the intensity function and solves for the estimate

Page 23: Optic Flow and Direct Motion T. Darrell

ProblemProblem

tI);(I);(I ++ axax vu yx

Violations of brightness constancy result in largeresidual errors:

Choose θ to be insensitive to outliers

θ

Robust Estimation

Standard Least Squares Estimation allows too much influence for outlying points

)()

)()(

)()(

2

mxx

x

mxx

xmE

i

ii

ii

−=∂∂=

−=

= ∑

ρψ

ρ

ρ

(Influence

Robust EstimationRobust EstimationGoal:

• Recover the best fit to the majority of the data• detect and reject outliers

Linear regression:),)((),( 2121 σρ ii

idaxaaaE −+=∑

Robust EstimationRobust EstimationQuadratic θ function gives too much weight to outliers.

22

2

),(r

rr+

σρ 222

2

)(2),(

rrr+

σσψ

Page 24: Optic Flow and Direct Motion T. Darrell

Robust Estimation

( )∑ ++= tsysxssd IvIuIvuE ρ),( Robust gradient constraint

( )∑ ++−= ),(),(),( ssssd vyuxJyxIvuE ρ Robust SSD

Minimize via coordinate descent.• Non-convex• Use a continuation method with deterministic annealing.• Coarse-to-fine• IRLS

Iteratively Reweighted Least-Squares

[ ] 2∑ ++= ),(),(),(),(),(),()( yxIyxvyxIyxuyxIyxWaErr tyxr

Robust Minimization (over all pixels):

Reweight each pixel based on previous residual.

An Outlier Measure is thus:

ε+∇∇

∝ 2),(

)),(/1(torelatedinversely),(

III

yxO

yxWyxO

t

Topics

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

Bayesian Optic Flow

• Some low-level human motion illusions can be explained by adding an uncertianty model to Lucas-Kanade tracking

• Theories from Psychology about normal flow fusion:– (VA) vector average (of normal motions) – (IOC) intersection of constraints (e.g., Lucas-Kanade):

Page 25: Optic Flow and Direct Motion T. Darrell

http://www.cs.huji.ac.il/~yweiss/Rhombus.

Page 26: Optic Flow and Direct Motion T. Darrell

Brightness constancy with noise:

Assume Gaussian noise, smooth surfaces, locally constant; take first order linear approximation:

Prior favoring slow speeds:

Assume noise is independent across location; apply Bayes:

With constant window w=1,

Form ‘normal equations’ to arrive at….

Lucas-Kanade with uncertainty:

One parameter: ratio of observation and prior gaussian spread.

http://www.cs.huji.ac.il/~yweiss/Rhombus[Weiss, Simoncelli, Adelson Nature Neuroscience 2002]

Page 27: Optic Flow and Direct Motion T. Darrell

Effect of contrast Topics

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