Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce]...

156
Camera Models Sanja Fidler CSC420: Intro to Image Understanding 1 / 67

Transcript of Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce]...

Page 1: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Models

Sanja Fidler CSC420: Intro to Image Understanding 1 / 67

Page 2: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Textbook

If you are interested, this book has it all:

A. Zisserman and R. Hartley

Multiview Geometry

Cambridge University Press, 2003

Sanja Fidler CSC420: Intro to Image Understanding 2 / 67

Page 3: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera

Camera is structurally similar to the eye

[Source: L.W. Kheng]Sanja Fidler CSC420: Intro to Image Understanding 3 / 67

Page 4: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera

Camera is structurally similar to the eye

[Source: L.W. Kheng]

Sanja Fidler CSC420: Intro to Image Understanding 4 / 67

Page 5: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera

Remember the pinhole camera from Lecture 2?

[Source: A. Torralba]Sanja Fidler CSC420: Intro to Image Understanding 5 / 67

Page 6: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera

Remember the pinhole camera from Lecture 2?

[Source: A. Torralba]Sanja Fidler CSC420: Intro to Image Understanding 5 / 67

Page 7: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera

Remember the pinhole camera from Lecture 2?

Size of the pinhole is called aperture

[Source: A. Torralba]Sanja Fidler CSC420: Intro to Image Understanding 5 / 67

Page 8: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Pinhole Camera

[Source: A. Torralba]

ExampleSanja Fidler CSC420: Intro to Image Understanding 6 / 67

Page 9: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Shrinking the Aperture

Why not make the aperture as small as possible?

Less light gets through

Di↵raction e↵ects...

[Source: N. Snavely]Sanja Fidler CSC420: Intro to Image Understanding 7 / 67

Page 10: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Shrinking the Aperture

[Source: N. Snavely]Sanja Fidler CSC420: Intro to Image Understanding 8 / 67

Page 11: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Adding a Lens

[Pic from Wikipedia]

Small pinhole Big pinhole Lens

A lens focuses light onto the film

There is a specific distance at which objects are in focus

Changing the shape of the lens changes this distance

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 9 / 67

Page 12: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Adding a Lens

[Pic from Wikipedia]

Small pinhole Big pinhole Lens

A lens focuses light onto the film

There is a specific distance at which objects are in focus

Changing the shape of the lens changes this distance

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 9 / 67

Page 13: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Adding a Lens

[Pic from Wikipedia]

Small pinhole Big pinhole Lens

A lens focuses light onto the film

There is a specific distance at which objects are in focus

Changing the shape of the lens changes this distance

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 9 / 67

Page 14: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Some “Cameras” Have Bigger Lenses than Others

http://www.use.com/images/s_2/thick_glasses_13b6941623c255ff400a_1.jpg?

Sanja Fidler CSC420: Intro to Image Understanding 10 / 67

Page 15: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Imaging

Images are 2D projections of real world scene

Images capture two kinds of information:

Geometric: positions, points, lines, curves, etc.

Photometric: intensity, color

Complex 3D-2D relationships

Camera models approximate these relationships

[Source: L.W. Kheng]

Sanja Fidler CSC420: Intro to Image Understanding 11 / 67

Page 16: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

[Source: N. Snavely]Sanja Fidler CSC420: Intro to Image Understanding 12 / 67

Page 17: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

[Source: N. Snavely]Sanja Fidler CSC420: Intro to Image Understanding 12 / 67

Page 18: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

3D to 2D Projection

How are 3D primitives projected onto the image plane?

We can do this using a linear 3D to 2D projection matrix

Di↵erent types:

Perspective projection

Orthographic projection

Scaled orthographic projection

Paraperspective projection

[source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 13 / 67

Page 19: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

3D to 2D Projection

How are 3D primitives projected onto the image plane?

We can do this using a linear 3D to 2D projection matrix

Di↵erent types:

Perspective projection

Orthographic projection

Scaled orthographic projection

Paraperspective projection

[source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 13 / 67

Page 20: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

3D to 2D Projection

How are 3D primitives projected onto the image plane?

We can do this using a linear 3D to 2D projection matrix

Di↵erent types:

Perspective projection

Orthographic projection

Scaled orthographic projection

Paraperspective projection

[source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 13 / 67

Page 21: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

3D to 2D Projection

How are 3D primitives projected onto the image plane?

We can do this using a linear 3D to 2D projection matrix

Di↵erent types, most common:

Perspective projection

Orthographic projection

Scaled orthographic projection

Paraperspective projection

[source: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 14 / 67

Page 22: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection[Pics from: A. Torralba, Forsyth & Ponce]

We will use the pinhole model as an approximation

Sanja Fidler CSC420: Intro to Image Understanding 15 / 67

Page 23: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection[Pics from: A. Torralba, Forsyth & Ponce]

We will use the pinhole model as an approximation

Sanja Fidler CSC420: Intro to Image Understanding 15 / 67

Page 24: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection[Pics from: A. Torralba, Forsyth & Ponce]

We will use the pinhole model as an approximation

Sanja Fidler CSC420: Intro to Image Understanding 15 / 67

Page 25: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection[Pics from: A. Torralba, Forsyth & Ponce]

We will use the pinhole model as an approximation

Sanja Fidler CSC420: Intro to Image Understanding 15 / 67

Page 26: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Focal Length

Can be thought of as zoom

Related to the field of view

!"##$ %&##$

!&&##$ '&&##$

Figure: Image from N. Snavely[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 16 / 67

Page 27: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection[Pics from: A. Torralba, Forsyth & Ponce]

We will use the pinhole model as an approximation

Since it’s easier to think in a non-upsidedown world, we will work with thevirtual image plane, and just call it the image plane.

How do points in 3D project to image plane? If I know a point in 3D, can Icompute to which pixel it projects?

Sanja Fidler CSC420: Intro to Image Understanding 17 / 67

Page 28: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

First some notation which will help us derive the math

To start with, we need a coordinate system

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 29: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

We place a coordinate system relative to camera: optical center or cameracenter C is thus at origin (0, 0, 0).

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 30: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

The Z axis is called the optical or principal axis. It is orthogonal to theimage plane. Axes X and Y are parallel to the image axes.

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 31: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

We will use a right handed coordinate system

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 32: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

The optical axis intersects the image plane in a point, p. We call this pointa principal point. It’s worth to remember the principal point since it willappear again later in the math.

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 33: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

The distance from the camera center to the principal point is called focallength, we will denote it with f . It’s worth to remember the focal lengthsince it will appear again later in the math.

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 34: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

We’ll denote the image axes with x and y . An image we see is of courserepresented with these axes. We’ll call this an image coordinate system.

The tricky part is how to get from the camera’s coordinate system (3D) tothe image coordinate system (2D).

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 35: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

Let’s take some point Q in 3D. Q “lives” relative to the camera; itscoordinates are assumed to be in camera’s coordinate system.

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 36: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

We call the line from Q to camera center a projection line.

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 37: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

The projection line intersects the image plane in a point q. This is the pointwe see in our image.

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 38: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling Projection

First thing to notice is that all points from Q’s projection line project to thesame point q in the image!

Ambiguity: It’s impossible to know how far a 3D point is from the cameraalong the projection line by looking only at the image (point q).

Sanja Fidler CSC420: Intro to Image Understanding 18 / 67

Page 39: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling projection

From the movie Bone Collector

Ambiguity: It’s impossible to know how far a 3D point is from the cameraalong the projection line by looking only at the image (point q).

It’s impossible to know the real 3D size of objects just from an image

Why did the detective put a dollar bill next to the footprint?

How would you compute the shoe’s dimensions?

Sanja Fidler CSC420: Intro to Image Understanding 19 / 67

Page 40: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Modeling projection

From the movie Bone Collector

Ambiguity: It’s impossible to know how far a 3D point is from the cameraalong the projection line by looking only at the image (point q).

It’s impossible to know the real 3D size of objects just from an image

Why did the detective put a dollar bill next to the footprint?

How would you compute the shoe’s dimensions?

Sanja Fidler CSC420: Intro to Image Understanding 19 / 67

Page 41: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection: Ready for Math[Pic from: Zisserman & Hartley]

Projection Equations

Using similar triangles:

Q = (X ,Y ,Z )T !⇣f · XZ

,f · YZ

, f⌘T

This is relative to principal point p. To move the origin to (0, 0) in image:

q = (X ,Y ,Z )T !⇣f · XZ

+ p

x

,f · YZ

+ p

y

, f⌘T

where p = (px

, py

) is the principal point

Sanja Fidler CSC420: Intro to Image Understanding 20 / 67

Page 42: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection: Ready for Math[Pic from: Zisserman & Hartley]

Projection Equations

Using similar triangles:

Q = (X ,Y ,Z )T !⇣f · XZ

,f · YZ

, f⌘T

This is relative to principal point p. To move the origin to (0, 0) in image:

q = (X ,Y ,Z )T !⇣f · XZ

+ p

x

,f · YZ

+ p

y

, f⌘T

where p = (px

, py

) is the principal point

Sanja Fidler CSC420: Intro to Image Understanding 20 / 67

Page 43: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection: Ready for Math

Projection Equations

Using similar triangles:

Q = (X ,Y ,Z )T !⇣f · XZ

,f · YZ

, f⌘T

This is relative to principal point p. To move the origin to (0, 0) in image:

q = (X ,Y ,Z )T !⇣f · XZ

+ p

x

,f · YZ

+ p

y

, f⌘T

where p = (px

, py

) is the principal point

Sanja Fidler CSC420: Intro to Image Understanding 20 / 67

Page 44: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection: Ready for Math

Projection Equations

Using similar triangles:

Q = (X ,Y ,Z )T !⇣f · XZ

,f · YZ

, f⌘T

This is relative to principal point p. To move the origin to (0, 0) in image:

q = (X ,Y ,Z )T !⇣f · XZ

+ p

x

,f · YZ

+ p

y

, f⌘T

where p = (px

, py

) is the principal point

Get the projection by throwing the last coordinate:

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

+ p

x

,f · YZ

+ p

y

⌘T

This is NOT a linear transformation as a division by Z is non-linear

Sanja Fidler CSC420: Intro to Image Understanding 20 / 67

Page 45: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Homogeneous Coordinates!

We will use homogeneous coordinates, which simply append a 1 to the vector

!"#"$%&%"'()*""+,-&./%()/")/0%)+%(*'%1)

0"#"$%&%"'()-#.$%))*""+,-&./%()

0"#"$%&%"'()(*%&%))*""+,-&./%()

2"&3%+4&$)!"#$)0"#"$%&%"'()*""+,-&./%()

[Source: N. Snavely]Sanja Fidler CSC420: Intro to Image Understanding 21 / 67

Page 46: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Homogeneous Coordinates!

We will use homogeneous coordinates, which simply append a 1 to the vector

In homogeneous coordinates, scaling doesn’t a↵ect anything:2

4x

y

1

3

5 ⇠

2

4w · xw · yw

3

5

Sanja Fidler CSC420: Intro to Image Understanding 22 / 67

Page 47: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Homogeneous Coordinates!

We will use homogeneous coordinates, which simply append a 1 to the vector

In homogeneous coordinates, scaling doesn’t a↵ect anything:2

4x

y

1

3

5 ⇠

2

4w · xw · yw

3

5

In Projective Geometry, all points are equal under scalingSanja Fidler CSC420: Intro to Image Understanding 22 / 67

Page 48: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Useful Trivia about Homogeneous Coordinates

Homogeneous coordinates are quite useful in general. Let’s see why

Let’s look at equation of a line in 2D: ax + by + c = 0

I can represent the line with a homogeneous vector l := (a, b, c)T (whyhomogeneous?) and a homogeneous vector x := (x , y , 1). How?

Dot product is 0: lT · x = 0!

So if I have a line and someone gives me a point (x , y), how do I quicklycheck if the point lies on the line? Homogeneous coordinates, and check ifdot product is 0.

Ok, what if I give you two points (x1, y1) and (x2, y2) and I ask you to writean equation for the line between them?

You can solve a linear system. But it’s much easier in homogeneouscoordinates: Since both points lie on a line, the homogeneous vectors areboth “orthogonal” to the line vector l (dot product 0).

We know that a vector orthogonal to two vectors is a cross product betweenthem: l = (x1, y1, 1)T ⇥ (x2, y2, 1)T . And this is easy to compute.

Sanja Fidler CSC420: Intro to Image Understanding 23 / 67

Page 49: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Useful Trivia about Homogeneous Coordinates

Homogeneous coordinates are quite useful in general. Let’s see why

Let’s look at equation of a line in 2D: ax + by + c = 0

I can represent the line with a homogeneous vector l := (a, b, c)T (whyhomogeneous?) and a homogeneous vector x := (x , y , 1). How?

Dot product is 0: lT · x = 0!

So if I have a line and someone gives me a point (x , y), how do I quicklycheck if the point lies on the line? Homogeneous coordinates, and check ifdot product is 0.

Ok, what if I give you two points (x1, y1) and (x2, y2) and I ask you to writean equation for the line between them?

You can solve a linear system. But it’s much easier in homogeneouscoordinates: Since both points lie on a line, the homogeneous vectors areboth “orthogonal” to the line vector l (dot product 0).

We know that a vector orthogonal to two vectors is a cross product betweenthem: l = (x1, y1, 1)T ⇥ (x2, y2, 1)T . And this is easy to compute.

Sanja Fidler CSC420: Intro to Image Understanding 23 / 67

Page 50: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Useful Trivia about Homogeneous Coordinates

Homogeneous coordinates are quite useful in general. Let’s see why

Let’s look at equation of a line in 2D: ax + by + c = 0

I can represent the line with a homogeneous vector l := (a, b, c)T (whyhomogeneous?) and a homogeneous vector x := (x , y , 1). How?

Dot product is 0: lT · x = 0!

So if I have a line and someone gives me a point (x , y), how do I quicklycheck if the point lies on the line? Homogeneous coordinates, and check ifdot product is 0.

Ok, what if I give you two points (x1, y1) and (x2, y2) and I ask you to writean equation for the line between them?

You can solve a linear system. But it’s much easier in homogeneouscoordinates: Since both points lie on a line, the homogeneous vectors areboth “orthogonal” to the line vector l (dot product 0).

We know that a vector orthogonal to two vectors is a cross product betweenthem: l = (x1, y1, 1)T ⇥ (x2, y2, 1)T . And this is easy to compute.

Sanja Fidler CSC420: Intro to Image Understanding 23 / 67

Page 51: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Useful Trivia about Homogeneous Coordinates

Homogeneous coordinates are quite useful in general. Let’s see why

Let’s look at equation of a line in 2D: ax + by + c = 0

I can represent the line with a homogeneous vector l := (a, b, c)T (whyhomogeneous?) and a homogeneous vector x := (x , y , 1). How?

Dot product is 0: lT · x = 0!

So if I have a line and someone gives me a point (x , y), how do I quicklycheck if the point lies on the line? Homogeneous coordinates, and check ifdot product is 0.

Ok, what if I give you two points (x1, y1) and (x2, y2) and I ask you to writean equation for the line between them?

You can solve a linear system. But it’s much easier in homogeneouscoordinates: Since both points lie on a line, the homogeneous vectors areboth “orthogonal” to the line vector l (dot product 0).

We know that a vector orthogonal to two vectors is a cross product betweenthem: l = (x1, y1, 1)T ⇥ (x2, y2, 1)T . And this is easy to compute.

Sanja Fidler CSC420: Intro to Image Understanding 23 / 67

Page 52: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Useful Trivia about Homogeneous Coordinates

Homogeneous coordinates are quite useful in general. Let’s see why

Let’s look at equation of a line in 2D: ax + by + c = 0

I can represent the line with a homogeneous vector l := (a, b, c)T (whyhomogeneous?) and a homogeneous vector x := (x , y , 1). How?

Dot product is 0: lT · x = 0!

So if I have a line and someone gives me a point (x , y), how do I quicklycheck if the point lies on the line? Homogeneous coordinates, and check ifdot product is 0.

Ok, what if I give you two points (x1, y1) and (x2, y2) and I ask you to writean equation for the line between them?

You can solve a linear system. But it’s much easier in homogeneouscoordinates: Since both points lie on a line, the homogeneous vectors areboth “orthogonal” to the line vector l (dot product 0).

We know that a vector orthogonal to two vectors is a cross product betweenthem: l = (x1, y1, 1)T ⇥ (x2, y2, 1)T . And this is easy to compute.

Sanja Fidler CSC420: Intro to Image Understanding 23 / 67

Page 53: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Useful Trivia about Homogeneous Coordinates

Homogeneous coordinates are quite useful in general. Let’s see why

Let’s look at equation of a line in 2D: ax + by + c = 0

I can represent the line with a homogeneous vector l := (a, b, c)T (whyhomogeneous?) and a homogeneous vector x := (x , y , 1). How?

Dot product is 0: lT · x = 0!

So if I have a line and someone gives me a point (x , y), how do I quicklycheck if the point lies on the line? Homogeneous coordinates, and check ifdot product is 0.

Ok, what if I give you two points (x1, y1) and (x2, y2) and I ask you to writean equation for the line between them?

You can solve a linear system. But it’s much easier in homogeneouscoordinates: Since both points lie on a line, the homogeneous vectors areboth “orthogonal” to the line vector l (dot product 0).

We know that a vector orthogonal to two vectors is a cross product betweenthem: l = (x1, y1, 1)T ⇥ (x2, y2, 1)T . And this is easy to compute.

Sanja Fidler CSC420: Intro to Image Understanding 23 / 67

Page 54: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Useful Trivia about Homogeneous Coordinates

Homogeneous coordinates are quite useful in general. Let’s see why

Let’s look at equation of a line in 2D: ax + by + c = 0

I can represent the line with a homogeneous vector l := (a, b, c)T (whyhomogeneous?) and a homogeneous vector x := (x , y , 1). How?

Dot product is 0: lT · x = 0!

So if I have a line and someone gives me a point (x , y), how do I quicklycheck if the point lies on the line? Homogeneous coordinates, and check ifdot product is 0.

Ok, what if I give you two points (x1, y1) and (x2, y2) and I ask you to writean equation for the line between them?

You can solve a linear system. But it’s much easier in homogeneouscoordinates: Since both points lie on a line, the homogeneous vectors areboth “orthogonal” to the line vector l (dot product 0).

We know that a vector orthogonal to two vectors is a cross product betweenthem: l = (x1, y1, 1)T ⇥ (x2, y2, 1)T . And this is easy to compute.

Sanja Fidler CSC420: Intro to Image Understanding 23 / 67

Page 55: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Back to Perspective Projection

We currently have this (the nasty division by Z ):

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

f ·XZ

+ p

x

f ·YZ

+ p

y

Write this with homogeneous coordinates:

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

2

4f ·XZ

+ p

x

f ·YZ

+ p

y

1

3

5 ⇠

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5

We can now write this as matrix multiplication:

Q =

2

4X

Y

Z

3

5 !

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5 =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4X

Y

Z

3

5

Sanja Fidler CSC420: Intro to Image Understanding 24 / 67

Page 56: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Back to Perspective Projection

We currently have this (the nasty division by Z ):

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

f ·XZ

+ p

x

f ·YZ

+ p

y

Write this with homogeneous coordinates:

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

2

4f ·XZ

+ p

x

f ·YZ

+ p

y

1

3

5 ⇠

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5

We can now write this as matrix multiplication:

Q =

2

4X

Y

Z

3

5 !

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5 =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4X

Y

Z

3

5

Sanja Fidler CSC420: Intro to Image Understanding 24 / 67

Page 57: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Back to Perspective Projection

We currently have this (the nasty division by Z ):

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

f ·XZ

+ p

x

f ·YZ

+ p

y

Write this with homogeneous coordinates:

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

2

4f ·XZ

+ p

x

f ·YZ

+ p

y

1

3

5 ⇠

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5

We can now write this as matrix multiplication:

Q =

2

4X

Y

Z

3

5 !

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5 =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4X

Y

Z

3

5

Sanja Fidler CSC420: Intro to Image Understanding 24 / 67

Page 58: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Intrinsics

From previous slide:

Q =

2

4X

Y

Z

3

5 !

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5 =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4X

Y

Z

3

5

Write:

K =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

This is called a camera calibration matrix or intrinsic parameter matrix.The parameters in K are called internal camera parameters.

Finally:

2

4w · xw · yw

3

5 = K

2

4X

Y

Z

3

5 ! q =

x

y

[Source: Zisserman & Hartley]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 67

Page 59: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Intrinsics

From previous slide:

Q =

2

4X

Y

Z

3

5 !

2

4f · X + Z · p

x

f · Y + Z · py

Z

3

5 =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4X

Y

Z

3

5

Write:

K =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

This is called a camera calibration matrix or intrinsic parameter matrix.The parameters in K are called internal camera parameters.

Finally:

2

4w · xw · yw

3

5 = K

2

4X

Y

Z

3

5 ! q =

x

y

[Source: Zisserman & Hartley]

Sanja Fidler CSC420: Intro to Image Understanding 25 / 67

Page 60: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Intrinsics

Camera calibration matrix:

K =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

It can be a little more complicated. Pixels may not be square:

K =

2

4f

x

0 p

x

0 f

y

p

y

0 0 1

3

5

And there might be a skew angle ✓ between x and y image axis:

K =

2

4f

x

�f

x

cot ✓ p

x

0 f

y

/ sin ✓ p

y

0 0 1

3

5

[Source: Zisserman & Hartley]

Sanja Fidler CSC420: Intro to Image Understanding 26 / 67

Page 61: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Intrinsics

Camera calibration matrix:

K =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

It can be a little more complicated. Pixels may not be square:

K =

2

4f

x

0 p

x

0 f

y

p

y

0 0 1

3

5

And there might be a skew angle ✓ between x and y image axis:

K =

2

4f

x

�f

x

cot ✓ p

x

0 f

y

/ sin ✓ p

y

0 0 1

3

5

[Source: Zisserman & Hartley]

Sanja Fidler CSC420: Intro to Image Understanding 26 / 67

Page 62: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Intrinsics

Camera calibration matrix:

K =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

It can be a little more complicated. Pixels may not be square:

K =

2

4f

x

0 p

x

0 f

y

p

y

0 0 1

3

5

And there might be a skew angle ✓ between x and y image axis:

K =

2

4f

x

�f

x

cot ✓ p

x

0 f

y

/ sin ✓ p

y

0 0 1

3

5

[Source: Zisserman & Hartley]

Sanja Fidler CSC420: Intro to Image Understanding 26 / 67

Page 63: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Intrinsics

Camera calibration matrix:

K =

2

4f 0 p

x

0 f p

y

0 0 1

3

5 We’ll work with this one

It can be a little more complicated. Pixels may not be square:

K =

2

4f

x

0 p

x

0 f

y

p

y

0 0 1

3

5

And there might be a skew angle ✓ between x and y image axis:

K =

2

4f

x

�f

x

cot ✓ p

x

0 f

y

/ sin ✓ p

y

0 0 1

3

5

[Source: Zisserman & Hartley]

Sanja Fidler CSC420: Intro to Image Understanding 27 / 67

Page 64: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Perspective Projection

[Source: N. Snavely]Sanja Fidler CSC420: Intro to Image Understanding 28 / 67

Page 65: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Dimensionality Reduction Machine (3D to 2D)

Figures © Stephen E. Palmer, 2002

!"#$%&'(# )"#*+,-.#

!"#$%"#&'%('%)*+$,%-  ./0)'+%-  12+$#/3'+%4)'/0$"+5%

Slide by A. Efros

Sanja Fidler CSC420: Intro to Image Understanding 29 / 67

Page 66: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Many-to-one: any points along same ray map to same point in image

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 67: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Many-to-one: any points along same ray map to same point in image

Points ! points

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 68: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Many-to-one: any points along same ray map to same point in image

Points ! points

Lines ! lines. Why?

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 69: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Figure: Proof by drawing

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 70: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Figure: Proof by drawing

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 71: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Many-to-one: any points along same ray map to same point in image

Points ! points

Lines ! lines

But line through principal point projects to a point. Why?

Figure: Can you tell where is the principal point?

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 72: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Many-to-one: any points along same ray map to same point in image

Points ! points

Lines ! lines

But line through principal point projects to a point. Why?

Planes ! planes

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 73: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection properties

Many-to-one: any points along same ray map to same point in image

Points ! points

Lines ! lines

But line through principal point projects to a point. Why?

Planes ! planes

But plane through principal point which is orthogonal to image planeprojects to line. Why?

Sanja Fidler CSC420: Intro to Image Understanding 30 / 67

Page 74: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Parallel lines converge at a vanishing point

Each di↵erent direction in the world has its own vanishing point

[Adopted from: N. Snavely, R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 31 / 67

Page 75: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Parallel lines converge at a vanishing point

Each di↵erent direction in the world has its own vanishing point

All lines with the same 3D direction intersect at the same vanishing point

[Pic: R. Szeliski]

Sanja Fidler CSC420: Intro to Image Understanding 32 / 67

Page 76: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.Why?

Sanja Fidler CSC420: Intro to Image Understanding 33 / 67

Page 77: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.Why?

Figure: We need to prove this.

Sanja Fidler CSC420: Intro to Image Understanding 33 / 67

Page 78: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.Why?

Sanja Fidler CSC420: Intro to Image Understanding 33 / 67

Page 79: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.Why?

Line that passes through V with direction D: X = V + tD.

Project it:2

4wx

wy

w

3

5 = KX =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4V

x

+ tD

x

V

y

+ tD

y

V

z

+ tD

z

3

5 =

2

4fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

3

5

Send t ! 1 and compute x and y :

x = limt!1

fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

V

z

+ tD

z

=fD

x

+ p

x

D

z

D

z

y = limt!1

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

=fD

y

+ p

y

D

z

D

z

This doesn’t depend on V! So all lines with direction D go to this point!

Sanja Fidler CSC420: Intro to Image Understanding 34 / 67

Page 80: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.Why?

Line that passes through V with direction D: X = V + tD.

Project it:2

4wx

wy

w

3

5 = KX =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4V

x

+ tD

x

V

y

+ tD

y

V

z

+ tD

z

3

5 =

2

4fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

3

5

Send t ! 1 and compute x and y :

x = limt!1

fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

V

z

+ tD

z

=fD

x

+ p

x

D

z

D

z

y = limt!1

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

=fD

y

+ p

y

D

z

D

z

This doesn’t depend on V! So all lines with direction D go to this point!

Sanja Fidler CSC420: Intro to Image Understanding 34 / 67

Page 81: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.Why?

Line that passes through V with direction D: X = V + tD.

Project it:2

4wx

wy

w

3

5 = KX =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4V

x

+ tD

x

V

y

+ tD

y

V

z

+ tD

z

3

5 =

2

4fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

3

5

Send t ! 1 and compute x and y :

x = limt!1

fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

V

z

+ tD

z

=fD

x

+ p

x

D

z

D

z

y = limt!1

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

=fD

y

+ p

y

D

z

D

z

This doesn’t depend on V! So all lines with direction D go to this point!

Sanja Fidler CSC420: Intro to Image Understanding 34 / 67

Page 82: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.Why?

Line that passes through V with direction D: X = V + tD.

Project it:2

4wx

wy

w

3

5 = KX =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

2

4V

x

+ tD

x

V

y

+ tD

y

V

z

+ tD

z

3

5 =

2

4fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

3

5

Send t ! 1 and compute x and y :

x = limt!1

fV

x

+ ftD

x

+ p

x

V

z

+ tp

x

D

z

V

z

+ tD

z

=fD

x

+ p

x

D

z

D

z

y = limt!1

fV

y

+ ftD

y

+ p

y

V

z

+ tp

y

D

z

V

z

+ tD

z

=fD

y

+ p

y

D

z

D

z

This doesn’t depend on V! So all lines with direction D go to this point!

Sanja Fidler CSC420: Intro to Image Understanding 34 / 67

Page 83: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.

The easiest way to find this point: Translate line with direction D to thecamera center. This line intersects the image plane in the vanishing pointcorresponding to direction D! Why?

Sanja Fidler CSC420: Intro to Image Understanding 35 / 67

Page 84: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Vanishing Point

All lines with the same 3D direction intersect at the same vanishing point.

The easiest way to find this point: Translate line with direction D to thecamera center. This line intersects the image plane in the vanishing pointcorresponding to direction D! Why?

Sanja Fidler CSC420: Intro to Image Understanding 35 / 67

Page 85: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Parallel lines converge at a vanishing point

Each di↵erent direction in the world has its own vanishing point

Lines parallel to image plane are also parallel in the image (we say that theyintersect at infinity). Why?

Sanja Fidler CSC420: Intro to Image Understanding 36 / 67

Page 86: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Lines parallel to image plane are also parallel in the image. We say that theyintersect at infinity.

Sanja Fidler CSC420: Intro to Image Understanding 37 / 67

Page 87: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Lines parallel to image plane are also parallel in the image. We say that theyintersect at infinity.

Sanja Fidler CSC420: Intro to Image Understanding 37 / 67

Page 88: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Tricks

This picture has been recorded from a car with a camera on top. We knowthe camera intrinsic matrix K .

Can we tell the incline of the hill we are driving on?

How?

Sanja Fidler CSC420: Intro to Image Understanding 38 / 67

Page 89: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Tricks

Can we tell the incline of the hill we are driving on?

Figure: This is the 3D world behind the picture.

Sanja Fidler CSC420: Intro to Image Understanding 39 / 67

Page 90: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Tricks

Can we tell the incline of the hill we are driving on?

Figure: If we compute the 3D direction of the house’s vertical lines relative tocamera, we have the incline! How can we do that?

Sanja Fidler CSC420: Intro to Image Understanding 39 / 67

Page 91: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Tricks

Can we tell the incline of the hill we are driving on?

Figure: Extract “vertical” lines and compute vanishing point. How can wecompute direction in 3D from vanishing point (if we have K )?

Sanja Fidler CSC420: Intro to Image Understanding 40 / 67

Page 92: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Tricks

Can we tell the incline of the hill we are driving on?

Figure: This picture should help.Sanja Fidler CSC420: Intro to Image Understanding 40 / 67

Page 93: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Tricks

Can we tell the incline of the hill we are driving on?

We have:2

4w · vp

x

w · vpy

w

3

5 = KD ! D = wK

�1

2

4vp

x

vp

y

1

3

5 ! normalize D to norm 1

Sanja Fidler CSC420: Intro to Image Understanding 40 / 67

Page 94: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Vanishing Points Can be Deceiving

Parallel lines converge at a vanishing point.

But intersecting lines in 2D are not necessary parallel in 3D.

[Source: A. Jepson]

Sanja Fidler CSC420: Intro to Image Understanding 41 / 67

Page 95: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Parallel lines converge at a vanishing point

Each di↵erent direction in the world has its own vanishing point

For lines on the same 3D plane, the vanishing points lie on a line. We call ita vanishing line. Vanishing line for the ground plane is a horizon line.

Sanja Fidler CSC420: Intro to Image Understanding 42 / 67

Page 96: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Parallel lines converge at a vanishing point

For lines on the same 3D plane, the vanishing points lie on a line. We call ita vanishing line. Vanishing line for the ground plane is a horizon line.

Some horizon lines are nicer than others ;)

Punta CanaSanja Fidler CSC420: Intro to Image Understanding 43 / 67

Page 97: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Parallel lines converge at a vanishing point

For lines on the same 3D plane, the vanishing points lie on a line. We call ita vanishing line or a horizon line.

Parallel planes in 3D have the same horizon line in the image.

Sanja Fidler CSC420: Intro to Image Understanding 44 / 67

Page 98: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Can I tell how much above ground this picture was taken?

Sanja Fidler CSC420: Intro to Image Understanding 45 / 67

Page 99: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Can I tell how much above ground this picture was taken?

Sanja Fidler CSC420: Intro to Image Understanding 45 / 67

Page 100: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Same distance as where the horizon intersects a building

Sanja Fidler CSC420: Intro to Image Understanding 45 / 67

Page 101: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

Same distance as where the horizon intersects a building: 50 floors up

Sanja Fidler CSC420: Intro to Image Understanding 45 / 67

Page 102: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

This is only true when the camera (image plane) is orthogonal to the groundplane. And the ground plane is flat.

A very nice explanation of this phenomena can be find by Derek Hoiem here:https://courses.engr.illinois.edu/cs543/sp2011/materials/3dscene_

book_svg.pdf

Sanja Fidler CSC420: Intro to Image Understanding 45 / 67

Page 103: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Orthographic Projection

[Source: R. Urtasun]

Requires no division and simply drops the Z coordinate.Orthographic projection:

Q =

2

664

X

Y

Z

1

3

775 !

2

4X

Y

1

3

5 =

2

41 0 0 00 1 0 00 0 0 1

3

5

2

664

X

Y

Z

1

3

775

Special case of perspective projection where the distance from the cameracenter to the image plane is infinity

Sanja Fidler CSC420: Intro to Image Understanding 46 / 67

Page 104: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Orthographic Projection

[Source: R. Urtasun]

Requires no division and simply drops the Z coordinate.

Orthographic projection:

Q =

2

664

X

Y

Z

1

3

775 !

2

4X

Y

1

3

5 =

2

41 0 0 00 1 0 00 0 0 1

3

5

2

664

X

Y

Z

1

3

775

Special case of perspective projection where the distance from the cameracenter to the image plane is infinity

Sanja Fidler CSC420: Intro to Image Understanding 46 / 67

Page 105: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Orthographic Projection

[Source: R. Urtasun]

Requires no division and simply drops the Z coordinate.Orthographic projection:

Q =

2

664

X

Y

Z

1

3

775 !

2

4X

Y

1

3

5 =

2

41 0 0 00 1 0 00 0 0 1

3

5

2

664

X

Y

Z

1

3

775

Special case of perspective projection where the distance from the cameracenter to the image plane is infinity

Sanja Fidler CSC420: Intro to Image Understanding 46 / 67

Page 106: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Orthographic Projection

[Source: R. Urtasun]

Requires no division and simply drops the Z coordinate.Orthographic projection:

Q =

2

664

X

Y

Z

1

3

775 !

2

4X

Y

1

3

5 =

2

41 0 0 00 1 0 00 0 0 1

3

5

2

664

X

Y

Z

1

3

775

Special case of perspective projection where the distance from the cameracenter to the image plane is infinity

Sanja Fidler CSC420: Intro to Image Understanding 46 / 67

Page 107: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Orthographic Projection

[Source: N. Snavely]

Sanja Fidler CSC420: Intro to Image Understanding 47 / 67

Page 108: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Orthographic Projection

For perspective projection lines parallel in 3D are not parallel in the image.

For orthographic projection lines parallel in 3D are parallel in the image.

[Source: A. Torralba]

Sanja Fidler CSC420: Intro to Image Understanding 48 / 67

Page 109: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

We are not yet done with projection. To fully specify projection, we need to:

Describe its internal parameters (we know this, this is our K)

Describe its pose in the world. Two important coordinate systems:

World coordinate system

Camera coordinate system

[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 49 / 67

Page 110: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

We are not yet done with projection. To fully specify projection, we need to:

Describe its internal parameters (we know this, this is our K)

Describe its pose in the world. Two important coordinate systems:

World coordinate system

Camera coordinate system

!"#$%"&

!"

#"

$"!"#$

!"#$%&'()*+%

!"

#"

$"

%"

[Source: N. Snavely, slide credit: R. Urtasun]Sanja Fidler CSC420: Intro to Image Understanding 49 / 67

Page 111: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

Why two coordinate systems?

Figure: Imagine this is your room.

Sanja Fidler CSC420: Intro to Image Understanding 50 / 67

Page 112: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

Why two coordinate systems?

Figure: When you were furnishing you measured everything in detail.

Sanja Fidler CSC420: Intro to Image Understanding 50 / 67

Page 113: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

Why two coordinate systems?

Figure: Thus you know all coordinates relative to a special point (origin) and

coordinate system in the room. This is your room’s (world) coordinate system.Sanja Fidler CSC420: Intro to Image Understanding 50 / 67

Page 114: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

Why two coordinate systems?

Figure: Now you take a picture and you wonder how points project to camera. In

order to project, you need all points in camera’s coordinate system.Sanja Fidler CSC420: Intro to Image Understanding 50 / 67

Page 115: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

Why two coordinate systems?

Figure: For e.g. self-driving cars, 3D points are typically measured with Velodyne.

Sanja Fidler CSC420: Intro to Image Understanding 50 / 67

Page 116: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

Why two coordinate systems?

Figure: We want to be able to project the 3D points in Velodyne’s coordinate

system onto an image captured by a camera.Sanja Fidler CSC420: Intro to Image Understanding 50 / 67

Page 117: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Parameters

Why two coordinate systems?

Figure: We want to be able to project the 3D points in Velodyne’s coordinate

system onto an image captured by a camera.

Sanja Fidler CSC420: Intro to Image Understanding 50 / 67

Page 118: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

To project a point (X ,Y ,Z ) in world coordinates on the image plane, we need to:

Transform (X ,Y ,Z ) into camera coordinates. We thus need:

Camera position (in world coordinates)

Camera orientation (in world coordinates)

To project into the image plane

Need to know camera intrinsics

These can all be described with matrices!

[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 51 / 67

Page 119: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

To project a point (X ,Y ,Z ) in world coordinates on the image plane, we need to:

Transform (X ,Y ,Z ) into camera coordinates. We thus need:

Camera position (in world coordinates)

Camera orientation (in world coordinates)

To project into the image plane

Need to know camera intrinsics

These can all be described with matrices!

[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 51 / 67

Page 120: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

To project a point (X ,Y ,Z ) in world coordinates on the image plane, we need to:

Transform (X ,Y ,Z ) into camera coordinates. We thus need:

Camera position (in world coordinates)

Camera orientation (in world coordinates)

To project into the image plane

Need to know camera intrinsics

These can all be described with matrices!

[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 51 / 67

Page 121: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

To project a point (X ,Y ,Z ) in world coordinates on the image plane, we need to:

Transform (X ,Y ,Z ) into camera coordinates. We thus need:

Camera position (in world coordinates)

Camera orientation (in world coordinates)

To project into the image plane

Need to know camera intrinsics

These can all be described with matrices!

[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 51 / 67

Page 122: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

To project a point (X ,Y ,Z ) in world coordinates on the image plane, we need to:

Transform (X ,Y ,Z ) into camera coordinates. We thus need:

Camera position (in world coordinates)

Camera orientation (in world coordinates)

To project into the image plane

Need to know camera intrinsics

These can all be described with matrices!

[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 51 / 67

Page 123: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection

To project a point (X ,Y ,Z ) in world coordinates on the image plane, we need to:

Transform (X ,Y ,Z ) into camera coordinates. We thus need:

Camera position (in world coordinates)

Camera orientation (in world coordinates)

To project into the image plane

Need to know camera intrinsics

These can all be described with matrices!

[Source: N. Snavely, slide credit: R. Urtasun]

Sanja Fidler CSC420: Intro to Image Understanding 51 / 67

Page 124: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Extrinsics

Figure: We first need our camera position and orientation in the room’s world.

Sanja Fidler CSC420: Intro to Image Understanding 52 / 67

Page 125: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Extrinsics

Sanja Fidler CSC420: Intro to Image Understanding 52 / 67

Page 126: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Extrinsics

Sanja Fidler CSC420: Intro to Image Understanding 52 / 67

Page 127: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Extrinsics

Sanja Fidler CSC420: Intro to Image Understanding 52 / 67

Page 128: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Extrinsics

Sanja Fidler CSC420: Intro to Image Understanding 52 / 67

Page 129: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Extrinsics

Sanja Fidler CSC420: Intro to Image Understanding 52 / 67

Page 130: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Extrinsics

Figure: Final Transformation

Sanja Fidler CSC420: Intro to Image Understanding 52 / 67

Page 131: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Equations

Projection matrix P models the cumulative e↵ect of all intrinsic andextrinsic parameters. We use homogeneous coordinates for 2D and 3D:

q =

2

4ax

ay

a

3

5 = P

2

664

X

Y

Z

1

3

775

It can be computed as

P =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

| {z }intrinsics K

2

41 0 0 00 1 0 00 0 1 0

3

5

| {z }projection

R3⇥3 03⇥1

01⇥3 1

| {z }rotation

I3⇥3 T3⇥1

01⇥3 1

| {z }translation

To get a point q in the image plane, I need to compute P(X ,Y ,Z , 1)T ,where P is a 3⇥ 4 matrix. This gives me a 3⇥ 1 vector. Now I divide allcoordinates with the third coordinate (making the third coordinate equal to1), and then drop the last coordinate. As simple as that.

Sanja Fidler CSC420: Intro to Image Understanding 53 / 67

Page 132: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Equations

Projection matrix P models the cumulative e↵ect of all intrinsic andextrinsic parameters. We use homogeneous coordinates for 2D and 3D:

q =

2

4ax

ay

a

3

5 = P

2

664

X

Y

Z

1

3

775

It can be computed as

P =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

| {z }intrinsics K

2

41 0 0 00 1 0 00 0 1 0

3

5

| {z }projection

R3⇥3 03⇥1

01⇥3 1

| {z }rotation

I3⇥3 T3⇥1

01⇥3 1

| {z }translation

To get a point q in the image plane, I need to compute P(X ,Y ,Z , 1)T ,where P is a 3⇥ 4 matrix. This gives me a 3⇥ 1 vector. Now I divide allcoordinates with the third coordinate (making the third coordinate equal to1), and then drop the last coordinate. As simple as that.

Sanja Fidler CSC420: Intro to Image Understanding 53 / 67

Page 133: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Equations

Projection matrix P models the cumulative e↵ect of all intrinsic andextrinsic parameters. We use homogeneous coordinates for 2D and 3D:

q =

2

4ax

ay

a

3

5 = P

2

664

X

Y

Z

1

3

775

It can be computed as

P =

2

4f 0 p

x

0 f p

y

0 0 1

3

5

| {z }intrinsics K

2

41 0 0 00 1 0 00 0 1 0

3

5

| {z }projection

R3⇥3 03⇥1

01⇥3 1

| {z }rotation

I3⇥3 T3⇥1

01⇥3 1

| {z }translation

To get a point q in the image plane, I need to compute P(X ,Y ,Z , 1)T ,where P is a 3⇥ 4 matrix. This gives me a 3⇥ 1 vector. Now I divide allcoordinates with the third coordinate (making the third coordinate equal to1), and then drop the last coordinate. As simple as that.

Sanja Fidler CSC420: Intro to Image Understanding 53 / 67

Page 134: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

The Projection Matrix

The projection matrix is defined as

P = K|{z}intrinsics

2

41 0 0 00 1 0 00 0 1 0

3

5

| {z }projection

R3⇥3 03⇥1

01⇥3 1

| {z }rotation

I3⇥3 T3⇥3

01⇥3 1

| {z }translation| {z }

hR t

i

More compactlyP = K

⇥R t

Sometimes you will see notation:

P = K⇥R | t

It’s the same thing.

This might look complicated. Truth is, in most cases you don’t have P atall, so you can’t really compute any projections. When you have a calibratedcamera, then someone typically gives you P. And then projection is easy.

Sanja Fidler CSC420: Intro to Image Understanding 54 / 67

Page 135: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

The Projection Matrix

The projection matrix is defined as

P = K|{z}intrinsics

2

41 0 0 00 1 0 00 0 1 0

3

5

| {z }projection

R3⇥3 03⇥1

01⇥3 1

| {z }rotation

I3⇥3 T3⇥3

01⇥3 1

| {z }translation| {z }

hR t

i

More compactlyP = K

⇥R t

Sometimes you will see notation:

P = K⇥R | t

It’s the same thing.

This might look complicated. Truth is, in most cases you don’t have P atall, so you can’t really compute any projections. When you have a calibratedcamera, then someone typically gives you P. And then projection is easy.

Sanja Fidler CSC420: Intro to Image Understanding 54 / 67

Page 136: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

A Short Note on Camera Calibration

The general procedure:

Place a 3D pattern (for which you know all distances) in front of camera.

Take a picture. Detect corners in image and find correspondences with thepoints in the pattern.

Go to the internet and check out the math that tells you how to compute K

from these 2D-3D correspondences. ;) We won’t cover in class.

[Pic from: R. Duraiswami]Sanja Fidler CSC420: Intro to Image Understanding 55 / 67

Page 137: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Calibration: Interesting Fact

Let’s say you have an image but you don’t know anything about the camera(for example, image downloaded from the web).

For images where you see lines corresponding to 3 orthogonal directions, likecubes or rooms, you can compute the camera matrix K as well as R and t!

How to do this is explained in the Zisserman & Hartley book.

Sanja Fidler CSC420: Intro to Image Understanding 56 / 67

Page 138: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

As a consequence, for scenes with lots of lines (e.g. man-made scenes) onecan reconstruct the scene in 3D from a single image!

Sanja Fidler CSC420: Intro to Image Understanding 57 / 67

Page 139: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

As a consequence, for scenes with lots of lines (e.g. man-made scenes) onecan reconstruct the scene in 3D from a single image!

Sanja Fidler CSC420: Intro to Image Understanding 57 / 67

Page 140: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Projection Properties: Cool Facts

As a consequence, for scenes with lots of lines (e.g. man-made scenes) onecan reconstruct the scene in 3D from a single image!

For those interested, check out the math here:

A. Criminisi, I. Reid, and A. Zisserman

Single View Metrology

International Journal of Computer Vision, vol 40, num 2, 2000

http://www.cs.cmu.edu/ ph/869/papers/Criminisi99.pdf

Sanja Fidler CSC420: Intro to Image Understanding 57 / 67

Page 141: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Inserting Objects [Karsch et al., 2011]

K. Karsch, V. Hedau, D. Forsyth, D. Hoiem, Rendering synthetic objects into legacy photographs, SIGGRAPH’11

link to videoSanja Fidler CSC420: Intro to Image Understanding 58 / 67

Page 142: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Calibration: Another Interesting Fact

From a longer video in which the sun travels across the sky you cancompute the camera intrinsic matrix, as well as extrinsic, i.e., the GPSlocation where you are! Well, up to a 100km accuracy...

Sanja Fidler CSC420: Intro to Image Understanding 59 / 67

Page 143: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Camera Calibration: Another Interesting Fact

J.-F. Lalonde, S. G. Narasimhan, and A. A. Efros

What Do the Sun and Sky Tell Us About the Camera?

International Journal on Computer Vision, 88(1), May 2010Paper: http://vision.gel.ulaval.ca/

~

jflalonde/projects/

sky/index.html

Code: https://github.com/jflalonde/webcamCalibration

From a longer video in which the sun travels across the sky you cancompute the camera intrinsic matrix, as well as extrinsic, i.e., the GPSlocation where you are! Well, up to a 100km accuracy...

Is this useful? Maybe, to catch terrorists that record their videos outside.

Sanja Fidler CSC420: Intro to Image Understanding 59 / 67

Page 144: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise (Not Very Easy, But Fun)

We want to render (project) a 3D CAD model of a car to this image in arealistic way

How?

Sanja Fidler CSC420: Intro to Image Understanding 60 / 67

Page 145: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

First get a CAD model. There are tones of them, e.g. 3D Warehouse (free)

Sanja Fidler CSC420: Intro to Image Understanding 61 / 67

Page 146: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

We downloaded this model. Now what?

Figure: A CAD model is a collection of 3D vertices and faces that connect thevertices. Each face represents a small triangle. It typically has color.

Sanja Fidler CSC420: Intro to Image Understanding 62 / 67

Page 147: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

Our image was collected with a car on the road:

A camera was on top of the car, approximately 1.7m above groundImage plane is orthogonal to the groundWe have the internal parameters of the camera, K.

Sanja Fidler CSC420: Intro to Image Understanding 63 / 67

Page 148: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

Our image was collected with a car on the road:

A camera was on top of the car, approximately 1.7m above groundImage plane is orthogonal to the groundWe have the internal parameters of the camera, K.

With a little bit of math, we can compute the ground plane in 3D, relativeto camera. We a bit more math we can compute which point on the groundplane projects to an image point (x , y).

How?

We can now “place” our CAD model to this point (compute R and t)

Rendering:

Compute [ax , ay , a]T = K

⇥R | t

⇤[X ,Y ,Z , 1]T for each CAD

vertex[X ,Y ,Z ]T . Divide [ax , ay , a]T with third coord and drop it.

Sanja Fidler CSC420: Intro to Image Understanding 64 / 67

Page 149: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

Our image was collected with a car on the road:

A camera was on top of the car, approximately 1.7m above groundImage plane is orthogonal to the groundWe have the internal parameters of the camera, K.

With a little bit of math, we can compute the ground plane in 3D, relativeto camera. We a bit more math we can compute which point on the groundplane projects to an image point (x , y).

How?

We can now “place” our CAD model to this point (compute R and t)

Rendering:

Compute [ax , ay , a]T = K

⇥R | t

⇤[X ,Y ,Z , 1]T for each CAD

vertex[X ,Y ,Z ]T . Divide [ax , ay , a]T with third coord and drop it.

Sanja Fidler CSC420: Intro to Image Understanding 64 / 67

Page 150: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

That’s it. Make a video for more fun

Sanja Fidler CSC420: Intro to Image Understanding 65 / 67

Page 151: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

That’s it. Make a video for more fun

Sanja Fidler CSC420: Intro to Image Understanding 65 / 67

Page 152: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Exercise

That’s it. Make a video for more fun

Sanja Fidler CSC420: Intro to Image Understanding 65 / 67

Page 153: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Can we Turn Fun into Useful?

Can we use this in some more practical (useful) application?

Sanja Fidler CSC420: Intro to Image Understanding 66 / 67

Page 154: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Can we Turn Fun into Useful?

Generate 3D boxes and score (classifier on some image features)

X. Chen, K. Kundu, Y. Zhu, A. Berneshawi, H. Ma, S. Fidler, R. Urtasun. 3D Object Proposalsfor Accurate Object Class Detection. NIPS’15

Sanja Fidler CSC420: Intro to Image Understanding 66 / 67

Page 155: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

Can we Turn Fun into Useful?

X. Chen, K. Kundu, Y. Zhu, A. Berneshawi, H. Ma, S. Fidler, R. Urtasun. 3D Object Proposalsfor Accurate Object Class Detection. NIPS’15

Sanja Fidler CSC420: Intro to Image Understanding 66 / 67

Page 156: Camera Modelsfidler/slides/2019/CSC420/lecture10.pdf · [Pics from: A. Torralba, Forsyth & Ponce] We will use the pinhole model as an approximation Since it’s easier to think in

A Little More on Camera Models

Sanja Fidler CSC420: Intro to Image Understanding 67 / 67