back to the homography: the whyfidler/slides/2018/csc420/lecture11.pdf · 2018-02-26 · homography...

85
Back to the Homography: The Why Sanja Fidler CSC420: Intro to Image Understanding 1 / 27

Upload: others

Post on 03-Aug-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Back to the Homography: The Why

Sanja Fidler CSC420: Intro to Image Understanding 1 / 27

Page 2: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

In Lecture 9 we said that a homography is a transformation thatmaps a projective plane to another projective plane.We shamelessly dumped the following equation for homographywithout explanation:

w

2

4x

0

y

0

1

3

5 =

2

4a b c

d e f

g h i

3

5

2

4x

y

1

3

5

Sanja Fidler CSC420: Intro to Image Understanding 2 / 27

Page 3: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Let’s revisit our transformation in the (new) light of perspective projection.

Sanja Fidler CSC420: Intro to Image Understanding 3 / 27

Page 4: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Let’s revisit our transformation in the (new) light of perspective projection.

Figure: We have our object in two di↵erent worlds, in two di↵erent poses relativeto camera, two di↵erent photographers, and two di↵erent cameras.

Sanja Fidler CSC420: Intro to Image Understanding 3 / 27

Page 5: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Let’s revisit our transformation in the (new) light of perspective projection.

Figure: Our object is a plane. Each plane is characterized by one point d on theplane and two independent vectors a and b on the plane.

Sanja Fidler CSC420: Intro to Image Understanding 3 / 27

Page 6: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Let’s revisit our transformation in the (new) light of perspective projection.

Figure: Then any other point X on the plane can be written as: X = d+↵a+ �b.

Sanja Fidler CSC420: Intro to Image Understanding 3 / 27

Page 7: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Let’s revisit our transformation in the (new) light of perspective projection.

Figure: Any two Chicken Run DVDs on our planet are related by sometransformation T . We’ll compute it, don’t worry.

Sanja Fidler CSC420: Intro to Image Understanding 3 / 27

Page 8: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Let’s revisit our transformation in the (new) light of perspective projection.

Figure: Each object is seen by a di↵erent camera and thus projects to thecorresponding image plane with di↵erent camera intrinsics.

Sanja Fidler CSC420: Intro to Image Understanding 3 / 27

Page 9: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Let’s revisit our transformation in the (new) light of perspective projection.

Figure: Given this, the question is what’s the transformation that maps the DVDon the first image to the DVD in the second image?

Sanja Fidler CSC420: Intro to Image Understanding 3 / 27

Page 10: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Each point on a plane can be written as: X = d+ ↵ · a+ � · b, where d is apoint, and a and b are two independent directions on the plane.

Let’s have two di↵erent planes in 3D:

First plane : X1 = d1 + ↵ · a1 + � · b1Second plane : X2 = d2 + ↵ · a2 + � · b2

Via ↵ and �, the two points X1 and X2 are in the same location relative toeach plane.

We can rewrite this using homogeneous coordinates:

First plane : X1 =⇥a1 b1 d1

⇤2

4↵�1

3

5 = A1

2

4↵�1

3

5

Second plane : X2 =⇥a2 b2 d2

⇤2

4↵�1

3

5 = A2

2

4↵�1

3

5

Careful: A1 =⇥a1 b1 d1

⇤and A2 =

⇥a2 b2 d2

⇤are 3⇥ 3 matrices.

Sanja Fidler CSC420: Intro to Image Understanding 4 / 27

Page 11: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Each point on a plane can be written as: X = d+ ↵ · a+ � · b, where d is apoint, and a and b are two independent directions on the plane.

Let’s have two di↵erent planes in 3D:

First plane : X1 = d1 + ↵ · a1 + � · b1Second plane : X2 = d2 + ↵ · a2 + � · b2

Via ↵ and �, the two points X1 and X2 are in the same location relative toeach plane.

We can rewrite this using homogeneous coordinates:

First plane : X1 =⇥a1 b1 d1

⇤2

4↵�1

3

5 = A1

2

4↵�1

3

5

Second plane : X2 =⇥a2 b2 d2

⇤2

4↵�1

3

5 = A2

2

4↵�1

3

5

Careful: A1 =⇥a1 b1 d1

⇤and A2 =

⇥a2 b2 d2

⇤are 3⇥ 3 matrices.

Sanja Fidler CSC420: Intro to Image Understanding 4 / 27

Page 12: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Each point on a plane can be written as: X = d+ ↵ · a+ � · b, where d is apoint, and a and b are two independent directions on the plane.

Let’s have two di↵erent planes in 3D:

First plane : X1 = d1 + ↵ · a1 + � · b1Second plane : X2 = d2 + ↵ · a2 + � · b2

Via ↵ and �, the two points X1 and X2 are in the same location relative toeach plane.

We can rewrite this using homogeneous coordinates:

First plane : X1 =⇥a1 b1 d1

⇤2

4↵�1

3

5 = A1

2

4↵�1

3

5

Second plane : X2 =⇥a2 b2 d2

⇤2

4↵�1

3

5 = A2

2

4↵�1

3

5

Careful: A1 =⇥a1 b1 d1

⇤and A2 =

⇥a2 b2 d2

⇤are 3⇥ 3 matrices.

Sanja Fidler CSC420: Intro to Image Understanding 4 / 27

Page 13: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

Each point on a plane can be written as: X = d+ ↵ · a+ � · b, where d is apoint, and a and b are two independent directions on the plane.

Let’s have two di↵erent planes in 3D:

First plane : X1 = d1 + ↵ · a1 + � · b1Second plane : X2 = d2 + ↵ · a2 + � · b2

Via ↵ and �, the two points X1 and X2 are in the same location relative toeach plane.

We can rewrite this using homogeneous coordinates:

First plane : X1 =⇥a1 b1 d1

⇤2

4↵�1

3

5 = A1

2

4↵�1

3

5

Second plane : X2 =⇥a2 b2 d2

⇤2

4↵�1

3

5 = A2

2

4↵�1

3

5

Careful: A1 =⇥a1 b1 d1

⇤and A2 =

⇥a2 b2 d2

⇤are 3⇥ 3 matrices.

Sanja Fidler CSC420: Intro to Image Understanding 4 / 27

Page 14: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

In 3D, a transformation between the planes is given by:

X2 = T X1

There is one transformation T between every pair of points X1 and X2.

Expand it:

A2

2

4↵�1

3

5 = T A1

2

4↵�1

3

5 for every ↵,�

Then it follows: T = A2A�11 , with T a 3⇥ 3 matrix.

Let’s look at what happens in projective (image) plane. Note that we haveeach plane in a separate image and the two images may not have the samecamera intrinsic parameters. Denote them with K1 and K2.

w1

2

4x1

y1

1

3

5 = K1X1 and w2

2

4x2

y2

1

3

5 = K2X2

Sanja Fidler CSC420: Intro to Image Understanding 5 / 27

Page 15: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

From previous slide:

w1

2

4x1

y1

1

3

5 = K1X1 and w2

2

4x2

y2

1

3

5 = K2X2

Insert X2 = T X1 into equality on the right:

w2

2

4x2

y2

1

3

5 = K2 T X1

Sanja Fidler CSC420: Intro to Image Understanding 6 / 27

Page 16: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

From previous slide:

w1

2

4x1

y1

1

3

5 = K1X1 and w2

2

4x2

y2

1

3

5 = K2X2

Insert X2 = T X1 into equality on the right:

w2

2

4x2

y2

1

3

5 = K2 T X1 = K2 T (K�11 K1)X1

Sanja Fidler CSC420: Intro to Image Understanding 6 / 27

Page 17: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

From previous slide:

w1

2

4x1

y1

1

3

5 = K1X1 and w2

2

4x2

y2

1

3

5 = K2X2

Insert X2 = T X1 into equality on the right:

w2

2

4x2

y2

1

3

5 = K2 T X1 = K2 T (K�11 K1)X1| {z }

w1

2

664

x1

y1

1

3

775

Sanja Fidler CSC420: Intro to Image Understanding 6 / 27

Page 18: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

From previous slide:

w1

2

4x1

y1

1

3

5 = K1X1 and w2

2

4x2

y2

1

3

5 = K2X2

Insert X2 = T X1 into equality on the right:

w2

2

4x2

y2

1

3

5 = K2 T X1 = K2 T (K�11 K1)X1 = w1K2 T K

�11

2

4x1

y1

1

3

5

Sanja Fidler CSC420: Intro to Image Understanding 6 / 27

Page 19: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

From previous slide:

w1

2

4x1

y1

1

3

5 = K1X1 and w2

2

4x2

y2

1

3

5 = K2X2

Insert X2 = T X1 into equality on the right:

w2

2

4x2

y2

1

3

5 = K2 T X1 = K2 T (K�11 K1)X1 = w1 K2 T K

�11| {z }

3⇥3 matrix

2

4x1

y1

1

3

5

Sanja Fidler CSC420: Intro to Image Understanding 6 / 27

Page 20: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

From previous slide:

w1

2

4x1

y1

1

3

5 = K1X1 and w2

2

4x2

y2

1

3

5 = K2X2

Insert X2 = T X1 into equality on the right:

w2

2

4x2

y2

1

3

5 = K2 T X1 = K2 T (K�11 K1)X1 = w1 K2 T K

�11| {z }

3⇥3 matrix

2

4x1

y1

1

3

5

And finally:

w2

2

4x2

y2

1

3

5 =

2

4a b c

d e f

g h i

3

5

2

4x1

y1

1

3

5

Sanja Fidler CSC420: Intro to Image Understanding 6 / 27

Page 21: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

The nice thing about homography is that once we have it, we can computewhere any point from one projective plane maps to on the second projectiveplane. We do not need to know the 3D location of that point. We don’teven need to know the camera parameters.

We still owe one more explanation for Lecture 9.

Sanja Fidler CSC420: Intro to Image Understanding 7 / 27

Page 22: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Homography

The nice thing about homography is that once we have it, we can computewhere any point from one projective plane maps to on the second projectiveplane. We do not need to know the 3D location of that point. We don’teven need to know the camera parameters.

We still owe one more explanation for Lecture 9.

Sanja Fidler CSC420: Intro to Image Understanding 7 / 27

Page 23: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Remember Panorama Stitching from Lecture 9?

[Source: Fernando Flores-Mangas]

Sanja Fidler CSC420: Intro to Image Understanding 8 / 27

Page 24: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Remember Panorama Stitching from Lecture 9?

Each pair of images is related by homography. Why?[Source: Fernando Flores-Mangas]

Sanja Fidler CSC420: Intro to Image Understanding 8 / 27

Page 25: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Rotating the Camera

Rotating my camera with R is the same as rotating the 3D points with R

T

(inverse of R):X2 = R

TX1

where X1 is a 3D point in the coordinate system of the first camera and X2

the 3D point in the coordinate system of the rotated camera.

We can use the same trick as before, where we have T = R :

w1

2

4x1

y1

1

3

5 = KX1 and w2

2

4x2

y2

1

3

5 = KX2

w2

2

4x2

y2

1

3

5 = w1 K R K

�1| {z }3⇥3 matrix

2

4x1

y1

1

3

5

And this is a homography

Sanja Fidler CSC420: Intro to Image Understanding 9 / 27

Page 26: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Rotating the Camera

Rotating my camera with R is the same as rotating the 3D points with R

T

(inverse of R):X2 = R

TX1

where X1 is a 3D point in the coordinate system of the first camera and X2

the 3D point in the coordinate system of the rotated camera.

We can use the same trick as before, where we have T = R :

w1

2

4x1

y1

1

3

5 = KX1 and w2

2

4x2

y2

1

3

5 = KX2

w2

2

4x2

y2

1

3

5 = w1 K R K

�1| {z }3⇥3 matrix

2

4x1

y1

1

3

5

And this is a homography

Sanja Fidler CSC420: Intro to Image Understanding 9 / 27

Page 27: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Rotating the Camera

Rotating my camera with R is the same as rotating the 3D points with R

T

(inverse of R):X2 = R

TX1

where X1 is a 3D point in the coordinate system of the first camera and X2

the 3D point in the coordinate system of the rotated camera.

We can use the same trick as before, where we have T = R :

w1

2

4x1

y1

1

3

5 = KX1 and w2

2

4x2

y2

1

3

5 = KX2

w2

2

4x2

y2

1

3

5 = w1 K R K

�1| {z }3⇥3 matrix

2

4x1

y1

1

3

5

And this is a homography

Sanja Fidler CSC420: Intro to Image Understanding 9 / 27

Page 28: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

So if I take a picture and then rotate the camera and take another picture,the first and second picture are related via homography (assuming the scenedidn’t change in between)

Sanja Fidler CSC420: Intro to Image Understanding 10 / 27

Page 29: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

So if I take a picture and then rotate the camera and take another picture,the first and second picture are related via homography (assuming the scenedidn’t change in between)

What if I move my camera?

Sanja Fidler CSC420: Intro to Image Understanding 10 / 27

Page 30: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

If I move the camera by t, then: X2 = X1� t. Let’s try the same trick again:

w2

2

4x2

y2

1

3

5 = K X2

Sanja Fidler CSC420: Intro to Image Understanding 11 / 27

Page 31: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

If I move the camera by t, then: X2 = X1� t. Let’s try the same trick again:

w2

2

4x2

y2

1

3

5 = K X2 = K (X1 � t)

Sanja Fidler CSC420: Intro to Image Understanding 11 / 27

Page 32: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

If I move the camera by t, then: X2 = X1� t. Let’s try the same trick again:

w2

2

4x2

y2

1

3

5 = K X2 = K (X1| {z }

w1

2

664

x1

y1

1

3

775

�t)

Sanja Fidler CSC420: Intro to Image Understanding 11 / 27

Page 33: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

If I move the camera by t, then: X2 = X1� t. Let’s try the same trick again:

w2

2

4x2

y2

1

3

5 = K X2 = K (X1 � t) = w1

2

4x1

y1

1

3

5� Kt

Sanja Fidler CSC420: Intro to Image Understanding 11 / 27

Page 34: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

If I move the camera by t, then: X2 = X1� t. Let’s try the same trick again:

w2

2

4x2

y2

1

3

5 = K X2 = K (X1 � t) = w1

2

4x1

y1

1

3

5� Kt

Hmm... Di↵erent values of w1 give me di↵erent points in the second image.

So even if I have K and t it seems I can’t compute where a point from thefirst image projects to in the second image.

Sanja Fidler CSC420: Intro to Image Understanding 11 / 27

Page 35: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

If I move the camera by t, then: X2 = X1� t. Let’s try the same trick again:

w2

2

4x2

y2

1

3

5 = K X2 = K (X1 � t) = w1

2

4x1

y1

1

3

5� Kt

Hmm... Di↵erent values of w1 give me di↵erent points in the second image.

So even if I have K and t it seems I can’t compute where a point from thefirst image projects to in the second image.

From

w1

2

4x1

y1

1

3

5 = KX1

we know that di↵erent w1 mean di↵erent points X1 on the projective line

Sanja Fidler CSC420: Intro to Image Understanding 11 / 27

Page 36: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

If I move the camera by t, then: X2 = X1� t. Let’s try the same trick again:

w2

2

4x2

y2

1

3

5 = K X2 = K (X1 � t) = w1

2

4x1

y1

1

3

5� Kt

Hmm... Di↵erent values of w1 give me di↵erent points in the second image.

So even if I have K and t it seems I can’t compute where a point from thefirst image projects to in the second image.

From

w1

2

4x1

y1

1

3

5 = KX1

we know that di↵erent w1 mean di↵erent points X1 on the projective line

Where (x1, y1) maps to in the 2nd image depends on the 3D location of X1!

Sanja Fidler CSC420: Intro to Image Understanding 11 / 27

Page 37: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

Summary: So if I move the camera, I can’t easily map one image to theother. The mapping depends on the 3D scene behind the image.

What about the opposite, what if I know that points (x1, y1) in the firstimage and (x2, y2) in the second belong to the same 3D point?

Sanja Fidler CSC420: Intro to Image Understanding 12 / 27

Page 38: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

Summary: So if I move the camera, I can’t easily map one image to theother. The mapping depends on the 3D scene behind the image.

What about the opposite, what if I know that points (x1, y1) in the firstimage and (x2, y2) in the second belong to the same 3D point?

Sanja Fidler CSC420: Intro to Image Understanding 12 / 27

Page 39: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

Summary: So if I move the camera, I can’t easily map one image to theother. The mapping depends on the 3D scene behind the image.

What about the opposite, what if I know that points (x1, y1) in the firstimage and (x2, y2) in the second belong to the same 3D point?

Sanja Fidler CSC420: Intro to Image Understanding 12 / 27

Page 40: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

What If I Move the Camera?

Summary: So if I move the camera, I can’t easily map one image to theother. The mapping depends on the 3D scene behind the image.

What about the opposite, what if I know that points (x1, y1) in the firstimage and (x2, y2) in the second belong to the same 3D point?

This great fact is called stereo

This brings us to the two-view geometry, which we’ll look at next

Sanja Fidler CSC420: Intro to Image Understanding 13 / 27

Page 41: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Summary – Stu↵ You Need To Know

Perspective Projection:

If point Q is in camera’s coordinate system:

Q = (X ,Y ,Z )T ! q =⇣

f ·XZ

+ p

x

, f ·YZ

+ p

y

⌘T

Same as: Q = (X ,Y ,Z )T !

2

64w · xw · yw

3

75 = K

2

64X

Y

Z

3

75 ! q =

"x

y

#

where K =

2

64f 0 p

x

0 f p

y

0 0 1

3

75 is camera intrinsic matrix

If Q is in world coordinate system, then the full projection is characterized

by a 3⇥ 4 matrix P:2

64w · xw · yw

3

75 = K⇥R | t

⇤| {z }

P

2

6664

X

Y

Z

1

3

7775

Sanja Fidler CSC420: Intro to Image Understanding 14 / 27

Page 42: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Summary – Stu↵ You Need To Know

Perspective Projection:

All parallel lines in 3D with the same direction meet in one, so-called

vanishing point in the image

All lines that lie on a plane have vanishing points that lie on a line, so-called

vanishing line

All parallel planes in 3D have the same vanishing line in the image

Orthographic Projection

Projections simply drops the Z coordinate:

Q =

2

6664

X

Y

Z

1

3

7775!

2

64X

Y

1

3

75 =

2

641 0 0 0

0 1 0 0

0 0 0 1

3

75

2

6664

X

Y

Z

1

3

7775

Parallel lines in 3D are parallel in the image

Sanja Fidler CSC420: Intro to Image Understanding 15 / 27

Page 43: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth

Getting the 3D Scene Behind the Image

Sanja Fidler CSC420: Intro to Image Understanding 16 / 27

Page 44: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

We know that it’s impossible to get depth (Z) from a single image

[Pic adopted from: J. Hays]Sanja Fidler CSC420: Intro to Image Understanding 17 / 27

Page 45: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

We know that it’s impossible to get depth (Z) from a single image

[Pic from: S. Lazebnik]

Sanja Fidler CSC420: Intro to Image Understanding 17 / 27

Page 46: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Nothing is impossible!

Sanja Fidler CSC420: Intro to Image Understanding 18 / 27

Page 47: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

When present, we can use certain cues to get depth (3D) from one image

Can you come up with (at least) 8 ways of getting depth from a singleimage?

Sanja Fidler CSC420: Intro to Image Understanding 18 / 27

Page 48: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

1

Shape from Shading

Sanja Fidler CSC420: Intro to Image Understanding 18 / 27

Page 49: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Shape from Shading

[Slide credit: J. Hays, pic from: Prados & Faugeras 2006]

Sanja Fidler CSC420: Intro to Image Understanding 19 / 27

Page 50: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

2

Shape from Texture

Sanja Fidler CSC420: Intro to Image Understanding 19 / 27

Page 51: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Shape from Texture: What do you see in the image?

[From the PhD Thesis: A.M. Loh. The recovery of 3-D structure using visual texture patterns]

Sanja Fidler CSC420: Intro to Image Understanding 20 / 27

Page 52: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Shape from Texture

[From the PhD Thesis: A.M. Loh. The recovery of 3-D structure using visual texture patterns]Sanja Fidler CSC420: Intro to Image Understanding 20 / 27

Page 53: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Shape from Texture

[From the PhD Thesis: A.M. Loh. The recovery of 3-D structure using visual texture patterns]

Sanja Fidler CSC420: Intro to Image Understanding 20 / 27

Page 54: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Shape from Texture: And quite a lot of stu↵ around us is textured

[From the PhD Thesis: A.M. Loh. The recovery of 3-D structure using visual texture patterns]

Sanja Fidler CSC420: Intro to Image Understanding 20 / 27

Page 55: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

3

Shape from Focus/De-focus

Sanja Fidler CSC420: Intro to Image Understanding 20 / 27

Page 56: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Shape from Focus/De-focus

[Slide credit: J. Hays, pics from: H. Jin and P. Favaro, 2002]Sanja Fidler CSC420: Intro to Image Understanding 21 / 27

Page 57: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

4

Depth Ordering via Occlusion Reasoning

Sanja Fidler CSC420: Intro to Image Understanding 21 / 27

Page 58: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Sanja Fidler CSC420: Intro to Image Understanding 22 / 27

Page 59: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Y and T junctions are great indicators of occlusionSanja Fidler CSC420: Intro to Image Understanding 22 / 27

Page 60: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Y and T junctions are great indicators of occlusionSanja Fidler CSC420: Intro to Image Understanding 22 / 27

Page 61: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Non-occluding pumpkins are a problemSanja Fidler CSC420: Intro to Image Understanding 22 / 27

Page 62: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Occlusion gives us ordering in depth

[Slide credit: J. Hays, Painting: Rene Magritt’e Le Blanc-Seing]Sanja Fidler CSC420: Intro to Image Understanding 22 / 27

Page 63: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

5

Depth from Google

Sanja Fidler CSC420: Intro to Image Understanding 22 / 27

Page 64: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: We go to Italy and take this picture.

[Paper: C. Wang, K. Wilson, N. Snavely, Accurate Georegistration of Point Clouds using

Geographic Data, 3DV 2013. http://www.cs.cornell.edu/projects/georegister/docs/georegister_3dv.pdf]

Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 65: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: We can match it to Google Street View (compute accurate location andviewing angle). See paper below.

[Paper: C. Wang, K. Wilson, N. Snavely, Accurate Georegistration of Point Clouds using

Geographic Data, 3DV 2013. http://www.cs.cornell.edu/projects/georegister/docs/georegister_3dv.pdf]

Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 66: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Depth from Google: “Borrow” depth from Google’s Street View Z-bu↵er.

[Paper: C. Wang, K. Wilson, N. Snavely, Accurate Georegistration of Point Clouds using

Geographic Data, 3DV 2013. http://www.cs.cornell.edu/projects/georegister/docs/georegister_3dv.pdf]

Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 67: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Depth from Google: “Borrow” depth from Google’s Street View Z-bu↵er.

[Paper: C. Wang, K. Wilson, N. Snavely, Accurate Georegistration of Point Clouds using

Geographic Data, 3DV 2013. http://www.cs.cornell.edu/projects/georegister/docs/georegister_3dv.pdf]Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 68: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Depth from Google: “Borrow” depth from Google’s Street View Z-bu↵er

http://inear.se/urbanjungle/

Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 69: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Depth from Google: Once you have depth you can render cool stu↵

http://inear.se/urbanjungle/

Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 70: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Depth from Google: Recognize this?

http://inear.se/urbanjungle/

Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 71: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

6

Depth via Recognition

Sanja Fidler CSC420: Intro to Image Understanding 23 / 27

Page 72: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Get 3D models of objects (lots available online, e.g. Google 3D Warehouse)

Figure: CAD models of IKEA furniture from Lim et al.

[Joseph J. Lim, Hamed Pirsiavash, Antonio Torralba. Parsing IKEA Objects: Fine PoseEstimation. ICCV’13]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 27

Page 73: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Match (align) 3D models with image (estimate the projection matrix P)

Figure: Match CAD models to image

[Joseph J. Lim, Hamed Pirsiavash, Antonio Torralba. Parsing IKEA Objects: Fine PoseEstimation. ICCV’13]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 27

Page 74: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Match (align) 3D models with image (estimate the projection matrix P)

Figure: Render depth from the CAD model.

[Saurabh Gupta, Pablo Arbelaez, Ross Girshick, Jitendra Malik. Aligning 3D Models to RGB-DImages of Cluttered Scenes. CVPR’15 ]

Sanja Fidler CSC420: Intro to Image Understanding 24 / 27

Page 75: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

7

Depth via Machine Learning

Sanja Fidler CSC420: Intro to Image Understanding 24 / 27

Page 76: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Collect training data: for example RGB-D data acquired by Kinect

Train classifiers/regressors

Figure: The NYUv2 dataset: RGB-D images collected with Kinect

[Nathan Silberman, Pushmeet Kohli, Derek Hoiem, Rob Fergus. Indoor Segmentation andSupport Inference from RGBD Images. ECCV’12.]http://cs.nyu.edu/

~

silberman/datasets/nyu_depth_v2.html

Sanja Fidler CSC420: Intro to Image Understanding 25 / 27

Page 77: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image(Red color: pixels closer to the camera, blue: pixels further away from camera.)

(a) image (b) predicted depth (c) ground-truth depth

Figure: Obtain impressive results.[Christian Hane, L’ubor Ladicky, Marc Pollefeys. Direction Matters: Depth Estimation with a Surface Normal Classifier.CVPR’15]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 27

Page 78: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Train Convolutional Neural Nets (CNNs)

Figure: CNN architecture from Eigen et al.

[David Eigen, Christian Puhrsch, Rob Fergus. Depth Map Prediction from a Single Image usinga Multi-Scale Deep Network. NIPS’14]Code: http://www.cs.nyu.edu/

~

deigen/depth/

Sanja Fidler CSC420: Intro to Image Understanding 25 / 27

Page 79: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Train Convolutional Neural Nets (CNNs)

(a) image (b) predicted depth (c) ground-truth depth

Figure: Results from Eigen et al.

[David Eigen, Christian Puhrsch, Rob Fergus. Depth Map Prediction from a Single Image usinga Multi-Scale Deep Network. NIPS’14]Code: http://www.cs.nyu.edu/

~

deigen/depth/

Sanja Fidler CSC420: Intro to Image Understanding 25 / 27

Page 80: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Train Convolutional Neural Nets (CNNs) to predict surface normals insteadof depth (works very well!)

Figure: Predict surface normals via CNNs

[Xiaolong Wang, David F. Fouhey, Abhinav Gupta. Designing Deep Networks for SurfaceNormal Estimation. CVPR’15]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 27

Page 81: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Train Convolutional Neural Nets (CNNs) to predict surface normals insteadof depth (works very well!)

Figure: Results

[Xiaolong Wang, David F. Fouhey, Abhinav Gupta. Designing Deep Networks for SurfaceNormal Estimation. CVPR’15]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 27

Page 82: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

8

Depth by Tricking Your Brain

Sanja Fidler CSC420: Intro to Image Understanding 25 / 27

Page 83: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Depth by tricking the brain: do you see the 3D object?

[Source: J. Hays, Pics from: http://magiceye.com]Sanja Fidler CSC420: Intro to Image Understanding 26 / 27

Page 84: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Depth from a Monocular Image

Figure: Depth by tricking the brain

[Source: J. Hays, Pics from: http://magiceye.com]Sanja Fidler CSC420: Intro to Image Understanding 26 / 27

Page 85: Back to the Homography: The Whyfidler/slides/2018/CSC420/lecture11.pdf · 2018-02-26 · Homography Each point on a plane can be written as: X = d+↵·a+ ·b,whered is a point, and

Next Time:

Depth from Stereo

Sanja Fidler CSC420: Intro to Image Understanding 27 / 27