Projections and Camera Calibration: Man-522: Computer Vision SET-2
Projections and Camera Calibration: Man-522: Computer Vision SET-2
Projections and Camera Calibration: Man-522: Computer Vision SET-2
SET-2
Projections and
Camera Calibration
Image formation
• How are objects in the world captured in
an image?
Physical parameters of
image formation
• Geometric
– Type of projection
– Camera pose
• Optical
– Sensor’s lens type
– focal length, field of view, aperture
• Photometric
– Type, direction, intensity of light reaching sensor
– Surfaces’ reflectance properties
Image formation
Image
plane
Virtual pinhole
image
In Latin, means
‘dark room’
http://www.acmi.net.au/AIC/CAMERA_OBSCURA.html
Camera obscura
http://brightbytes.com/cosite/collection2.html
Adapted from R. Duraiswami
Camera obscura at home
http://blog.makezine.com/archive/2006/02/how_to_room_
Sketch from http://www.funsci.com/fun3_en/sky/sky.htm sized_camera_obscu.html
Perspective effects
Perspective effects
• Far away objects appear smaller
Scene
Projection properties
• Many-to-one: any points along same ray map to
same point in image
• Points points
• Lines lines (collinearity preserved)
• Distances and angles are not preserved
• Degenerate cases:
– Line through focal point projects to a point.
– Plane through focal point projects to line
– Plane perpendicular to image plane projects to part of
the image.
Perspective and art
• Use of correct perspective projection indicated in
1st century B.C. frescoes
• Skill resurfaces in Renaissance: artists develop
systematic methods to determine perspective
projection (around 1480-1515)
Optical
Camera axis
frame
‘ Scene / world
‘’ ’ points
x
1 0 0 0 x
0 1 0 0 y
y x
(f' , f' )
y
z z z
0 0 1 / f ' 0 z / f '
1 divide by the third
coordinate to convert back
to non-homogeneous
coordinates
Camera
frame
Perspective projection & calibration
World Extrinsic:
frame
Camera frame World frame
Intrinsic:
Image coordinates relative to
camera Pixel coordinates
Camera
frame
Camera to World to 3D
2D Perspective
pixel coord.
point = trans. matrix
projection matrix camera coord.
trans. matrix
point
(3x1) (3x4) (4x1)
(3x3) (4x4)
Weak perspective
• Approximation: treat magnification as constant
• Assumes scene depth << average distance to
camera
Image World
plane points:
Orthographic projection
• Given camera at constant distance from scene
• World points projected along rays parallel to
optical access
Pinhole size / aperture
How does the size of the aperture affect the
image we’d get?
Larger
Smaller
Adding a lens
focal point
focal point
optical center
(Center Of Projection)
W
Object of Interest
in World Coordinate
System (U,V,W)
V
U
Imaging Geometry
Camera Coordinate
Y System (X,Y,Z).
X Z
• Z is optic axis
f • Image plane located f units
out along optic axis
• f is called focal length
Imaging Geometry
W
Y y
X Z x
V
U
W
Y y
X Z x
V
u U
V
u U
v Pixel
Coordinates
Forward Projection
3D-to-2D Projection
• perspective projection
O.Camps, PSU
Basic Perspective Projection
Scene Point Perspective Projection Eqns
P = (X,Y,Z)
X
Image Point y x f
Y
p = (x,y,f) X Y
Z
x Y
Z
y
y f
x
X
f Z
Z derived via similar
O
triangles rule
x X
f
Z
O.Camps, PSU
Basic Perspective Projection
Scene Point Perspective Projection Eqns
P = (X,Y,Z)
X
Image Point y x f
Y
p = (x,y,f) X Y
Z
x Y
Z
y
y f
x
X
f Z
Z derived via similar
O
triangles rule
X Y
y
x
f f
Z Z
O.Camps, PSU
Basic Perspective Projection
Scene Point Perspective Projection Eqns
P = (X,Y,Z)
X
Image Point y x f
Y
p = (x,y,f) X Y
Z
x Y
Z
y
y f
x
X
f Z
Z
O
O.Camps, PSU
Homogeneous Coordinates
Represent a 2D point (x,y) by a 3D point (x’,y’,z’) by
adding a “fictitious” third coordinate.
X X
x f x' f 0 0 0
y ' 0 Y
Z
f 0 0
Y Z
y f z ' 0 0 1 0
Z 1
Forward Projection
X
U
Z V
X
U
R Z V
C
Rotate to Translate by - C
align axes (align origins)
P C = R ( PW - C )
Matrix Form, Homogeneous Coords
P C = R ( PW - C )
X
Left camera located at world origin (0,0,0)
and camera axes aligned with world coord axes.
Simple Stereo, Left Camera
=
Simple Stereo Projection Equations
Left camera
Example: Simple Stereo System
Y Z
(X,Y,Z)
z
left y
camera
located at ( , )
z
(0,0,0) y ( , )
x right
camera
Tx located at
x (Tx,0,0)
X
Right camera located at world location (Tx,0,0)
and camera axes aligned with world coord axes.
Simple Stereo, Right Camera
=
Simple Stereo Projection Equations
Left camera
Right camera
Bob’s sure-fire way(s) to
figure out the rotation
X r11 r12 r13 1 0 0 cx U
Y r21 r22 r23 1 about
0forget 0 thiscy V
while thinking
Z r31 r32 r33 0 rotations
0about 1 cz W
1 0 0 0 1 0 0 0 1 1
PC = R P W
This equation says how vectors in the world coordinate
system (including the coordinate axes) get transformed
into the camera coordinate system.
Figuring out Rotations
X r11 r12 r13 U
Y r21 r22 r23 V PC = R P W
Z r31 r32 r33 W
1 0 0 0 1 1
what if world x axis (1,0,0) corresponds to camera axis (a,b,c)?
X
a r11 r12 r13 U
1 X
a ra11 r12 r13 U
1
Y
b r21 r22 r23 V
0 Y
b rb21 r22 r23 V
0
Z
c r31 r32 r33 0
W Z
c rc31 r32 r33 0
W
1 0 0 0 1 1 1 0 0 0 1 1
we can immediately write down the first column of R!
Figuring out Rotations
and likewise with world Y axis and world Z axis...
PC = R P W R-1PC = PW RTPC = PW
y
z
x
0 0 1 0 -1 0
Rtrain 0 -1 0 Rfly 0 0 1
1 0 0 -1 0 0
Note: External Parameters
also often written as R,T
X r11 r12 r13 1 0 0 cx U
Y r21 r22 r23 0 1 0 cy V
Z r31 r32 r33 0 0 1 cz W
1 0 0 0 1 0 0 0 1 1
W
Object of Interest
in World Coordinate
System (U,V,W)
V
U
Imaging Geometry
Camera Coordinate
Y System (X,Y,Z).
X Z
• Z is optic axis
f • Image plane located f units
out along optic axis
• f is called focal length
Imaging Geometry
W
Y y
X Z x
V
U
W
Y y
X Z x
V
u U
V
u U
v Pixel
Coordinates
Forward Projection
Affine Transformation
Intrinsic parameters
oy x v (row)
(0,0)
X Y
u f ox v f oy
Z Z
ox and oy called image center or principle point
Intrinsic parameters
sometimes one or more coordinate axes are flipped (e.g. T&V section 2.4)
oy y
v (row)
x
(0,0)
X Y
u f ox v f oy
Z Z
Intrinsic parameters (scales)
sampling determines how many rows/cols in the image
film scanning
resolution
pixel array
C cols x R rows
CCD
analog
resample
Effective Scales: sx and sy
1 X 1Y
u s f ox v f oy
x Z sy Z
Aspect ratio is sy / sx
O.Camps, PSU
Perspective projection matrix
Adding the intrinsic parameters into the
perspective projection matrix:
X
x' f / s x 0 ox 0
y ' 0 Y
f / sy oy 0
Z
z ' 0 0 1 0
1
To verify:
x’
u 1 X Y
1
z’ u s f ox v f oy
y’ x Z sy Z
v
z’
O.Camps, PSU
Note:
Sometimes, the image and the camera coordinate systems
have opposite orientations: [the book does it this way]
X X
f ( u o x ) s x x' f / s x 0 ox 0
Z y ' 0 Y
f / sy oy 0
Y Z
f ( v o y )s y z ' 0 0 1 0
Z 1
Note 2
In general, I like to think of the conversion as
a separate 2D affine transformation from film
coords (x,y) to pixel coordinates (u,v):
X
u’ a11 a12 xa' 13f 0 0 0
Y
v’ a21 a22 ya' 23 0
f 0 0
w’ Z
0 0 z 1' 0 0 1 0
1
Maff Mproj
U Mext X Mint u
V Y v
W Z
U u
M
V m11 m12 m13 m14 v
W m21 m22 m23 m24
m31 m31 m33 m34
Summary: Projection Equation
Film plane Perspective
World to camera
to pixels projection
Mint
M
Intro to Image Mappings
Image Mappings
Overview
from R.Szeliski
Geometric Image Mappings
Geometric
image transformation transformed image
(x,y)
(x’,y’)
x’ = f(x, y, {parameters})
y’ = g(x, y, {parameters})
Linear Transformations
(Can be written as matrices)
Geometric
image transformation transformed image
(x,y)
(x’,y’)
x’ x
y’ = M(params) y
1 1
Translation
y y’
transform
1
ty
0
0 1 x tx x’
0 0
0 1 x 0 S x’
)
0
0 1 x x’
)
1
ty
0
0 1 x tx x’
http://planetmath.org/encyclopedia/PartitionedMatrix.html
Partitioned Matrices
equation form
Another Example (from last time)
X r11 r12 r13 tx U
Y r21 r22 r23 ty V
Z r31 r32 r33 tz W
1 0 0 0 1 1
3x1 3x3 3x1 3x1
PC R T PW
1x1 = 1x3 1x1 1x1
1 0 1 1
PC = R P W + T
Similarity (scaled Euclidean)
y y’ S
transform
)
1
ty
0
0 1 x tx x’
0
0 1 x x’
0
0 1 x x’
Note!
Euclidean
Summary of 2D Transformations
Similarity
Summary of 2D Transformations
Affine
Summary of 2D Transformations
Projective
Summary of 2D Transformations
from R.Szeliski