Camera Calibrations - Computer Vision
Camera Calibrations - Computer Vision
http://en.wikipedia.org/wiki/File:Jodhpur_tilt_shift.jpg
Miniature faking
Miniature faking
http://en.wikipedia.org/wiki/File:Oregon_State_Beavers_Tilt-Shift_Miniature_Greg_Keene.jpg
Review
• Previous section:
– Model fitting and outlier rejection
Review: Hough transform
y m
x b
y m
3 5 3 3 2 2
3 7 11 10 4 3
2 3 1 4 5 2
2 1 0 1 3 3
x b
Slide from S. Savarese
Review: RANSAC
N I 14
Algorithm:
1. Sample (randomly) the number of points required to fit the model (#=2)
2. Solve for model parameters using samples
3. Score by the fraction of inliers within a preset threshold of the model
Repeat 1-3 until the best model is found with high confidence
Review: 2D image transformations
Szeliski 2.1
This section – multiple views
• Today – Camera Calibration. Intro to multiple views
and Stereo.
• Next Lecture – Epipolar Geometry and Fundamental
Matrix. Stereo Matching (if there is time).
• Both lectures are relevant for project 2.
Recap: Oriented and Translated Camera
R
jw
t kw
Ow
iw
Recap: Degrees of freedom
x K R t X
5 6
x
u s u0 r11 r12 r13 tx
wv 0 v0 r21 r22 y
r23 ty
z
1 0 0 1 r31 r32 r33 t z
1
This Lecture: How to calibrate the camera?
x K R t X
X
su * * * * Y
sv * * * *
Z
s * * * *
1
What can we do with camera calibration?
How do we calibrate a camera?
Projection matrix
R,T
jw
kw
Ow
iw
x KR t X
x: Image Coordinates: (u,v,1)
K: Intrinsic Matrix (3x3)
R: Rotation (3x3)
t: Translation (3x1)
X: World Coordinates: (X,Y,Z,1)
Projection matrix
x
u f 0 0 0
x K I 0 X wv 0 y
f 0 0
z
1 0 0 1 0
1
Slide Credit: Saverese
Remove assumption: known optical center
x
u f 0 u0 0
x K I 0 X wv 0 y
f v0 0
z
1 0 0 1 0
1
Remove assumption: square pixels
x
u 0 u0 0
x K I 0 X wv 0 v0
0
y
z
1 0 0 1 0
1
Remove assumption: non-skewed pixels
x
u s u0 0
x K I 0 X wv 0 y
v0 0
z
1 0 0 1 0
1
R
jw
t kw
Ow
iw
Allow camera translation
x
u s u0 1 0 0 t x
x K I t X w v 0
v0 0 1 0 t y
y
z
1 0 0 1 0 0 1 t z
1
Slide Credit: Saverese
3D Rotation of Points
1 0 0
Rx ( ) 0 cos sin
p’
0 sin cos
cos 0 sin
R y ( ) 0 1 0
p
y sin 0 cos
cos sin 0
Rz ( ) sin cos 0
z
0 0 1
Allow camera rotation
x K R t X
x
u s u0 r11 r12 r13 tx
wv 0 v0 r21 r22 y
r23 ty
z
1 0 0 1 r31 r32 r33 t z
1
Degrees of freedom
x K R t X
5 6
x
u s u0 r11 r12 r13 tx
wv 0 v0 r21 r22 y
r23 ty
z
1 0 0 1 r31 r32 r33 t z
1
Beyond Pinholes: Radial Distortion
• Common in wide-angle lenses or
for special applications (e.g.,
security)
• Creates non-linear terms in
projection
• Usually handled by through solving
for distortion terms and then
correcting image to look like a
pinhole camera image
x K R t X
X
su * * * * Y
sv * * * *
Z
s * * * *
1
Calibrating the Camera
Use a scene with known geometry
– Correspond image points to 3d points
– Get least squares solution (or non-linear solution)
Known 2d Known 3d
image coords locations
X
su m11 m12 m13 m14 Y
sv m m22 m23 m24
21 Z
s m31 m32 m33 m34
1
X
su m11 m12 m13 m14 Y Known 3d
Known 2d
sv m m22 m23 m24
image coords 21 Z locations
s m31 m32 m33 m34
1
X
su m11 m12 m13 m14 Y Known 3d
Known 2d
sv m m22 m23 m24
image coords 21 Z locations
s m31 m32 m33 m34
1
m31uX m32uY m33uZ m34u m11 X m12Y m13 Z m14
m31vX m32 vY m33vZ m34 v m21 X m22Y m23 Z m24
• Disadvantages
– Doesn’t directly give you human-interpretable camera parameters
– Doesn’t model radial distortion
– Can’t impose constraints, such as known focal length
R
jw
t kw
Ow
iw
Recovering the camera center
x K R t X This is not the camera
center -C. It is –RC
x (because a point will
u s u0 r11 r12 r13 tx be rotated before tx, ty,
wv 0 v0 r21 r22 y
r23 ty and tz are added)
z
1 0 0 1 r31 r32 r33 t z
This, m4, is K * t
1
So K-1 m4 is t
X
su * * * * Y
So we need
-R-1 K-1 m4 to get C
sv * * * *
Z Q is K * R. So we just
s * * * *
need -Q-1 m4
1
Q
Estimate of camera center
Computer Vision
James Hays
Slides by
Kristen Grauman
Multiple views
stereo vision
Lowe
structure from motion
Hartley and Zisserman
optical flow
Why multiple views?
• Structure and depth are inherently ambiguous from
single views.
P1
P2
P1’=P2’
Optical center
• What cues help us to perceive 3d shape and depth?
Shading
Images from
same point of
view, different
camera
parameters
3d shape / depth
estimates
[From A.M. Loh. The recovery of 3-D structure using visual texture patterns. PhD thesis]
Perspective effects
Exploit disparity as
depth cue using single
image.
(Single image random
dot stereogram, Single
image stereogram)
— Carl Sagan
https://en.wikipedia.org/wiki/Pale_Blue_Dot
Motion of Sun (yellow), Earth (blue), and
Mars (red). At left, Copernicus' heliocentric geocentric model (often
Nicolaus Copernicus motion. At right, traditional geocentric motion, exemplified specifically by the
including the retrograde motion of Mars. Ptolemaic system)
https://en.wikipedia.org/wiki/Heliocentrism
If the apparent motion of the planets is caused by parallax, why aren’t
we seeing parallax for stars?
The angles involved in these calculations are very small and thus
difficult to measure. The nearest star to the Sun (and also the star
with the largest parallax), Proxima Centauri, has a parallax of
0.7685 ± 0.0002 arcsec.[1] This angle is approximately that
subtended by an object 2 centimeters in diameter located 5.3
kilometers away. First reliable measurements of parallax were not
Tycho Brahe
made until 1838, by Friedrich Bessel
https://en.wikipedia.org/wiki/Stellar_parallax
https://en.wikipedia.org/wiki/Stellar_parallax
Stereo vision
Camera 1 Camera 3
Camera 2
R1,t1 R3,t3
R2,t2 Slide credit:
Noah Snavely
Multi-view geometry problems
• Structure: Given projections of the same 3D point in two
or more images, compute the 3D coordinates of that point
Camera 1 Camera 3
Camera 2
R1,t1 R3,t3
R2,t2 Slide credit:
Noah Snavely
Multi-view geometry problems
• Motion: Given a set of corresponding points in two or
more images, compute the camera parameters
Camera 1
R1,t1 ? Camera 2
R2,t2 ? ?
Camera 3
R3,t3 Slide credit:
Noah Snavely
Estimating depth with stereo
• Stereo: shape from “motion” between two views
• We’ll need to consider:
• Info on camera pose (“calibration”)
• Image point correspondences
scene point
image plane
optical
center
Camera parameters
Camera
frame 2
Extrinsic parameters:
Camera frame 1 Camera frame 2
Intrinsic parameters:
Camera
Image coordinates relative to
frame 1 camera Pixel coordinates
Depth of p
image point image point
(left) (right)
Focal
length
optical
optical center
center (right)
(left) baseline
Geometry for a simple stereo system
• Assume parallel optical axes, known camera parameters
(i.e., calibrated cameras). What is expression for Z?
T xl x r T
Z f Z
T TT T
Z ZZf fZf f
xr xxrlr
- xxl lr xl
disparity
Depth from disparity
image I(x,y) Disparity map D(x,y) image I´(x´,y´)
(x´,y´)=(x+D(x,y), y)