SLIDE 1 Camera calibration
Digital Visual Effects, Spring 2006 Yung-Yu Chuang 2005/4/19
with slides by Richard Szeliski, Steve Seitz, and Marc Pollefyes
SLIDE 2 Announcements
- Artifacts for assignment #1 voting
http:/ / www.csie.ntu.edu.tw/ ~cyy/ vfx/ assignm ents/ proj 1/ artifacts/ index.html
SLIDE 3 Outline
- Camera proj ection models
- Camera calibration
- Nonlinear least square methods
- Bundle adj ustment
SLIDE 4
Camera projection models
SLIDE 5
Pinhole camera
SLIDE 6 Pinhole camera model
(optical center)
principal point
SLIDE 7
Pinhole camera model
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ 1 1 ~ 1 Z Y X f f Z fY fX y x Z fY y Z fX x = =
SLIDE 8
Pinhole camera model
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ 1 1 1 1 1 ~ 1 Z Y X f f Z fY fX y x
SLIDE 9 Principal point offset
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ 1 1 1 1 1 ~ 1 Z Y X y f x f Z fY fX y x
[ ]X
I K x ~
intrinsic matrix
SLIDE 10 Intrinsic matrix
- non-square pixels (digital video)
- skew
- radial distortion
⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ = 1 y f x f K ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ = 1 y f x s fa K
Is this form of K good enough?
SLIDE 11
Radial distortion
SLIDE 12 Camera rotation and translation
t R + ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ = ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛
×
Z Y X Z Y X
3 3
' ' '
[ ]
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ 1 1 ~ 1 Z Y X y f x f y x t R
[ ]X
t R K x ~
extrinsic matrix
SLIDE 13 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?
SLIDE 14
Other projection models
SLIDE 15 Orthographic projection
pecial case of perspective proj ection
– Distance from the COP to the PP is infinite – Also called “parallel proj ection”: (x, y, z) → (x, y)
Image World
SLIDE 16 Other types of projections
caled orthographic
– Also called “weak perspective”
– Also called “paraperspective”
SLIDE 17
Fun with perspective
SLIDE 18
Perspective cues
SLIDE 19
Perspective cues
SLIDE 20 Fun with perspective
Ames room
SLIDE 21
Forced perspective in LOTR
SLIDE 22
Camera calibration
SLIDE 23 Camera calibration
- Estimate both intrinsic and extrinsic parameters
- Mainly, two categories:
- 1. Photometric calibration: uses reference obj ects
with known geometry
elf calibration: only assumes static scene, e.g. structure from motion
SLIDE 24 Camera calibration approaches
- 1. linear regression (least squares)
- 2. nonlinear optinization
- 3. multiple planar patterns
SLIDE 25
Chromaglyphs (HP research)
SLIDE 26
Linear regression
[ ]
MX X t R K x = ~
SLIDE 27 Linear regression
- Directly estimate 11 unknowns in the M matrix
using known 3D points (X
i,Yi,Zi) and measured
feature positions (ui,vi)
SLIDE 28
Linear regression
SLIDE 29
Linear regression
SLIDE 30 Linear regression
S
- lve for Proj ection Matrix M using least-square
techniques
SLIDE 31 Normal equation
Given an overdetermined system
b Ax = b A Ax A
T T
=
the normal equation is that which minimizes the sum of the square differences between left and right sides Why?
SLIDE 32 Normal equation
( )
2
) ( b Ax x − = E ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎣ ⎡ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡
n m nm n m
b b x x a a a a : : : : ... : : : : : : ...
1 1 1 1 11
nxm, n equations, m variables
SLIDE 33 Normal equation
⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ − ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ ⎡ = −
∑ ∑ ∑ ∑ ∑ ∑
= = = = = = n m j j nj i m j j ij m j j j n i m j j nj m j j ij m j j j
b x a b x a b x a b b b x a x a x a
1 1 1 1 1 1 1 1 1 1
: : : : : : b Ax
( )
∑ ∑
= =
⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = − =
n i i m j j ij
b x a E
1 2 1 2
) ( b Ax x
SLIDE 34 Normal equation
( )
∑ ∑
= =
⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = − =
n i i m j j ij
b x a E
1 2 1 2
) ( b Ax x = ∂ ∂ =
1
x E
∑ ∑ ∑
= = =
− =
n i i i n i j m j ij i
b a x a a
1 1 1 1 1
2 2
1 1 1
2
i n i i m j j ij
a b x a
∑ ∑
= =
⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ − ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ ) ( 2 b A Ax A x
T T
− = ∂ ∂ = E
b A Ax A
T T
=
→
SLIDE 35 Linear regression
– All specifics of the camera summarized in one matrix – Can predict where any world point will map to in the image
– Doesn’ t tell us about particular parameters – Mixes up internal and external parameters
- pose specific: move the camera and everything breaks
SLIDE 36 Nonlinear optimization
- Feature measurement equations
- Likelihood of M given {(ui,vi)}
SLIDE 37 Optimal estimation
- Log likelihood of M given {(ui,vi)}
- How do we minimize C?
- Non-linear regression (least squares), because
ûi and vi are non-linear functions of M
- We can use Levenberg-Marquardt method to
minimize it
SLIDE 38 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/
SLIDE 39
Step 1: data acquisition
SLIDE 40
Step 2: specify corner order
SLIDE 41
S tep 3: corner extraction
SLIDE 42
S tep 3: corner extraction
SLIDE 43
Step 4: minimize projection error
SLIDE 44
Step 4: camera calibration
SLIDE 45
Step 4: camera calibration
SLIDE 46
Step 5: refinement
SLIDE 47
Nonlinear least square methods
SLIDE 48 Least square fitting
number of data points number of parameters
SLIDE 49 Linear least square fitting
y t
t x x t x M t y
1
) , ( ) ( + = = ) , ( ) (
i i i
t x M y x f − =
3 2 1
) , ( t x t x x t x M + + =
is linear, too. residual prediction
SLIDE 50
Nonlinear least square fitting
SLIDE 51 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.
SLIDE 52
Function minimization
SLIDE 53 Quadratic functions
Approximate the function with a quadratic function within a small neighborhood
SLIDE 54 Quadratic functions
A is positive definite. All eigenvalues are positive. Fall all x, xTAx>0. negative definite A is indefinite A is singular
SLIDE 55
Function minimization
SLIDE 56
Descent methods
SLIDE 57
Descent direction
SLIDE 58 Steepest descent method
It has good performance in the initial stage of the iterative
- process. Converge very slow with a linear rate.
the decrease of F(x) per unit along h direction
→
hsd is a descent direction because hT
sd F’ (x)=- F’ (x)2<0
SLIDE 59 Steepest descent method
isocontour gradient
SLIDE 60
Line search
SLIDE 61 Line search
Hh h h h
T T
= α
SLIDE 62
Steepest descent method
SLIDE 63 Newton’s method
It has good performance in the final stage of the iterative process, where x is close to x*.
→ → → →
SLIDE 64 Hybrid method
This needs to calculate second-order derivative which might not be available.
SLIDE 65 Levenberg-Marquardt method
- LM can be thought of as a combination of
steepest descent and the Newton method. When the current solution is far from the correct one, the algorithm behaves like a steepest descent method: slow, but guaranteed to converge. When the current solution is close to the correct solution, it becomes a Newton’ s method.
SLIDE 66 Nonlinear least square ). ( ˆ with , ˆ Here, minimal. is distance squared that the so vector parameter best the find try to , ts measuremen
set a Given p x x x p x f
T
= − = ε ε ε
SLIDE 67
Levenberg-Marquardt method
SLIDE 68 Levenberg-Marquardt method
- μ=0 → Newton’ s method
- μ→∞ → steepest descent method
- S
trategy for choosing μ
– S tart with some small μ – If F is not reduced, keep trying larger μ until it does – If F is reduced, accept it and reduce μ for the next iteration
SLIDE 69
Bundle adjustment
SLIDE 70 Bundle adjustment
- Bundle adj ustment (BA) is a technique for
simultaneously refining the 3D structure and camera parameters
- It is capable of obtaining an optimal
reconstruction under certain assumptions on image error models. For zero-mean Gaussian image errors, BA is the maximum likelihood estimator.
SLIDE 71 Bundle adjustment
- n 3D points are seen in m views
- xij is the proj ection of the i-th point on image j
- aj is the parameters for the j -th camera
- bi is the parameters for the i-th point
- BA attempts to minimize the proj ection error
Euclidean distance predicted proj ection
SLIDE 72
Bundle adjustment
SLIDE 73 Bundle adjustment
3 views and 4 points
SLIDE 74
Typical Jacobian
SLIDE 75
Block structure of normal equation
SLIDE 76
Bundle adjustment
SLIDE 77 Bundle adjustment
Multiplied by
SLIDE 78 Reference
- Manolis Lourakis and Antonis Argyros, The Design and
Implementation of a Generic S parse Bundle Adj ustment S
Package Based on the Levenberg-Marquardt Algorithm, FORTH- ICS / TR-320 2004.
- K. Madsen, H.B. Nielsen, O. Timgleff, Methods for Non-Linear Least
S quares Problems, 2004.
- Zhengyou Zhang, A Flexible New Techniques for Camera
Calibration, MS R-TR-98-71, 1998.
- Bill Triggs, Philip McLauchlan, Richard Hartley and Andrew
Fitzgibbon, Bundle Adj ustment - A Modern S ymthesis, Proceedings
- f the International Workshop on Vision Algorithms: Theory and
Practice, pp298-372, 1999.