augmented reality ii - camera calibrationcampar.in.tum.de/twiki/pub/far/augmentedrealityi... ·...
TRANSCRIPT
Augmented Reality II- Camera Calibration -
Gudrun KlinkerMay 11, 2004
Literature
• Richard Hartley and Andrew Zisserman,“Multiple View Geometry in ComputerVision”, Cambridge University Press, 2000.(Section 5, pp. 139-161)
Camera Calibration
• 3D-to-2D Projection:
†
x = PX
xy1
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
p11 p12 p13 p14
p21 p22 p23 p24
p31 p32 p33 p34
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
XYZ1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
Outline
• Finite camera model(Definition of camera parameters)
• Projective camera model(Properties of the projection matrix P,relationship to camera properties)
• Models of cameras at infinity• Computation of P
Finite Camera Model
Finite Camera Model
• Pinhole camera geometry• Central projection using homogeneous
coordinates• Principal point offset• Camera rotation and translation• CCD cameras• Skew parameter
Pinhole Camera Geometry
• Projection of 3D-Pointsonto a plane
• Center of projection:origin of Euclideancoordinate system Ccam
• Image plane at distance z = f (focal length)
†
XYZ
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
Æf X
Zf Y
Z
Ê
Ë Á Á
ˆ
¯ ˜ ˜
f
principalplane
imageplane
principal rayprincipalpointCcam
Central Projection UsingHomogeneous Coordinates
f
principalplane
imageplane
principal rayprincipalpointCcam
†
XYZ1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
Æ
f XZ
f YZ
1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
fXfYZ
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
f 0f 0
1 0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
XYZ1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
x = PXP = diag( f , f ,1) I | O[ ]
Principal Point Offset
• Principal point at (px, py)rel. to image origin
camera calibration matrix• 3 degrees of freedom
principalpoint
imageorigin
†
fX + Zpx
fY + Zpy
Z
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
f px 0f py 0
1 0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
XYZ1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
x = K I | O[ ]Xcam
K =
f px
f py
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
Ccam
cameracoordinateframe
Camera Rotation and Translation
cameracoordinateframe
worldcoordinateframe
• inhomogeneous (3x3):
• homogeneous (4x4):
• 3D-to-2D (3x4):
• 9 degrees of freedom;internal parameters K,external parameters R, C
R,C
†
˜ X cam = R( ˜ X - ˜ C )= R ˜ X - R ˜ C
†
x = KR I | - ˜ C [ ]X
Ccam
†
xcam =R -R ˜ C 0 1
È
Î Í
˘
˚ ˙ X
Camera Rotation and Translation- Alternative Representation -
• inhomogeneous (3x3):
• homogeneous (4x4):
• all-together (3x4):
• 9 degrees of freedom;internal parameters K,external parameters R, t
†
t = -R ˜ C ˜ X cam = R ˜ X + t
†
x = K R | t[ ]X†
xcam =R t0 1
È
Î Í
˘
˚ ˙ X
cameracoordinateframe
worldcoordinateframe
R,tCcam
Example
†
˜ C =2.00.0
-2.0
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
Rz(30°) =
0.866 0.5 0.0-0.5 0.866 0.0
0 0 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xcam = Rz | -Rz˜ C [ ]X
=
0.866 0.5 0 -1.732-0.5 0.866 0 1.0
0 0 1 2.0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
X
cameracoordinateframe
worldcoordinateframe
Ccam R,C
CCD Cameras
• non-square pixels• scale factors mx, my, aspect ratio mx/my
• all-together (3x4):
• 10 degrees of freedom†
K =
mx
my
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
f px
f py
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
=
ax x0
ay y0
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
†
x = KR I | t[ ]X
Skew Parameter(Finite Projective Camera)
• skew parameter s
• all-together:
• 11 degrees of freedom
†
K =
ax s x0
ay y0
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
†
x = KR I | t[ ]X
Finite Camera Model- Summary -
• Pinhole camera geometry (f)• Central projection• Principal point offset (px, py)• Camera rotation and translation (R, t)• CCD cameras (mx, my) --> (ax, ay, x0, y0)• Skew parameter (s)
†
x =
ax s x0
ay y0
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
R | t[ ]X
Projective Camera Model
Projective Camera ModelGiven some matrix PNotations for P:
†
P =
p11 p12 p13 p14
p21 p22 p23 p24
p31 p32 p33 p34
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
=
P1T
P2T
P3T
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
= p1 p2 p3 p4[ ]= M | p4[ ]
Camera Center
• P is 3x4 matrix, rank = 31-dimensional null-space
• Ray through thecamera center†
PC = 0cameracenter
C
†
X(l) = lA + (1- l)Cx = PX(l)
= lPA + (1- l)PC= lPA
†
M | p4[ ]C = 0
Camera Center
• 1-dimensional null-space
• Ray through thecamera center
• Hom. representation ofcamera center
†
PC = 0
†
KR I | - ˜ C [ ]C = 0
C =˜ C T
1
Ê
Ë Á
ˆ
¯ ˜ =
-M-1p4
1
Ê
Ë Á
ˆ
¯ ˜
†
M | p4[ ]C = 0cameracenter
C
Example
†
PC = 0
0.866 0.5 0 -1.732-0.5 0.866 0 1.0
0 0 1 2.0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
20
-21
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
1.732 -1.732-1.0 +1.0-2.0 + 2.0
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
000
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
Rz | -Rz˜ C [ ]C = 0
M | p4[ ]C = 0
cameracoordinateframe
worldcoordinateframe
Ccam R,C
†
C =-M-1p4
1
Ê
Ë Á
ˆ
¯ ˜
C =-
0.866 -0.5 00.5 0.866 00 0 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
-1.73212
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
20
-21
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
Summary- Camera Center -
-M-1
p 4ca
mer
a ce
nter
M
Column Vectors of P
• p1,p2,p3: vanishingpoints of x-, y-, z-axis,(e.g.: direction of x-axis, D)
• p4: image of worldorigin (0,0,0 1)T
†
P = p1 p2 p3 p4[ ]
†
p1 = PD = P
1000
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
cameracenter
p1
worldcoordinateframe
(1,0,0)p1
Example
†
0.866 0.5 0 -1.732-0.5 0.866 0 1.0
0 0 1 2.0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
1000
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
0.866-0.5
0
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
0.866 0.5 0 -1.732-0.5 0.866 0 1.0
0 0 1 2.0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
0100
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
0.50.866
0
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
0.866 0.5 0 -1.732-0.5 0.866 0 1.0
0 0 1 2.0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
0010
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
001
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
0.866 0.5 0 -1.732-0.5 0.866 0 1.0
0 0 1 2.0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
0001
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
-1.7321.02.0
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
p4
p2
p1
Summary- Column Space -
imag
e of
x-a
xis
imag
e of
y-a
xis
imag
e of
z-a
xis
imag
e of
wor
ld o
rigin
“dist
ance
” w o
f wor
ld
orig
in fr
om
cam
era
ctr
Row Vectors of P
• P3T: principal plane
i.e.,(line at infinity)
• P1T, P2T: axis planes
i.e.,(plane P1)
†
P =
P1T
P2T
P3T
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
†
PX =
xy0
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
†
P3T X = 0
†
PX =
0yw
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
†
P1T X = 0
Example• P3T: principal plane
• axis plane P1T
†
0.866 0.5 0 -1.732-0.5 0.866 0 1
0 0 1 2
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
X =
xy0
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
0 0 1 2( )X = 0z = -2
†
0.866 0.5 0 -1.732-0.5 0.866 0 1
0 0 1 2
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
X =
0yw
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
0.866 0.5 0 -1.732( )X = 00.866x + 0.5y =1.732
y = 2(1.732 - 0.866x)
Summary- Row Space -
normal to plane throughy-axis and camera center
normal to plane throughx-axis and camera center
normal to principal plane through camera center
“principal ray”
Principal Point
• Principal axis: ray from C,perp. to principal plane P3
• Normal to P3:(p31,p32,p33,0)T
(on plane at infinity)• Principal point:
– intersectionof principal axis with imageplane
– Projection of (p31,p32,p33,0)T
onto the image planex0 = P(p31,p32,p33,0) T = Mm3
(with P = [M | p4])
f
principalplane
imageplane
principal rayprincipalpointCcam
Example• principal point
†
P =
0.866 0.5 0 -1.732-0.5 0.866 0 1
0 0 1 2
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
x0 = Mm3
=
0.866 0.5 0-0.5 0.866 0
0 0 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
001
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
001
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
Summary- Principal Ray -
principal raydirection
“distance” wof world originfrom cameracenter
imag
e of
wor
ld o
rigin
Depth of Points
• Perpendicular distance w of a point X fromthe principal plane (along the principal ray)
(since PC=0 for the camera center)
• Dot product of the ray from the cameracenter to X with the principal ray direction
†
w = P3T X= P3T (X - C)
= m3T ( ˜ X - ˜ C )
Cameras at Infinity
Cinematography
• Move camera backwards along the opticalaxis (with increasing z)
• Rescale picture by increasing f
– small z and f: perspective– large z and f: weak perspective†
x' = f xz
dx'= f(xz
- xz +1
) = f( xz2 +z
)
Cameras at Infinity
“distance” wof world originfrom cameracenter
r1T
r2T
r3T
-r1TC
-r2TC
d0..t = -r3TC
Moving camera along the principal ray:
Cameras at Infinity
“distance” wof initialworld originfrom cameracenter
r1T
r2T
r3Td0/dt 0T
-r1TC
-r2TC
d0
Zooming (by factor k = dt/d0):
dt/d0 K
†
P• , affine Camera
Cameras at Infinity- Weak Perspective -
• The action of a weak perspective camera isequivalent to orthographic projection onto aplane at Z=d0, followed by a perspectiveprojection from the plane.
x
d0f
Cameras at Infinity- Affine Approximation -
• The effect of the affine approximation tothe true camera matrix P0 is to move theimage of a point X radially towards or awayfrom the principal point x0 by a factor equalto . †
P•
†
1+ Dd0 x
d0f
Cameras at Infinity
• The distance between the true perspectiveimage position and the position obtainedusing the affine camera approximation issmall, if– the depth relief is small compared to the
average depth (d0)– the distance of the point from the principal ray
is small
Parallel Projection versusPerspective Projection
Central Projection UsingHomogeneous Coordinates
f
principalplane
imageplane
principal rayprincipalpointCcam
†
XYZ1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
Æ
f XZ
f YZ
1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
fXfYZ
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
f 0f 0
1 0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
XYZ1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
x = PXP = diag( f , f ,1) I | O[ ]
Reminder
Principal Point Offset
• Principal point at (px, py)rel. to image origin
camera calibration matrix• 3 degrees of freedom
principalpoint
imageorigin
†
fX + Zpx
fY + Zpy
Z
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
f px 0f py 0
1 0
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
XYZ1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
x = K I | O[ ]Xcam
K =
f px
f py
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
Ccam
cameracoordinateframe
Reminder
Cameras at Infinity- Parallel Projection -
• parallel projection matrix:
• calibration matrix
• principal point is not defined
†
1 0 0 00 1 0 00 0 0 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
†
K2x2ˆ 0
ˆ 0 T 1
È
Î Í
˘
˚ ˙
Hierarchy of Affine Cameras
Hierarchy of Affine Cameras
• orthographic projection
• with Euclidean transformations (5 DOF)
†
xy1
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
1 0 0 00 1 0 00 0 0 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xyz1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
†
xy1
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=R t0 T 1
È
Î Í
˘
˚ ˙
1 0 0 00 1 0 00 0 0 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xyz1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
r1T t1r2T t2
0T 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xyz1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
Hierarchy of Affine Cameras
• scaled orthographic projection (6 DOF)
• weak perspective projection (7 DOF)
†
xy1
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
kk
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
r1T t1r2T t2
0T 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xyz1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
=
r1T t1
r2T t2
0T 1k
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xyz1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
†
xy1
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
ax
ay
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
r1T t1r2T t2
0T 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xyz1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
Hierarchy of Affine Cameras
• affine camera (8 DOF)
†
xy1
Ê
Ë
Á Á Á
ˆ
¯
˜ ˜ ˜
=
ax say
1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
r1T t1r2T t2
0T 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙
xyz1
Ê
Ë
Á Á Á Á
ˆ
¯
˜ ˜ ˜ ˜
†
PA =
m11 m12 m13 t1
m21 m22 m23 t2
0 0 0 1
È
Î
Í Í Í
˘
˚
˙ ˙ ˙