Cameras Stereo 17 Ink
Cameras Stereo 17 Ink
Cameras Stereo 17 Ink
CSE 455
Linda Shapiro
1
Müller-Lyer Illusion
http://www.michaelbach.de/ot/sze_muelue/index.html
Object Film
4
Adding a lens
“circle of
confusion”
focal point
optical center
(Center Of Projection)
7
Digital camera
10
Modeling projection
3D point
C
negative z axis
11
Modeling projection
x/z = x´/-d
x´ = -d(x/z)
y/z = y´/-d
y´ = -d(y/z)
Projection equations
• Compute intersection with PP of ray from (x,y,z) to COP
• Derived using similar triangles
(x´,y´) 12
Homogeneous coordinates
Is this a linear transformation?
• no—division by z is nonlinear
Trick: add one more coordinate:
13
Perspective Projection
Projection is a matrix multiply using homogeneous coordinates:
14
Perspective Projection Example
1. Object point at (10, 6, 4), d=2
é x ù é ù
é 1 0 ù
0 ê ú é 1 0 ù
0 ê
10
ê
0
úê y ú ê
0 ú
úê 6 ú = é 10 6 -2 ù
ê 0 1 0 ú = 0 1
ê z ú ê
0 0 0 ú
ê 0 0 -1 / d 0 úê ê úê 4 ú ë û
ë û 1 ú ë 0 0 -1 / 2 0 ûê ú
ë û ë 1 û
Þ x' = -5, y' = -3
2. Object point at (25, 15, 10)
é x ù é 25 ù
é 1 0 ù
0 ê ú é 1 0 ù
0 ê
ê
0
úê y ú ê
0 ú
úê 15 ú é
ê 0 1 0 0 ú =ê 0 1 0 0 ú = ë 25 15 -5 ùû
ê ú
ê 0 0 -1 / d 0 úê z ú ê 0 0 -1 / 2 0 úê 10 ú
ë û 1 ë ûê 1 ú
ë û ë û
Þ x' = -5, y' = -3
Perspective projection is not 1-to-1!
15
Perspective Projection
How does scaling the projection matrix change the transformation?
SAME
16
Perspective Projection
17
Perspective Projection
What happens when d?
18
Orthographic projection
Special case of perspective projection
• Distance from the COP to the PP is infinite
Image World
19
Orthographic Projection
20
Camera parameters
How many numbers do we need to describe a camera?
21
A Tale of Two Coordinate Systems
v y
COP
u
Camera
w
Two important coordinate systems: o x
1. World coordinate system z “The World”
2. Camera coordinate system
22
Camera parameters
•To project a point (x,y,z) in world coordinates into a
camera
•First transform (x,y,z) into camera coordinates
•Need to know
– Camera position (in world coordinates)
– Camera orientation (in world coordinates)
•Then project into the image plane
– Need to know camera intrinsics
•These can all be described with matrices
23
3D Translation
• 3D translation is just like 2D with one more
coordinate
x′ 1 0 0 tx x
y′ = 0 1 0 ty y
z′ 0 0 1 tz z
1 0 0 0 1 1
24
3D Rotation (just the 3 x 3 part shown)
About X axis: 1 0 0 About Y: cosθ 0 sinθ
0 cosθ –sinθ 0 1 0
0 sinθ cosθ -sinθ 0 cosθ
Step 1: Translate by -c
image
plane
0
camera
27
Extrinsics
• How do we get the camera to “canonical form”?
– (Center of projection at the origin, x-axis points
right, y-axis points up, z-axis points backwards)
Step 1: Translate by -c
How do we represent
translation as a matrix
multiplication?
28
Extrinsics
• How do we get the camera to “canonical form”?
– (Center of projection at the origin, x-axis points
right, y-axis points up, z-axis points backwards)
Step 1: Translate by -c
Step 2: Rotate by R
Step 1: Translate by -c
Step 2: Rotate by R
30
Perspective projection
f is the focal
in general,
length of the
camera
: principal point ((0,0) unless optical axis doesn’t intersect projection plane at origin)
31
Focal length
• Can think of as “zoom”
24mm 50mm
200mm 800mm
intrinsics
projection rotation translation
33
Projection matrix
arbitrary 3D point
=
image plane
34
Distortion
35
Correcting radial distortion
CSE 455
Linda Shapiro
39
40
Amount of horizontal movement is
…
…inversely proportional to the distance from the camera
41
Depth from Stereo
• Goal: recover depth by finding image coordinate x’
that corresponds to x
X
X
x z
x x’
f f
x'
C Baseline C’
B
42
Depth from
X
disparity
x x f
z
O O z x x’
f f
O Baseline O’
B
B f
disparity x x
z
Disparity is inversely proportional to depth.
43
Depth from Stereo
• Goal: recover depth by finding image coordinate x’ that
corresponds to x
• Sub-Problems
1. Calibration: How do we recover the relation of the cameras (if
not already known)?
2. Correspondence: How do we search for the matching point x’?
x'
44
Correspondence Problem
x ?
45
Key idea: Epipolar constraint
X
x x’
x’
x’
46
Epipolar geometry: notation X
x x’
47
Epipolar geometry: notation X
x x’
49
Example: Motion parallel to
image plane
50
Epipolar constraint
X
x x’
51
Epipolar constraint
X
x x’
x’
x’
53
Epipolar constraint: Calibrated case
X
x x’
• Assume that the intrinsic and extrinsic parameters of the cameras are
known
• We can multiply the projection matrix of each camera (and the image
points) by the inverse of the calibration matrix to get normalized
image coordinates
• We can also set the global coordinate system to the coordinate
system of the first camera. Then the projection matrices of the two
cameras can be written as [I | 0] and [R | t] 54
Simplified Matrices for the 2
Cameras
= (R | T)
55
Epipolar constraint: Calibrated case
X = (x,1)T
x x’ = Rx+t
t
R
56
Epipolar constraint: Calibrated case
X
x x’
x [ t ( R x )] 0 xT E x 0 with E [ t ] R
Essential Matrix E
(Longuet-Higgins, 1981)
57
The vectors Rx, t, and x’ are coplanar
Epipolar constraint: Calibrated case
X
x x’
x [ t ( R x )] 0 xT E x 0 with E [ t ] R
• E x is the epipolar line associated with x (l' = E x)
• ETx' is the epipolar line associated with x' (l = ETx')
• E e = 0 and ETe' = 0
• E is singular (rank two)
• E has five degrees of freedom 58
Epipolar constraint: Uncalibrated
case
X
x x’
x x’
ˆxT E xˆ 0 T
x F x 0 with F K E K
T 1
ˆx K 1 x
Fundamental Matrix
xˆ K x
1 (Faugeras and Luong, 1992)
60
Epipolar constraint: Uncalibrated
case
X
x x’
ˆxT E xˆ 0 T
x F x 0 with F K E K
T 1
61
The eight-point algorithm
x (u, v,1)T , x (u, v,1) f11
f
12
f13
f11 f12 f13 u
f 21
u v 1 f 21 f 22 f 23 v 0 uu uv u vu vv v u v 1 f 22 0
f 31 f 32 f 33 1 A f 23
f
31
f 32
Smallest f
33
eigenvalue of
Minimize: ATA
N
i i
( x
i 1
T
F x ) 2
x x f
z
O O z x x’
f f
O Baseline O’
B
B f
disparity x x
z
Disparity is inversely proportional to depth.
65
Basic stereo matching algorithm
R=I t = (T, 0, 0)
x
0 0 0
x’
E t R 0 0 T
t 0 T 0
0 0 0 u 0
u v 10 0 T v 0 u v 1 T 0 Tv Tv
0 T 0 1 Tv
68
The y-coordinates of corresponding points are the same
Stereo image rectification
69
Stereo image rectification
• Reproject image planes
onto a common plane
parallel to the line
between camera centers
70
Example
Unrectified
Rectified
71
Left Right
scanline
Matching cost
disparity
scanline
SSD 73
Correspondence search
Left Right
scanline
Norm. corr 74
Effect of window size
W=3 W = 20
• Smaller window
+ More detail
– More noise
• Larger window
+ Smoother disparity maps
– Less detail
– Fails near boundaries 75
Failures of correspondence search
77
How can we improve window-based matching?
78
Stereo constraints/priors
• Uniqueness
– For any point in one image, there should be at
most one matching point in the other image
79
Stereo constraints/priors
• Uniqueness
– For any point in one image, there should be at most
one matching point in the other image
• Ordering
– Corresponding points should be in the same order in
both views
80
Stereo constraints/priors
• Uniqueness
– For any point in one image, there should be at most
one matching point in the other image
• Ordering
– Corresponding points should be in the same order in
both views
82
Stereo as energy minimization
Zero-mean SAD
87
Using more than two images