Camera calibration
description
Transcript of Camera calibration
Camera calibration
Digital Visual Effects, Spring 2007Yung-Yu Chuang2007/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)• Nonlinear least square methods• Bundle adjustment
Camera projection models
Pinhole camera
Pinhole camera model
(optical center)
origin
principal point
P(X,Y,Z)
p
(x,y)
Pinhole camera model
10100000000
~1
ZYX
ff
ZfYfX
yx
ZfYy
ZfXx
principal point
Pinhole camera model
1010000100001
1000000
~1
ZYX
ff
ZfYfX
yx
principal point
Principal point offset
1010000100001
1000
0~
10
0
ZYX
yfxf
ZfYfX
yx
XIKx 0~
intrinsic matrix
principal point
only related to camera projection
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?
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
Camera rotation and translation
tR
ZYX
ZYX
33
'''
1100
00
~1
0
0
ZYX
yfxf
yx
tR
XtRKx ~
extrinsic matrix
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?
Other projection models
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
Other types of projections• Scaled orthographic
– Also called “weak perspective”
• Affine projection– Also called “paraperspective”
Fun with perspective
Perspective cues
Perspective cues
Fun with perspective
Ames room
Forced perspective in LOTR
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
Camera calibration approaches1. linear regression (least squares)2. nonlinear optimization3. multiple planar patterns
Chromaglyphs (HP research)
Linear regression
MXXtRKx ~
Linear regression• Directly estimate 11 unknowns in the M matrix using known 3D points (Xi,Yi,Zi) and measured feature positions (ui,vi)
Linear regression
Linear regression
Linear regression
Solve for Projection Matrix M using least-square techniques
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?
Normal equation
2)( bAxx E
n
m
nmn
m
b
b
x
x
aa
aa
:::
:
...::::::
... 1
1
1
111
nxm, n equations, m variables
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
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 →
Normal equation
bbxbAxbAAxAx
bbbAxAxbAxAxbAxbAxbAxbAx
bAxbAx
bAx
TTTTTTT
TTTTTT
TTT
TT
T
2
bAAxAx
TT 22 E
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
Nonlinear optimization• A probabilistic view of least square• Feature measurement equations
• Likelihood of M given {(ui,vi)}
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?
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
A popular calibration tool
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/
Step 1: data acquisition
Step 2: specify corner order
Step 3: corner extraction
Step 3: corner extraction
Step 4: minimize projection error
Step 4: camera calibration
Step 4: camera calibration
Step 5: refinement
Nonlinear least square methods
Least square fitting
number of data pointsnumber of parameters
Linear least square fittingy
t
txxtxMty 10),()(
3210),( txtxxtxM is linear, too.
model parameters
),()( iii txMyxf
residualprediction
Nonlinear least square fitting
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.
Function minimization
Quadratic functionsApproximate the function with a quadratic function within a small neighborhood
Quadratic functionsA is positive definite.All eigenvalues are positive.Fall all x, xTAx>0.
negative definite
A is indefiniteA is singular
Function minimization
Descent methods
Descent direction
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
Line search
minumum is )(
that so Find
0 h)F(x α
)('
)(0
0
0
hxFhxxF
h)F(x
T α
α
)(xF'h 0
Line search
Hhhhh
T
T
0)(' 0 hxFhT α
)(xF'h 0
0
)()(
)('
0''
0'
0
Hhhhh
hxFxFh
hxFh
TT
TT
T
α
α
α
Steepest descent method
isocontour gradient
Steepest descent method
It has good performance in the initial stage of the iterative process. Converge very slow with a linear rate.
Newton’s method
It has good performance in the final stage of the iterative process, where x is close to x*.
→
→
→→
Hybrid method
This needs to calculate second-order derivative which might not be available.