Camera calibration

67
Camera calibration Digital Visual Effects, Spring 2007 Yung-Yu Chuang 2007/4/17 with slides by Richard Szeliski, Steve Seitz, and Marc Pollefyes

description

Camera calibration. Digital Visual Effects, Spring 2007 Yung-Yu Chuang 2007/4/17. with slides by Richard Szeliski, Steve Seitz, and Marc Pollefyes. Announcements. Project #2 is due next Tuesday before the class. Outline. Camera projection models Camera calibration (tools) - PowerPoint PPT Presentation

Transcript of Camera calibration

Page 1: Camera calibration

Camera calibration

Digital Visual Effects, Spring 2007Yung-Yu Chuang2007/4/17

with slides by Richard Szeliski, Steve Seitz, and Marc Pollefyes

Page 2: Camera calibration

Announcements• Project #2 is due next Tuesday before the

class

Page 3: Camera calibration

Outline• Camera projection models• Camera calibration (tools)• Nonlinear least square methods• Bundle adjustment

Page 4: Camera calibration

Camera projection models

Page 5: Camera calibration

Pinhole camera

Page 6: Camera calibration

Pinhole camera model

(optical center)

origin

principal point

P(X,Y,Z)

p

(x,y)

Page 7: Camera calibration

Pinhole camera model

10100000000

~1

ZYX

ff

ZfYfX

yx

ZfYy

ZfXx

principal point

Page 8: Camera calibration

Pinhole camera model

1010000100001

1000000

~1

ZYX

ff

ZfYfX

yx

principal point

Page 9: Camera calibration

Principal point offset

1010000100001

1000

0~

10

0

ZYX

yfxf

ZfYfX

yx

XIKx 0~

intrinsic matrix

principal point

only related to camera projection

Page 10: Camera calibration

Intrinsic matrix

• non-square pixels (digital video)• skew• radial distortion

1000

0

0

0

yfxf

K

1000 0

0

yfxsfa

K

Is this form of K good enough?

Page 11: Camera calibration

Distortion

• Radial distortion of the image– Caused by imperfect lenses– Deviations are most noticeable for rays that

pass through the edge of the lens

No distortion Pin cushion Barrel

Page 12: Camera calibration

Camera rotation and translation

tR

ZYX

ZYX

33

'''

1100

00

~1

0

0

ZYX

yfxf

yx

tR

XtRKx ~

extrinsic matrix

Page 13: Camera calibration

Two kinds of parameters• internal or intrinsic parameters such as

focal length, optical center, aspect ratio:what kind of camera?

• external or extrinsic (pose) parameters including rotation and translation:where is the camera?

Page 14: Camera calibration

Other projection models

Page 15: Camera calibration

Orthographic projection• Special case of perspective projection

– Distance from the COP to the PP is infinite

– Also called “parallel projection”: (x, y, z) → (x, y)

Image World

Page 16: Camera calibration

Other types of projections• Scaled orthographic

– Also called “weak perspective”

• Affine projection– Also called “paraperspective”

Page 17: Camera calibration

Fun with perspective

Page 18: Camera calibration

Perspective cues

Page 19: Camera calibration

Perspective cues

Page 21: Camera calibration

Forced perspective in LOTR

Page 22: Camera calibration

Camera calibration

Page 23: Camera calibration

Camera calibration• Estimate both intrinsic and extrinsic

parameters• Mainly, two categories:1. Photometric calibration: uses reference

objects with known geometry2. Self calibration: only assumes static scene,

e.g. structure from motion

Page 24: Camera calibration

Camera calibration approaches1. linear regression (least squares)2. nonlinear optimization3. multiple planar patterns

Page 25: Camera calibration

Chromaglyphs (HP research)

Page 26: Camera calibration

Linear regression

MXXtRKx ~

Page 27: Camera calibration

Linear regression• Directly estimate 11 unknowns in the M matrix using known 3D points (Xi,Yi,Zi) and measured feature positions (ui,vi)

Page 28: Camera calibration

Linear regression

Page 29: Camera calibration

Linear regression

Page 30: Camera calibration

Linear regression

Solve for Projection Matrix M using least-square techniques

Page 31: Camera calibration

Normal equationGiven an overdetermined system

bAx

bAAxA TT

the normal equation is that which minimizes the sum of the square differences between left and right sides

Why?

Page 32: Camera calibration

Normal equation

2)( bAxx E

n

m

nmn

m

b

b

x

x

aa

aa

:::

:

...::::::

... 1

1

1

111

nxm, n equations, m variables

Page 33: Camera calibration

Normal equation

n

m

jjnj

i

m

jjij

m

jjj

n

i

m

jjnj

m

jjij

m

jjj

bxa

bxa

bxa

b

b

b

xa

xa

xa

1

1

11

11

1

1

11

:

:

:

:

:

:

bAx

n

ii

m

jjij bxaE

1

2

1

2)( bAxx

Page 34: Camera calibration

Normal equation

n

ii

m

jjij bxaE

1

2

1

2)( bAxx

1

0xE

n

iii

n

ij

m

jiji baxaa

11

1 11 22

11 1

2 i

n

ii

m

jjij abxa

)(20 bAAxAx

TT

E bAAxA TT →

Page 35: Camera calibration

Normal equation

bbxbAxbAAxAx

bbbAxAxbAxAxbAxbAxbAxbAx

bAxbAx

bAx

TTTTTTT

TTTTTT

TTT

TT

T

2

bAAxAx

TT 22 E

Page 36: Camera calibration

Linear regression• Advantages:

– All specifics of the camera summarized in one matrix

– Can predict where any world point will map to in the image

• Disadvantages:– Doesn’t tell us about particular parameters– Mixes up internal and external parameters

• pose specific: move the camera and everything breaks

Page 37: Camera calibration

Nonlinear optimization• A probabilistic view of least square• Feature measurement equations

• Likelihood of M given {(ui,vi)}

Page 38: Camera calibration

Optimal estimation• Log likelihood of M given {(ui,vi)}

• It is a least square problem (but not necessarily linear least square)• How do we minimize C?

Page 39: Camera calibration

Optimal estimation• Non-linear regression (least squares), because the relations between ûi and ui are non-linear functions M

• We can use Levenberg-Marquardt method to minimize it

XtRKuuu ~ˆ

known constant

We could have terms like in thiscosf

unknown parameters

Page 40: Camera calibration

A popular calibration tool

Page 41: Camera calibration

Multi-plane calibration

Images courtesy Jean-Yves Bouguet, Intel Corp.Advantage• Only requires a plane• Don’t have to know positions/orientations• Good code available online!

– Intel’s OpenCV library: http://www.intel.com/research/mrl/research/opencv/ – Matlab version by Jean-Yves Bouget: http://www.vision.caltech.edu/bouguetj/calib_doc/index.html– Zhengyou Zhang’s web site: http://research.microsoft.com/~zhang/Calib/

Page 43: Camera calibration

Step 2: specify corner order

Page 44: Camera calibration

Step 3: corner extraction

Page 45: Camera calibration

Step 3: corner extraction

Page 46: Camera calibration

Step 4: minimize projection error

Page 47: Camera calibration

Step 4: camera calibration

Page 48: Camera calibration

Step 4: camera calibration

Page 49: Camera calibration

Step 5: refinement

Page 50: Camera calibration

Nonlinear least square methods

Page 51: Camera calibration

Least square fitting

number of data pointsnumber of parameters

Page 52: Camera calibration

Linear least square fittingy

t

txxtxMty 10),()(

3210),( txtxxtxM is linear, too.

model parameters

),()( iii txMyxf

residualprediction

Page 53: Camera calibration

Nonlinear least square fitting

Page 54: Camera calibration

Function minimization

It is very hard to solve in general. Here, we only consider a simpler problem of finding local minimum.

Least square is related to function minimization.

Page 55: Camera calibration

Function minimization

Page 56: Camera calibration

Quadratic functionsApproximate the function with a quadratic function within a small neighborhood

Page 57: Camera calibration

Quadratic functionsA is positive definite.All eigenvalues are positive.Fall all x, xTAx>0.

negative definite

A is indefiniteA is singular

Page 58: Camera calibration

Function minimization

Page 59: Camera calibration

Descent methods

Page 60: Camera calibration

Descent direction

Page 61: Camera calibration

Steepest descent method

the decrease of F(x) per unit along h direction→

hsd is a descent direction because hTsd F’(x)=- F’(x)2<0

Page 62: Camera calibration

Line search

minumum is )(

that so Find

0 h)F(x α

)('

)(0

0

0

hxFhxxF

h)F(x

T α

α

)(xF'h 0

Page 63: Camera calibration

Line search

Hhhhh

T

T

0)(' 0 hxFhT α

)(xF'h 0

0

)()(

)('

0''

0'

0

Hhhhh

hxFxFh

hxFh

TT

TT

T

α

α

α

Page 64: Camera calibration

Steepest descent method

isocontour gradient

Page 65: Camera calibration

Steepest descent method

It has good performance in the initial stage of the iterative process. Converge very slow with a linear rate.

Page 66: Camera calibration

Newton’s method

It has good performance in the final stage of the iterative process, where x is close to x*.

→→

Page 67: Camera calibration

Hybrid method

This needs to calculate second-order derivative which might not be available.