epipolar geometry and stereo vision

58
Epipolar Geometry and Stereo Vision Computer Vision ECE 5554 Virginia Tech Devi Parikh 10/15/13 These slides have been borrowed from Derek Hoiem and Kristen Grauman. Derek adapted many slides from Lana Lazebnik, Silvio Saverese, Steve Seitz, and took many figures from Hartley & Zisserman. 1

Upload: herve

Post on 25-Feb-2016

59 views

Category:

Documents


1 download

DESCRIPTION

10/15/13. Epipolar Geometry and Stereo Vision. Computer Vision ECE 5554 Virginia Tech Devi Parikh. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Epipolar  Geometry and Stereo Vision

Epipolar Geometry and Stereo Vision

Computer VisionECE 5554

Virginia Tech

Devi Parikh

10/15/13

These slides have been borrowed from Derek Hoiem and Kristen Grauman. Derek adapted many slides from Lana Lazebnik, Silvio Saverese, Steve Seitz, and took many figures from Hartley & Zisserman.

1

Page 2: Epipolar  Geometry and Stereo Vision

Announcements• PS1 grades are out

– Max: 120– Min: 42– Median and Mean: 98 – 17 students > 100

• PS3 due Monday (10/21) night

• Progress on projects

• Feedback forms

2

Page 3: Epipolar  Geometry and Stereo Vision

Recall • Image formation geometry

• Vanishing points and vanishing lines

• Pinhole camera model and camera projection matrix

• Homogeneous coordinates

Vanishing point

Vanishing

line

Vanishing point

Vertical vanishing point

(at infinity)

XtRKx

Slide source: Derek Hoiem3

Page 4: Epipolar  Geometry and Stereo Vision

This class: Two-View Geometry

• Epipolar geometry– Relates cameras from two positions

• Next time: Stereo depth estimation– Recover depth from two images

4

Page 5: Epipolar  Geometry and Stereo Vision

Why multiple views?• Structure and depth are inherently ambiguous from single

views.

Images from Lana Lazebnik5

Slide credit: Kristen Grauman

Page 6: Epipolar  Geometry and Stereo Vision

Why multiple views?• Structure and depth are inherently ambiguous from single

views.

Optical center

X1X2

x1’=x2’

6Slide credit: Kristen Grauman

Page 7: Epipolar  Geometry and Stereo Vision

• What cues help us to perceive 3d shape and depth?

7Slide credit: Kristen Grauman

Page 8: Epipolar  Geometry and Stereo Vision

Shading

[Figure from Prados & Faugeras 2006]

8Slide credit: Kristen Grauman

Page 9: Epipolar  Geometry and Stereo Vision

Focus/defocus

[figs from H. Jin and P. Favaro, 2002]

Images from same point of view, different camera parameters

3d shape / depth estimates

9Slide credit: Kristen Grauman

Page 10: Epipolar  Geometry and Stereo Vision

Texture

[From A.M. Loh. The recovery of 3-D structure using visual texture patterns. PhD thesis] 10Slide credit: Kristen Grauman

Page 11: Epipolar  Geometry and Stereo Vision

Perspective effects

Image credit: S. Seitz11

Slide credit: Kristen Grauman

Page 12: Epipolar  Geometry and Stereo Vision

Motion

Figures from L. Zhang

http://www.brainconnection.com/teasers/?main=illusion/motion-shape12

Slide credit: Kristen Grauman

Page 13: Epipolar  Geometry and Stereo Vision

Stereo photography and stereo viewers

Invented by Sir Charles Wheatstone, 1838 Image from fisher-price.com

Take two pictures of the same subject from two slightly different viewpoints and display so that each eye sees only one of the images.

Slide credit: Kristen Grauman13

Page 14: Epipolar  Geometry and Stereo Vision

http://www.johnsonshawmuseum.org

Slide credit: Kristen Grauman14

Page 15: Epipolar  Geometry and Stereo Vision

http://www.johnsonshawmuseum.org

Slide credit: Kristen Grauman15

Page 16: Epipolar  Geometry and Stereo Vision

Public Library, Stereoscopic Looking Room, Chicago, by Phillips, 1923

Slide credit: Kristen Grauman16

Page 17: Epipolar  Geometry and Stereo Vision

http://www.well.com/~jimg/stereo/stereo_list.htmlSlide credit: Kristen Grauman

17

Page 18: Epipolar  Geometry and Stereo Vision

Recall: Image Stitching• Two images with rotation/zoom but no translation

f f'

.

x

x'

X

18

Page 19: Epipolar  Geometry and Stereo Vision

Estimating depth with stereo

• Stereo: shape from “motion” between two views

scene point

optical center

image plane

19

Page 20: Epipolar  Geometry and Stereo Vision

Two cameras, simultaneous views

Single moving camera and static scene

Stereo vision

20

Page 21: Epipolar  Geometry and Stereo Vision

Depth from Stereo• Goal: recover depth by finding image coordinate x’

that corresponds to x

f

x x’

BaselineB

z

C C’

X

f

X

x

x'

21Disparity: Hold up your finger. View it with one eye at a time. Alternate.

Page 22: Epipolar  Geometry and Stereo Vision

Depth from Stereo• Goal: recover depth by finding image coordinate x’ that

corresponds to x• Sub-Problems

1. Calibration: How do we recover the relation of the cameras (if not already known)?

2. Correspondence: How do we search for the matching point x’?

X

x

x'

22

Page 23: Epipolar  Geometry and Stereo Vision

Correspondence Problem

• We have two images taken from cameras with different intrinsic and extrinsic parameters

• How do we match a point in the first image to a point in the second? How can we constrain our search?

x ?

23

Page 24: Epipolar  Geometry and Stereo Vision

Key idea: Epipolar constraint

24

Page 25: Epipolar  Geometry and Stereo Vision

Potential matches for x have to lie on the corresponding line l’.

Potential matches for x’ have to lie on the corresponding line l.

Key idea: Epipolar constraint

x x’

X

x’

X

x’

X

25

Page 26: Epipolar  Geometry and Stereo Vision

• Epipolar Plane – plane containing baseline (1D family)

• Epipoles = intersections of baseline with image planes = projections of the other camera center

• Baseline – line connecting the two camera centers

Epipolar geometry: notationX

x x’

26

Page 27: Epipolar  Geometry and Stereo Vision

• Epipolar Lines - intersections of epipolar plane with image planes (always come in corresponding pairs)

Epipolar geometry: notationX

x x’

• Epipolar Plane – plane containing baseline (1D family)

• Epipoles = intersections of baseline with image planes = projections of the other camera center

• Baseline – line connecting the two camera centers

27

Page 28: Epipolar  Geometry and Stereo Vision

Example: Converging cameras

28

Page 29: Epipolar  Geometry and Stereo Vision

Example: Motion parallel to image plane

29

Page 30: Epipolar  Geometry and Stereo Vision

Example: Forward motion

What would the epipolar lines look like if the camera moves directly forward?

30

Page 31: Epipolar  Geometry and Stereo Vision

e

e’

Example: Forward motion

Epipole has same coordinates in both images.Points move along lines radiating from e: “Focus of expansion”

31

Page 32: Epipolar  Geometry and Stereo Vision

X

x x’

Epipolar constraint: Calibrated case

Given the intrinsic parameters of the cameras:1. Convert to normalized coordinates by pre-multiplying all points with the

inverse of the calibration matrix; set first camera’s coordinate system to world coordinates

XxKx 1 ˆHomogeneous 2d point (3D ray towards X) 2D pixel coordinate

(homogeneous)

3D scene pointXxKx 1 ˆ

3D scene point in 2nd camera’s 3D coordinates 32

Page 33: Epipolar  Geometry and Stereo Vision

X

x x’

Epipolar constraint: Calibrated case

Given the intrinsic parameters of the cameras:1. Convert to normalized coordinates by pre-multiplying all points with the

inverse of the calibration matrix; set first camera’s coordinate system to world coordinates

2. Define some R and t that relate X to X’ as below

txRx ˆˆXxKx 1 ˆ XxKx 1 ˆ

33

Page 34: Epipolar  Geometry and Stereo Vision

An aside: cross product

Vector cross product takes two vectors and returns a third vector that’s perpendicular to both inputs.

So here, c is perpendicular to both a and b, which means the dot product = 0.

Slide source: Kristen Grauman34

Page 35: Epipolar  Geometry and Stereo Vision

Epipolar constraint: Calibrated case

x x’

X

t~

XxKx 1 ˆ XxKx 1 ˆ

ˆ x = Rˆ ′ x + t 0)]ˆ([ˆ xRtx

35Algebraically…

Page 36: Epipolar  Geometry and Stereo Vision

Another aside:Matrix form of cross product

Can be expressed as a matrix multiplication.

cbbb

aaaa

aaba

3

2

1

12

13

23

00

0

00

0

12

13

23

aaaa

aaax

Slide source: Kristen Grauman36

Page 37: Epipolar  Geometry and Stereo Vision

Essential Matrix(Longuet-Higgins, 1981)

Essential matrix

0)]ˆ([ˆ xRtx RtExExT with0ˆˆ

X

x x’

37

Page 38: Epipolar  Geometry and Stereo Vision

X

x x’

Properties of the Essential matrix

• E x’ is the epipolar line associated with x’ (l = E x’)• ETx is the epipolar line associated with x (l’ = ETx)• E e’ = 0 and ETe = 0• E is singular (rank two)• E has five degrees of freedom

– (3 for R, 2 for t because it’s up to a scale)

0)]ˆ([ˆ xRtxDrop ^ below to simplify notation

RtExExT with0ˆˆ

38

Page 39: Epipolar  Geometry and Stereo Vision

The Fundamental Matrix

Fundamental Matrix(Faugeras and Luong, 1992)

0ˆˆ xExT

1with0 KEKFxFx TT

Without knowing K and K’, we can define a similar relation using unknown normalized coordinates

xKx 1ˆ

xKx 1 ˆ

40

Page 40: Epipolar  Geometry and Stereo Vision

Properties of the Fundamental matrix

1with0 KEKFxFx TT

• F x’ is the epipolar line associated with x’ (l = F x’)• FTx is the epipolar line associated with x (l’ = FTx)• F e’ = 0 and FTe = 0• F is singular (rank two): det(F)=0• F has seven degrees of freedom: 9 entries but defined up to scale, det(F)=0

X

x x’

41

Page 41: Epipolar  Geometry and Stereo Vision

Estimating the Fundamental Matrix

• 8-point algorithm– Least squares solution using SVD on equations from 8 pairs of

correspondences– Enforce det(F)=0 constraint using SVD on F

• 7-point algorithm– Use least squares to solve for null space (two vectors) using SVD and 7

pairs of correspondences– Solve for linear combination of null space vectors that satisfies det(F)=0

• Minimize reprojection error– Non-linear least squares

Note: estimation of F (or E) is degenerate for a planar scene.42

Page 42: Epipolar  Geometry and Stereo Vision

8-point algorithm1. Solve a system of homogeneous linear

equationsa. Write down the system of equations

0xx FT

43

Page 43: Epipolar  Geometry and Stereo Vision

8-point algorithm1. Solve a system of homogeneous linear

equationsa. Write down the system of equationsb. Solve f from Af=0 using SVD

Matlab: [U, S, V] = svd(A);f = V(:, end);F = reshape(f, [3 3])’;

44

Page 44: Epipolar  Geometry and Stereo Vision

Need to enforce singularity constraint

45

Page 45: Epipolar  Geometry and Stereo Vision

8-point algorithm1. Solve a system of homogeneous linear

equationsa. Write down the system of equationsb. Solve f from Af=0 using SVD

2. Resolve det(F) = 0 constraint using SVD

Matlab: [U, S, V] = svd(A);f = V(:, end);F = reshape(f, [3 3])’;

Matlab: [U, S, V] = svd(F);S(3,3) = 0;F = U*S*V’;

46

Page 46: Epipolar  Geometry and Stereo Vision

8-point algorithm1. Solve a system of homogeneous linear equations

a. Write down the system of equationsb. Solve f from Af=0 using SVD

2. Resolve det(F) = 0 constraint by SVD

Notes:• Use RANSAC to deal with outliers (sample 8 points)

– How to test for outliers?• Solve in normalized coordinates

– mean=0– standard deviation ~= (1,1,1)– just like with estimating the homography for stitching

47

Page 47: Epipolar  Geometry and Stereo Vision

Comparison of homography estimation and the 8-point algorithm

Homography (No Translation) Fundamental Matrix (Translation)

Assume we have matched points x x’ with outliers

48

Page 48: Epipolar  Geometry and Stereo Vision

Homography (No Translation) Fundamental Matrix (Translation)

Comparison of homography estimation and the 8-point algorithm

Assume we have matched points x x’ with outliers

• Correspondence Relation

1. Normalize image coordinates

2. RANSAC with 4 points– Solution via SVD

3. De-normalize:

0HxxHxx ''

Txx ~ xTx ~

THTH ~1

49

Page 49: Epipolar  Geometry and Stereo Vision

Comparison of homography estimation and the 8-point algorithm

Homography (No Translation) Fundamental Matrix (Translation)

• Correspondence Relation

1. Normalize image coordinates

2. RANSAC with 8 points– Initial solution via SVD– Enforce by SVD

3. De-normalize:

• Correspondence Relation

1. Normalize image coordinates

2. RANSAC with 4 points– Solution via SVD

3. De-normalize:

Assume we have matched points x x’ with outliers

0HxxHxx ''

Txx ~ xTx ~

THTH ~1

Txx ~ xTx ~

TFTF ~T

0~det F

0 Fxx T

50

Page 50: Epipolar  Geometry and Stereo Vision

7-point algorithm

Faster (need fewer points) and could be more robust (fewer points), but also need to check for degenerate cases

51

Page 51: Epipolar  Geometry and Stereo Vision

“Gold standard” algorithm• Use 8-point algorithm to get initial value of F• Use F to solve for P and P’ (discussed later)• Jointly solve for 3d points X and F that

minimize the squared re-projection error

X

x x'

See Algorithm 11.2 and Algorithm 11.3 in HZ (pages 284-285) for details 52

Page 52: Epipolar  Geometry and Stereo Vision

Comparison of estimation algorithms

8-point Normalized 8-point Nonlinear least squares

Av. Dist. 1 2.33 pixels 0.92 pixel 0.86 pixel

Av. Dist. 2 2.18 pixels 0.85 pixel 0.80 pixel 53

Page 53: Epipolar  Geometry and Stereo Vision

We can get projection matrices P and P’ up to a projective ambiguity

Code:function P = vgg_P_from_F(F)[U,S,V] = svd(F);e = U(:,3);P = [-vgg_contreps(e)*F e];

0IP | e|FeP 0 Fe T

See HZ p. 255-256

K’*translationK’*rotation

If we know the intrinsic matrices (K and K’), we can resolve the ambiguity54

Page 54: Epipolar  Geometry and Stereo Vision

From epipolar geometry to camera calibration

• Estimating the fundamental matrix is known as “weak calibration”

• If we know the calibration matrices of the two cameras, we can estimate the essential matrix: E = KTFK’

• The essential matrix gives us the relative rotation and translation between the cameras, or their extrinsic parameters

55

Page 55: Epipolar  Geometry and Stereo Vision

Let’s recap…• Fundamental matrix song

56

Page 56: Epipolar  Geometry and Stereo Vision

Next time: Stereo

Fuse a calibrated binocular stereo pair to produce a depth image

image 1 image 2

Dense depth map

57

Page 57: Epipolar  Geometry and Stereo Vision

Next class: structure from motion

58

Page 58: Epipolar  Geometry and Stereo Vision

Questions?

See you Thursday!

59Slide credit: Devi Parikh