50
Pinhole Camera Model Computational Photography Derek Hoiem, University of Illinois 10/05/17

Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Pinhole Camera Model

Computational Photography

Derek Hoiem, University of Illinois

10/05/17

Page 2: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Next classes: Single-view Geometry

How tall is this woman?

Which ball is closer?

How high is the camera?

What is the camera

rotation?

What is the focal length of

the camera?

Page 3: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Today’s class

Mapping between image and world coordinates

– Pinhole camera model

– Projective geometry

• Vanishing points and lines

– Projection matrix

Page 4: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Image formation

Let’s design a camera– Idea 1: put a piece of film in front of an object– Do we get a reasonable image?

Slide source: Seitz

Page 5: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Pinhole camera

Idea 2: add a barrier to block off most of the rays

– This reduces blurring

– The opening known as the aperture

Slide source: Seitz

Page 6: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Pinhole camera

Figure from Forsyth

f

f = focal length

c = center of the camera

c

Page 7: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Camera obscura: the pre-camera

• First idea: Mozi, China (470BC to 390BC)

• First built: Alhacen, Iraq/Egypt (965 to 1039AD)

Illustration of Camera Obscura Freestanding camera obscura at UNC Chapel Hill

Photo by Seth Ilys

Page 8: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Camera Obscura used for Tracing

Lens Based Camera Obscura, 1568

Page 9: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

First Photograph

Joseph Niepce, 1826

Photograph of the first photograph

Stored at UT Austin

Oldest surviving photograph

– Took 8 hours on pewter plate

Niepce later teamed up with Daguerre, who eventually created Daguerrotypes

Page 10: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Point of observation

Figures © Stephen E. Palmer, 2002

Dimensionality Reduction Machine (3D to 2D)

3D world 2D image

Page 11: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Projection can be tricky…

Leon Keer – streetpainting3d.com

Page 12: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Julian Beever– julianbeever.net

Page 13: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Projective Geometry

What is lost?

• Length

Which is closer?

Who is taller?

Page 14: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Length is not preserved

Figure by David Forsyth

B’

C’

A’

Page 15: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Projective Geometry

What is lost?

• Length

• Angles

Perpendicular?

Parallel?

Page 16: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Projective Geometry

What is preserved?

• Straight lines are still straight

Page 17: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Vanishing points and lines

Parallel lines in the world intersect in the image at a “vanishing point”

Page 18: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Vanishing points and lines

oVanishing Point o

Vanishing Point

Vanishing Line

• The projections of parallel 3D lines intersect at a vanishing point

• The projection of parallel 3D planes intersect at a vanishing line

• If a set of parallel 3D lines are also parallel to a particular plane, their

vanishing point will lie on the vanishing line of the plane

• Not all lines that intersect are parallel• Vanishing point <-> 3D direction of a line

• Vanishing line <-> 3D orientation of a surface

Page 19: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Vanishing points and lines

Vanishingpoint

Vanishingline

Vanishingpoint

Vertical vanishingpoint

(at infinity)

Credit: Criminisi

Page 20: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Vanishing points and lines

Photo from online Tate collection

Page 21: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Vanishing objects

Page 22: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Projection: world coordinatesimage coordinates

Camera

Center

(tx, ty, tz)

Z

Y

X

P.

.

. f Z Y

v

up

.

Optical

Center

(u0, v0)

v

u

Page 23: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Homogeneous coordinates

Conversion

Converting to homogeneous coordinates

homogeneous image

coordinates

homogeneous scene

coordinates

Converting from homogeneous coordinates

Page 24: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Homogeneous coordinates

Invariant to scaling

Point in Cartesian is ray in Homogeneous

w

y

wx

kw

ky

kwkx

kw

ky

kx

w

y

x

k

Homogeneous Coordinates

Cartesian Coordinates

Page 25: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Basic geometry in homogeneous coordinates

• Line equation: ax + by + c = 0

• Append 1 to pixel coordinate to get homogeneous coordinate

• Line given by cross product of two points

• Intersection of two lines given by cross product of the lines

1

i

i

i v

u

p

jiij ppline

jiij linelineq

i

i

i

i

c

b

a

line

Page 26: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Another problem solved by homogeneous coordinates

Cartesian: (Inf, Inf)

Homogeneous: (1, 1, 0)

Intersection of parallel linesCartesian: (Inf, Inf)

Homogeneous: (1, 2, 0)

Page 27: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Pinhole Camera Model

XtRKx x: Image Coordinates: (u,v,1)

K: Intrinsic Matrix (3x3)

R: Rotation (3x3)

t: Translation (3x1)

X: World Coordinates: (X,Y,Z,1)

Ow

iw

kw

jw

t

R

Page 28: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Interlude: when have I used this stuff?

Page 29: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

When have I used this stuff?

Object Recognition (CVPR 2006)

Page 30: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

When have I used this stuff?

Single-view reconstruction (SIGGRAPH 2005)

Page 31: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

When have I used this stuff?

Getting spatial layout in indoor scenes (ICCV 2009)

Page 32: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

When have I used this stuff?

Inserting synthetic objects into images: http://vimeo.com/28962540

Page 33: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

When have I used this stuff?

Creating detailed and complete 3D scene models from a

single view (ongoing)

Page 34: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

When have I used this stuff?

Multiview 3D reconstruction at Reconstruct

Page 35: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

X0IKx

10100

000

000

1z

y

x

f

f

v

u

w

K

Slide Credit: Saverese

Projection matrix

Intrinsic Assumptions

• Unit aspect ratio

• Principal point at (0,0)

• No skew

Extrinsic Assumptions• No rotation

• Camera at (0,0,0)

Page 36: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Remove assumption: known optical center

X0IKx

10100

00

00

1

0

0

z

y

x

vf

uf

v

u

w

Intrinsic Assumptions

• Unit aspect ratio

• No skew

Extrinsic Assumptions• No rotation

• Camera at (0,0,0)

Page 37: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Remove assumption: square pixels

X0IKx

10100

00

00

1

0

0

z

y

x

v

u

v

u

w

Intrinsic Assumptions• No skew

Extrinsic Assumptions• No rotation

• Camera at (0,0,0)

Page 38: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Remove assumption: non-skewed pixels

X0IKx

10100

00

0

1

0

0

z

y

x

v

us

v

u

w

Intrinsic Assumptions Extrinsic Assumptions• No rotation

• Camera at (0,0,0)

Note: different books use different notation for parameters

Page 39: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Oriented and Translated Camera

Ow

iw

kw

jw

t

R

Page 40: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Allow camera translation

XtIKx

1100

010

001

100

0

0

1

0

0

z

y

x

t

t

t

v

u

v

u

w

z

y

x

Intrinsic Assumptions Extrinsic Assumptions• No rotation

Page 41: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

3D Rotation of Points

Rotation around the coordinate axes, counter-clockwise:

100

0cossin

0sincos

)(

cos0sin

010

sin0cos

)(

cossin0

sincos0

001

)(

z

y

x

R

R

R

p

p’

y

z

Slide Credit: Saverese

Page 42: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Allow camera rotation

XtRKx

1100

0

1 333231

232221

131211

0

0

z

y

x

trrr

trrr

trrr

v

us

v

u

w

z

y

x

Page 43: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Degrees of freedom

XtRKx

1100

0

1 333231

232221

131211

0

0

z

y

x

trrr

trrr

trrr

v

us

v

u

w

z

y

x

5 6

Page 44: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Vanishing Point = Projection from Infinity

R

R

R

z

y

x

z

y

x

z

y

x

KpKRptRKp

0

R

R

R

z

y

x

vf

uf

v

u

w

100

0

0

1

0

0 0uz

fxu

R

R

0vz

fyv

R

R

Page 45: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Orthographic Projection

• Special case of perspective projection

– Distance from the COP to the image plane is infinite

– Also called “parallel projection”

– What’s the projection matrix?

Image World

Slide by Steve Seitz

11000

0010

0001

z

y

x

w

v

u

Page 46: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Scaled Orthographic Projection

• Special case of perspective projection

– Object dimensions are small compared to distance to camera

– Also called “weak perspective”

– What’s the projection matrix?

Slide by Steve Seitz

1000

000

000

z

y

x

s

f

f

w

v

u

Illustration from George Bebis

Page 47: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Take-home questions

• Suppose the camera axis is in the direction of (x=0, y=0, z=1) in its own coordinate system. What is the camera axis in world coordinates given the extrinsic parameters R, t

• Suppose a camera at height y=h (x=0,z=0) observes a point at (u,v) known to be on the ground (y=0). Assume R is identity. What is the 3D position of the point in terms of f, u0, v0?

Page 48: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Beyond Pinholes: Radial Distortion

Image from Martin Habbecke

Corrected Barrel Distortion

Page 49: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Things to remember

• Vanishing points and vanishing lines

• Pinhole camera model and camera projection matrix

Vanishing

point

Vanishing

line

Vanishing

point

Vertical vanishing

point

(at infinity)

XtRKx

Page 50: Computational Photography CS498dwh · Vanishing points and lines Vanishing Pointo o Vanishing Point Vanishing Line • The projections of parallel 3D lines intersect at a vanishing

Next classes

• Tues: single-view metrology

– Measuring 3D distances from the image

• Thurs: single-view 3D reconstruction