Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the...

41
Geometry of a single camera Odilon Redon, Cyclops, 1914

Transcript of Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the...

Page 1: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Geometry of a single camera

Odilon Redon, Cyclops, 1914

Page 2: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Our goal: Recovery of 3D structure

J. Vermeer, Music Lesson, 1662

A. Criminisi, M. Kemp, and A. Zisserman,Bringing Pictorial Space to Life: computer techniques for the analysis of paintings, Proc. Computers and the History of Art, 2002

Page 3: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Things aren’t always as they appear…

http://en.wikipedia.org/wiki/Ames_room

Page 4: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Single-view ambiguity

x

X?X?

X?

Page 5: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Single-view ambiguity

Page 6: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Single-view ambiguity

Rashad Alakbarov shadow sculptures

Page 7: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Anamorphic perspective

Image source

Page 8: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Anamorphic perspective

H. Holbein The Younger, The Ambassadors, 1533https://en.wikipedia.org/wiki/Anamorphosis

Page 9: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Our goal: Recovery of 3D structure• When certain assumptions

hold, we can recover structure from a single view

• In general, we need multi-view geometry

Image source

• But first, we need to understand the geometry of a single camera…

Page 10: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera calibration

• Normalized (camera) coordinate system: camera center is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel to x and y axes of the world

• Camera calibration: figuring out transformation from world coordinate system to image coordinate system

world coordinate system

Page 11: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

)/,/(),,( ZYfZXfZYX !

÷÷÷÷÷

ø

ö

ççççç

è

æ

úúú

û

ù

êêê

ë

é=

÷÷÷

ø

ö

ççç

è

æ

÷÷÷÷÷

ø

ö

ççççç

è

æ

10100

1ZYX

ff

ZYfXf

ZYX

!

Review: Pinhole camera model

PXx =

Page 12: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Principal point

• Principal point (p): point where principal axis intersects the image plane

• Normalized coordinate system: origin of the image is at the principal point

• Image coordinate system: origin is in the corner

Page 13: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

)/,/(),,( yx pZYfpZXfZYX ++!

÷÷÷

ø

ö

ççç

è

æ++

÷÷÷÷÷

ø

ö

ççççç

è

æ

ZpZYfpZXf

ZYX

y

x

!

1

Principal point offset

We want the principal point to map to (px, py) instead of (0,0)

px

py

÷÷÷÷÷

ø

ö

ççççç

è

æ

úúú

û

ù

êêê

ë

é=

10100

ZYX

pfpf

y

x

Page 14: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Principal point offset

principal point: ),( yx pp

px

py

÷÷÷÷÷

ø

ö

ççççç

è

æ

úúú

û

ù

êêê

ë

é=

10100

ZYX

pfpf

y

x

Page 15: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

÷÷÷÷÷

ø

ö

ççççç

è

æ

úúú

û

ù

êêê

ë

é

úúú

û

ù

êêê

ë

é=

÷÷÷

ø

ö

ççç

è

æ++

1010101

1ZYX

pfpf

ZZpYfZpXf

y

x

y

x

Principal point offset

calibration matrix K

[ ]0|IKP =

principal point: ),( yx pp

px

py

÷÷÷÷÷

ø

ö

ççççç

è

æ

úúú

û

ù

êêê

ë

é=

10100

ZYX

pfpf

y

x

projection matrix [I | 0]

Page 16: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

úúú

û

ù

êêê

ë

é=

úúú

û

ù

êêê

ë

é

úúú

û

ù

êêê

ë

é=

111yy

xx

y

x

y

x

pfpf

mm

K baba

Pixel coordinates

mx pixels per meter in horizontal direction, my pixels per meter in vertical direction

Pixel size: yx mm11

´

pixels/m m pixels

Page 17: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

( )C~X~RX~ cam -=

Camera rotation and translation

• In general, the cameracoordinate frame will be related to the worldcoordinate frame by a rotation and a translation

coords. of point in camera frame

coords. of camera center in world frame

coords. of a pointin world frame

• Conversion from world to camera coordinate system (in non-homogeneous coordinates):

camera coordinate system world coordinate

system

Page 18: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

( )C~X~RX~ cam -=

Camera rotation and translation

3D transformation matrix (4 x 4)

Page 19: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

( )C~X~RX~ cam -=

Camera rotation and translation

3D transformation matrix (4 x 4)

Page 20: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera rotation and translation

3D transformation matrix (4 x 4)

perspective projection

matrix (3 x 4)

2D transformation matrix (3 x 3)

Page 21: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera rotation and translation

Page 22: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera rotation and translation

C~Rt -=

Page 23: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera parameters

• Intrinsic parameters• Principal point coordinates• Focal length• Pixel magnification factors• Skew (non-rectangular pixels)• Radial distortion

úúú

û

ù

êêê

ë

é=

úúú

û

ù

êêê

ë

é

úúú

û

ù

êêê

ë

é=

111yy

xx

y

x

y

x

pfpf

mm

baba

K

[ ]tRKP =

Page 24: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera parameters

[ ]CRRKP ~-=

• Intrinsic parameters• Principal point coordinates• Focal length• Pixel magnification factors• Skew (non-rectangular pixels)• Radial distortion

• Extrinsic parameters• Rotation and translation relative

to world coordinate system

• What is the projection of thecamera center?

coords. of camera center in world frame

[ ] 01

~~=ú

û

ùêë

é-=

CCRRKPCThe camera center is the null space of the projection matrix!

[ ]tRKP =

Page 25: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera calibration

úúúú

û

ù

êêêê

ë

é

úúú

û

ù

êêê

ë

é=

úúú

û

ù

êêê

ë

é

1************

ZYX

yx

lll

[ ]XtRKx =

Source: D. Hoiem

Page 26: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera calibration• Given n points with known 3D coordinates Xi

and known image projections xi, estimate the camera parameters

? P

Xi

xi

Page 27: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

ii PXx =l

Camera calibration: Linear method

0=´ ii PXx 01 3

2

1

=úúú

û

ù

êêê

ë

é

´úúú

û

ù

êêê

ë

é

iT

iT

iT

i

i

yx

XPXPXP

00

00

3

2

1

=÷÷÷

ø

ö

ççç

è

æ

úúú

û

ù

êêê

ë

é

--

-

PPP

XXXXXX

Tii

Tii

Tii

Ti

Tii

Ti

xyxy

Two linearly independent equations

Page 28: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera calibration: Linear method

• P has 11 degrees of freedom• One 2D/3D correspondence gives us two linearly

independent equations• 6 correspondences needed for a minimal solution

• Homogeneous least squares: find p minimizing ||Ap||2• Solution given by eigenvector of ATA with smallest eigenvalue

0pA =0

00

00

3

2

1111

111

=÷÷÷

ø

ö

ççç

è

æ

úúúúúú

û

ù

êêêêêê

ë

é

--

--

PPP

XXXX

XXXX

Tnn

TTn

Tnn

Tn

T

TTT

TTT

xy

xy

!!!

Page 29: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera calibration: Linear method

• Note: for coplanar points that satisfy ΠTX=0,we will get degenerate solutions (Π,0,0), (0,Π,0), or (0,0,Π)

0Ap =0

00

00

3

2

1111

111

=÷÷÷

ø

ö

ççç

è

æ

úúúúúú

û

ù

êêêêêê

ë

é

--

--

PPP

XXXX

XXXX

Tnn

TTn

Tnn

Tn

T

TTT

TTT

xy

xy

!!!

Page 30: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Camera calibration: Linear vs. nonlinear

• Linear calibration is easy to formulate and solve, but it doesn’t directly tell us the camera parameters

• In practice, non-linear methods are preferred• Write down objective function in terms of intrinsic and extrinsic

parameters

• Define error as sum of squared distances between measured 2D points and estimated projections of 3D points

• Minimize error using Newton’s method or other non-linear optimization

• Can model radial distortion and impose constraints such as known focal length and orthogonality

úúúú

û

ù

êêêê

ë

é

úúú

û

ù

êêê

ë

é=

úúú

û

ù

êêê

ë

é

1************

ZYX

yx

lll

[ ]XtRKx =vs.

Page 31: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

A taste of multi-view geometry: Triangulation

• Given projections of a 3D point in two or more images (with known camera matrices), find the coordinates of the point

Page 32: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Triangulation• Given projections of a 3D point in two or more

images (with known camera matrices), find the coordinates of the point

O1 O2

x1x2

X?

Page 33: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Triangulation• We want to intersect the two visual rays

corresponding to x1 and x2, but because of noise and numerical errors, they don’t meet exactly

O1 O2

x1x2

X?

Page 34: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Triangulation: Geometric approach• Find shortest segment connecting the two

viewing rays and let X be the midpoint of that segment

O1 O2

x1x2

X

Page 35: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Triangulation: Nonlinear approachFind X that minimizes

O1 O2

x1x2

X?

P1X

)()( 22 XP,xXP,x 2211 dd +

P2X

Page 36: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Triangulation: Linear approach

baba ][0

00

´=úúú

û

ù

êêê

ë

é

úúú

û

ù

êêê

ë

é

--

-=´

z

y

x

xy

xz

yz

bbb

aaaaaa

XPxXPx

22

11

==

2

1

ll

0XPx0XPx

22

11

=´=´

0X]P[x0X]P[x

22

11

==

´

´

Cross product as matrix multiplication:

Page 37: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Triangulation: Linear approach

XPxXPx

22

11

==

2

1

ll

0XPx0XPx

22

11

=´=´

0X]P[x0X]P[x

22

11

==

´

´

Two independent equations each in terms of three unknown entries of X

Page 38: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Preview: Structure from motion

Camera 3R3,t3

Figure credit: Noah Snavely

Camera 1Camera 2R1,t1 R2,t2

• Given 2D point correspondences between multiple images, compute the camera parameters and the 3D points

Page 39: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Preview: Structure from motion

Camera 3R3,t3

Camera 1Camera 2R1,t1 R2,t2

• Structure: Given known cameras and projections of the same 3D point in two or more images, compute the 3D coordinates of that point• Triangulation!

?

Page 40: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Preview: Structure from motion

Camera 3R3,t3

Camera 1Camera 2R1,t1 R2,t2

• Motion: Given a set of known 3D points seen by a camera, compute the camera parameters• Calibration!

? ? ?

Page 41: Geometry of a single cameraslazebni.cs.illinois.edu/spring19/lec14_calibration.pdfcenter is at the origin, the principal axis is the z-axis, x and y axes of the image plane are parallel

Useful reference