13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the...

50
Stereo Vision 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University

Transcript of 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the...

Page 1: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Stereo Vision16-385 Computer Vision (Kris Kitani)

Carnegie Mellon University

Page 2: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

What’s different between these two images?

Page 3: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e
Page 4: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e
Page 5: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Objects that are close move more or less?

Page 6: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

The amount of horizontal movement is inversely proportional to …

Page 7: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

The amount of horizontal movement is inversely proportional to …

… the distance from the camera.

Page 8: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0

image plane

Page 9: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0ff x

x

0 image plane

Page 10: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0ff x

x

0

Z

Page 11: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0

(baseline)b

ff x

x

0

Z

Page 12: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0

(baseline)b

ff x

x

0

X

Z

=x

f

Z

Page 13: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0

(baseline)b

ff x

x

0

X

Z

=x

f

Z

b�X

Z

=x

0

f

Page 14: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0

(baseline)b

ff x

x

0

X

Z

=x

f

Z

d = x� x

0

=bf

Z

Disparity

b�X

Z

=x

0

f

Page 15: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

X

O O0

(baseline)b

ff x

x

0

X

Z

=x

f

Z

d = x� x

0

=bf

Z

Disparityinversely proportional to depth

b�X

Z

=x

0

f

Page 16: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Nomad robot searches for meteorites in Antartica http://www.frc.ri.cmu.edu/projects/meteorobot/index.html

Real-time stereo sensing

Page 17: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e
Page 18: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Subaru Eyesight system

Pre-collision braking

Page 19: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e
Page 20: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

How so you compute depth from a stereo pair?

Page 21: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

1. Rectify images (make epipolar lines horizontal)

2. For each pixel a. Find epipolar line b. Scan line for best match c. Compute depth from disparity

Z =bf

d

Page 22: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

How can you make the epipolar lines horizontal?

Page 23: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

It’s hard to make the image planes exactly parallel

Page 24: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

How can you make the epipolar lines horizontal?

Page 25: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

t

x

x’

How can you make the epipolar lines horizontal?

R = I t = (T, 0, 0)

When this relationship holds:

Page 26: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

t

x

x’

How can you make the epipolar lines horizontal?

R = I t = (T, 0, 0)

!!!

"

#

$$$

%

&

−=×=

0000

000

TTRtE

RtExExT ×==" ,0

Let’s try this out…

This always has to hold

When this relationship holds:

Page 27: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

t

x

x’

How can you make the epipolar lines horizontal?

R = I t = (T, 0, 0)

!!!

"

#

$$$

%

&

−=×=

0000

000

TTRtE

( ) ( ) vTTvvTTvuv

u

TTvu !==

"""

#

$

%%%

&

'

!

−="""

#

$

%%%

&

'!

!

)))

*

+

,,,

-

.

− 00

10100

00000

1

RtExExT ×==" ,0Write out the constraint

Let’s try this out…

This always has to hold

When this relationship holds:

Page 28: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

t

x

x’

How can you make the epipolar lines horizontal?

R = I t = (T, 0, 0)

!!!

"

#

$$$

%

&

−=×=

0000

000

TTRtE

( ) ( ) vTTvvTTvuv

u

TTvu !==

"""

#

$

%%%

&

'

!

−="""

#

$

%%%

&

'!

!

)))

*

+

,,,

-

.

− 00

10100

00000

1

RtExExT ×==" ,0

y coordinate is always the same!

Write out the constraint

Let’s try this out…

This always has to hold

The image of a 3D point will always be on the same

horizontal line

When this relationship holds:

Page 29: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

What is stereo rectification?

Page 30: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

What is stereo rectification?

Page 31: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

What is stereo rectification?

Reproject image planes onto a common plane parallel to the line between camera centers

Page 32: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

What is stereo rectification?

Reproject image planes onto a common plane parallel to the line between camera centers

Need two homographies (3x3 transform), one for each input image reprojection

C. Loop and Z. Zhang. Computing Rectifying Homographies for Stereo Vision.Computer Vision and Pattern Recognition, 1999.

Page 33: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Stereo Rectification1. Rotate the right camera by R

(aligns camera coordinate system orientation only)

2. Rotate (rectify) the left camera so that the epipole is at infinity

3. Rotate (rectify) the right camera so that the epipole is at infinity

4. Adjust the scale

Page 34: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

1. Compute E to get R

2. Rotate right image by R

3. Rotate both images by Rrect

4. Scale both images by H

Stereo Rectification:

Page 35: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

rotate by R

1. Compute E to get R

2. Rotate right image by R

3. Rotate both images by Rrect

4. Scale both images by H

Stereo Rectification:

Page 36: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

1. Compute E to get R

2. Rotate right image by R

3. Rotate both images by Rrect

4. Scale both images by H

Stereo Rectification:

Page 37: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

rotate by Rrect

rotate by Rrect

1. Compute E to get R

2. Rotate right image by R

3. Rotate both images by Rrect

4. Scale both images by H

Stereo Rectification:

Page 38: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

1. Compute E to get R

2. Rotate right image by R

3. Rotate both images by Rrect

4. Scale both images by H

Stereo Rectification:

Page 39: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

scale by H

scale by H

1. Compute E to get R

2. Rotate right image by R

3. Rotate both images by Rrect

4. Scale both images by H

Stereo Rectification:

Page 40: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

1. Compute E to get R

2. Rotate right image by R

3. Rotate both images by Rrect

4. Scale both images by H

Stereo Rectification:

Page 41: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

What can we do after rectification?

Page 42: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Setting the epipole to infinity (Building Rrect from e)

Let

r1 = e1 =T

||T ||

Rrect =

2

4r>1r>2r>3

3

5

r2 =1q

T 2x

+ T 2y

⇥�T

y

Tx

0⇤

r3 = r1 ⇥ r2

epipole coincides with translation vector

cross product of e and the direction vector of

the optical axis

orthogonal vector

Given: epipole e

(using SVD on E) (translation from E)

Page 43: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Rrecte1 =

2

4r>1 e1r>2 e1r>3 e1

3

5 =

2

4???

3

5

r1 = e1 =T

||T ||If and r2 r3 orthogonal

then

Page 44: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Rrecte1 =

2

4r>1 e1r>2 e1r>3 e1

3

5 =

2

4100

3

5

r1 = e1 =T

||T ||If and r2 r3 orthogonal

then

Where is this point located on the image plane?

Page 45: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Rrecte1 =

2

4r>1 e1r>2 e1r>3 e1

3

5 =

2

4100

3

5

r1 = e1 =T

||T ||If and r2 r3 orthogonal

then

Where is this point located on the image plane?

At x-infinity

Page 46: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Stereo Rectification Algorithm

1. Estimate E using the 8 point algorithm (SVD)

2. Estimate the epipole e (SVD of E)

3. Build Rrect from e

4. Decompose E into R and T

5. Set R1=Rrect and R2 = RRrect

6. Rotate each left camera point (warp image) [x’ y’ z’] = R1 [x y z]

7. Rectified points as p = f/z’[x’ y’ z’]

8. Repeat 6 and 7 for right camera points using R2

Page 47: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Stereo Rectification Algorithm

1. Estimate E using the 8 point algorithm

2. Estimate the epipole e (solve Ee=0)

3. Build Rrect from e

4. Decompose E into R and T

5. Set R1=Rrect and R2 = RRrect

6. Rotate each left camera point x’~ Hx where H = KR1 *You may need to alter the focal length (inside K) to keep points within the original image size

7. Repeat 6 and 7 for right camera points using R2

Page 48: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Unrectified

Page 49: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Unrectified

Rectified

Page 50: 13.1 Stereo Rectification16385/s17/Slides/13.1_Stereo_Rectification.pdf · 1. Estimate E using the 8 point algorithm 2. Estimate the epipole e (solve Ee=0) 3. Build R rect from e

Unrectified

Rectified