Lecture’9’&’10:’’...
Transcript of Lecture’9’&’10:’’...
Lecture 9 & 10 - !!!
Fei-Fei Li!
Lecture 9 & 10: Stereo Vision
Professor Fei-‐Fei Li Stanford Vision Lab
15-‐Oct-‐13 1
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we will learn today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 2
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we will learn today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 3
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10
Lecture 9 & 10 - !!!
Fei-Fei Li!
Recovering 3D from Images
• How can we automaEcally compute 3D geometry from images? – What cues in the image provide 3D informaEon?
Point of observation
Real 3D world 2D image
? 15-‐Oct-‐13 4
Lecture 9 & 10 - !!!
Fei-Fei Li!
• Shading
Visual Cues for 3D
Merle Norman Cosme2cs, Los Angeles
Slide cred
it: J. Hayes
15-‐Oct-‐13 5
Lecture 9 & 10 - !!!
Fei-Fei Li!
Visual Cues for 3D
• Shading
• Texture
The Visual Cliff, by William Vandivert, 1960
Slide cred
it: J. Hayes
15-‐Oct-‐13 6
Lecture 9 & 10 - !!!
Fei-Fei Li!
Visual Cues for 3D
From The Art of Photography, Canon
• Shading
• Texture
• Focus
Slide cred
it: J. Hayes
15-‐Oct-‐13 7
Lecture 9 & 10 - !!!
Fei-Fei Li!
Visual Cues for 3D
• Shading
• Texture
• Focus
• MoEon
Slide cred
it: J. Hayes
15-‐Oct-‐13 8
Lecture 9 & 10 - !!!
Fei-Fei Li!
Visual Cues for 3D
• Others: – Highlights – Shadows – Silhoue`es – Inter-‐reflecEons – Symmetry – Light PolarizaEon – ...
• Shading
• Texture
• Focus
• MoEon Shape From X
• X = shading, texture, focus, moEon, ... • We’ll focus on the moEon cue
Slide cred
it: J. Hayes
15-‐Oct-‐13 9
Lecture 9 & 10 - !!!
Fei-Fei Li!
Stereo ReconstrucEon
• The Stereo Problem – Shape from two (or more) images – Biological moEvaEon
known camera
viewpoints
Slide cred
it: J. Hayes
15-‐Oct-‐13 10
Lecture 9 & 10 - !!!
Fei-Fei Li!
Why do we have two eyes?
Cyclope vs. Odysseus
Slide cred
it: J. Hayes
15-‐Oct-‐13 11
Lecture 9 & 10 - !!!
Fei-Fei Li!
1. Two is be`er than one
Slide cred
it: J. Hayes
15-‐Oct-‐13 12
Lecture 9 & 10 - !!!
Fei-Fei Li!
2. Depth from Convergence
Human performance: up to 6-8 feet
Slide cred
it: J. Hayes
15-‐Oct-‐13 13
Lecture 9 & 10 - !!!
Fei-Fei Li!
3. Depth from binocular disparity
Sign and magnitude of disparity
P: converging point
C: object nearer projects to the outside of the P, disparity = +
F: object farther projects to the inside of the P, disparity = -
Slide cred
it: J. Hayes
15-‐Oct-‐13 14
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we will learn today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 15
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 16
Epipolar geometry
• Epipolar Plane • Epipoles e1, e2
• Epipolar Lines • Baseline
O1 O2
p2
P
p1
e1 e2
= intersecEons of baseline with image planes = projecEons of the other camera center = vanishing points of camera moEon direcEon
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 17
Example: Converging image planes
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 18
Epipolar Constraint
-‐ Two views of the same object -‐ Suppose I know the camera posiEons and camera matrices -‐ Given a point on lel image, how can I find the corresponding point on right image?
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 19
Epipolar Constraint
• PotenEal matches for p have to lie on the corresponding epipolar line l’.
• PotenEal matches for p’ have to lie on the corresponding epipolar line l.
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 20
Epipolar Constraint
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
=→
1vu
PMp
O O’
p p’
P
R, T
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡ʹ′
ʹ′
=ʹ′→
1vu
PMp
[ ]01 IKM = [ ]TRKM 2'=
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 21
Epipolar Constraint
O O’
p p’
P
R, T
K1 and K2 are known (calibrated cameras)
[ ]0IM = [ ]TRM ='
[ ]01 IKM = [ ]TRKM 2'=
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 22
Epipolar Constraint
O O’
p p’
P
R, T
[ ] 0)pR(TpT =ʹ′×⋅Perpendicular to epipolar plane
)( pRT ʹ′×
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 23
Cross product as matrix mulEplicaEon
baba ][0
00
×=
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−
−
−
=×
z
y
x
xy
xz
yz
bbb
aaaaaa
“skew symmetric matrix”
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 24
Epipolar Constraint
O O’
p p’
P
R, T
[ ] 0)pR(TpT =ʹ′×⋅ [ ] 0pRTpT =ʹ′⋅⋅→ ×
E = essenEal matrix (Longuet-‐Higgins, 1981)
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 25
Epipolar Constraint
• E p2 is the epipolar line associated with p2 (l1 = E p2) • ET p1 is the epipolar line associated with p1 (l2 = ET p1) • E is singular (rank two) • E e2 = 0 and ET e1 = 0 • E is 3x3 matrix; 5 DOF
O1 O2
p2
P
p1
e1 e2 l1 l2
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we will learn today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 26
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10
Lecture 9 & 10 - !!!
Fei-Fei Li!
Simplest Case: Parallel images • Image planes of cameras
are parallel to each other and to the baseline
• Camera centers are at same height
• Focal lengths are the same
Slide cred
it: J. Hayes
15-‐Oct-‐13 27
Lecture 9 & 10 - !!!
Fei-Fei Li!
• Image planes of cameras are parallel to each other and to the baseline
• Camera centers are at same height
• Focal lengths are the same • Then, epipolar lines fall
along the horizontal scan lines of the images
Simplest Case: Parallel images
Slide cred
it: J. Hayes
15-‐Oct-‐13 28
Lecture 9 & 10 - !!!
Fei-Fei Li!
Essential matrix for parallel images
pTE !p = 0, E = [t× ]R
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−== ×
0000
000][
TTRtE
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−
−
−
=×
00
0][
xy
xz
yz
aaaaaa
a
R = I t = (T, 0, 0)
Epipolar constraint:
t
p
p’
Reminder: skew symmetric matrix
Slide cred
it: J. Hayes
15-‐Oct-‐13 29
Lecture 9 & 10 - !!!
Fei-Fei Li!
( ) ( ) vTTvvTTvuv
u
TTvu ʹ′==
⎟⎟⎟
⎠
⎞
⎜⎜⎜
⎝
⎛
ʹ′
−=⎟⎟⎟
⎠
⎞
⎜⎜⎜
⎝
⎛ʹ′
ʹ′
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
− 00
10100
00000
1
The y-coordinates of corresponding points are the same!
t
p
p’
Essential matrix for parallel images
pTE !p = 0, E = [t× ]R
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−== ×
0000
000][
TTRtE
R = I t = (T, 0, 0)
Epipolar constraint:
Slide cred
it: J. Hayes
15-‐Oct-‐13 30
Lecture 9 & 10 - !!!
Fei-Fei Li!
Triangulation -- depth from disparity
f
p p’
Baseline B
z
O O’
P
f
disparity = u− "u = B ⋅ fz
Disparity is inversely proportional to depth!
Slide cred
it: J. Hayes
15-‐Oct-‐13 31
Lecture 9 & 10 - !!!
Fei-Fei Li!
Stereo image rectification
Slide cred
it: J. Hayes
15-‐Oct-‐13 32
Lecture 9 & 10 - !!!
Fei-Fei Li!
Algorithm: • Re-project image planes onto a
common plane parallel to the line between optical centers
• Pixel motion is horizontal after this transformation
• Two transformation matrices, one for each input image reprojection
Ø C. Loop and Z. Zhang. Computing Rectifying Homographies for Stereo Vision. IEEE Conf. Computer Vision and Pattern Recognition, 1999.
Stereo image rectification
Slide cred
it: J. Hayes
15-‐Oct-‐13 33
Lecture 9 & 10 - !!!
Fei-Fei Li!
Rectification example
15-‐Oct-‐13 34
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 35
Applica2on: view morphing S. M. Seitz and C. R. Dyer, Proc. SIGGRAPH 96, 1996, 21-‐30
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 36
Applica2on: view morphing
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 37
Applica2on: view morphing
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 38
Applica2on: view morphing
Lecture 9 & 10 - !!!
Fei-Fei Li!
Removing perspective distortion
Hp
(rectification)
15-‐Oct-‐13 39
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we will learn today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 40
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10
Lecture 9 & 10 - !!!
Fei-Fei Li!
Reminder: transformaEons in 2D
Special case from lecture 2 (planar rotaEon & translaEon)
u 'v '1
!
"
###
$
%
&&&= R t
0 1
!
"#
$
%&
uv1
!
"
###
$
%
&&&= He
uv1
!
"
###
$
%
&&&
- 3 DOF - Preserve distance (areas) - Regulate motion of rigid object
Lecture 9 & 10 - !!!
Fei-Fei Li!
u 'v '1
!
"
###
$
%
&&&=
a1 a2 a3a4 a5 a6a7 a8 a9
!
"
####
$
%
&&&&
uv1
!
"
###
$
%
&&&= H
uv1
!
"
###
$
%
&&&
- 8 DOF - Preserve colinearity
Reminder: transformaEons in 2D
Generic case (rotaEon in 3D, scale & translaEon)
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 43
Lecture 9 & 10 - !!!
Fei-Fei Li!
Computing H
-‐ 8 DOF -‐ how many points do I need to esEmate H?
At least 4 points! (8 equations) - There are several algorithms…
15-‐Oct-‐13 44
H
Lecture 9 & 10 - !!!
Fei-Fei Li!
DLT algorithm (Direct Linear Transformation)
pi !pi!pi = H pi
15-‐Oct-‐13 45
H
Lecture 9 & 10 - !!!
Fei-Fei Li!
DLT algorithm (direct Linear Transformation)
!pi ×H pi = 0
9x1
0Ai =hFunction of measurements
Unknown [9x1]
[2x9]
2 independent equaEons
h =
h1h2h9
!
"
#####
$
%
&&&&&
15-‐Oct-‐13 46
H =
h1 h2 h3h4 h5 h6h7 h8 h9
!
"
####
$
%
&&&&
Lecture 9 & 10 - !!!
Fei-Fei Li!
DLT algorithm (direct Linear Transformation)
0hAi =9x2A
0hA1 =0hA2 =
0hAN =
0hA 199N2 =××
1x9h
Over determined Homogenous system
ix ixʹ′
H
15-‐Oct-‐13 47
Lecture 9 & 10 - !!!
Fei-Fei Li!
DLT algorithm (direct Linear Transformation)
0hA 199N2 =××How to solve ?
Singular Value Decomposition (SVD)!
15-‐Oct-‐13 48
Lecture 9 & 10 - !!!
Fei-Fei Li!
DLT algorithm (direct Linear Transformation)
0hA 199N2 =××
999992 ××× Σ Tn VU
Last column of V gives h! H!
How to solve ?
Singular Value Decomposition (SVD)!
Why? See pag 593 of AZ
15-‐Oct-‐13 49
Lecture 9 & 10 - !!!
Fei-Fei Li!
DLT algorithm (direct Linear Transformation)
How to solve ? 0hA 199N2 =××
15-‐Oct-‐13 50
Lecture 9 & 10 - !!!
Fei-Fei Li!
Clarification about SVM Tnnnnnmnm VDUP ×××× =
Tnnnmmmnm VDUP ×××× =
Has n orthogonal columns
Orthogonal matrix
• This is one of the possible SVD decompositions • This is typically used for efficiency • The classic SVD is actually:
orthogonal Orthogonal
15-‐Oct-‐13 51
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we will learn today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 52
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10
Lecture 9 & 10 - !!!
Fei-Fei Li!
Stereo matching: solving the correspondence problem
• Multiple matching hypotheses satisfy the epipolar constraint, but which one is correct?
15-‐Oct-‐13 53
Lecture 9 & 10 - !!!
Fei-Fei Li!
Basic stereo matching algorithm
• For each pixel in the first image – Find corresponding epipolar line in the right image – Examine all pixels on the epipolar line and pick the best match – Triangulate the matches to get depth information
• Simplest case: epipolar lines are scanlines
– When does this happen?
Slide cred
it: J. Hayes
15-‐Oct-‐13 54
Lecture 9 & 10 - !!!
Fei-Fei Li!
Basic stereo matching algorithm
• If necessary, rectify the two stereo images to transform epipolar lines into scanlines
• For each pixel x in the first image – Find corresponding epipolar scanline in the right image – Examine all pixels on the scanline and pick the best match x’ – Compute disparity x-x’ and set depth(x) = 1/(x-x’)
corresponding
15-‐Oct-‐13 55
Lecture 9 & 10 - !!!
Fei-Fei Li!
• Let’s make some assumptions to simplify the matching problem – The baseline is relatively small (compared to the
depth of scene points) – Then most scene points are visible in both views – Also, matching regions are similar in appearance
Correspondence problem
Slide cred
it: J. Hayes
15-‐Oct-‐13 56
Lecture 9 & 10 - !!!
Fei-Fei Li!
Matching cost
disparity
Left Right
scanline
Correspondence search with similarity constraint
• Slide a window along the right scanline and compare contents of that window with the reference window in the left image
• Matching cost: SSD or normalized correlation
Slide cred
it: J. Hayes
15-‐Oct-‐13 57
Lecture 9 & 10 - !!!
Fei-Fei Li!
Left Right
scanline
Correspondence search with similarity constraint
SSD
15-‐Oct-‐13 58
Lecture 9 & 10 - !!!
Fei-Fei Li!
Left Right
scanline
Correspondence search with similarity constraint
Norm. corr
15-‐Oct-‐13 59
Lecture 9 & 10 - !!!
Fei-Fei Li!
Effect of window size
– Smaller window + More detail • More noise
– Larger window
+ Smoother disparity maps • Less detail
W = 3 W = 20
15-‐Oct-‐13 60
Lecture 9 & 10 - !!!
Fei-Fei Li!
The similarity constraint
• Corresponding regions in two images should be similar in appearance
• …and non-corresponding regions should be different • When will the similarity constraint fail?
Slide cred
it: J. Hayes
15-‐Oct-‐13 61
Lecture 9 & 10 - !!!
Fei-Fei Li!
Limitations of similarity constraint
Textureless surfaces Occlusions, repetition
Specular surfaces Slide cred
it: J. Hayes
15-‐Oct-‐13 62
Lecture 9 & 10 - !!!
Fei-Fei Li!
Results with window search
Window-based matching Ground truth
Left image Right image
15-‐Oct-‐13 63
Lecture 9 & 10 - !!!
Fei-Fei Li!
Better methods exist... (CS231a)
Graph cuts Ground truth
Y. Boykov, O. Veksler, and R. Zabih, Fast Approximate Energy Minimization via Graph Cuts, PAMI 2001
15-‐Oct-‐13 64
Lecture 9 & 10 - !!!
Fei-Fei Li!
The role of the baseline
• Small baseline: large depth error • Large baseline: difficult search problem
Large Baseline Small Baseline
Slide credit: S. Seitz
15-‐Oct-‐13 65
Lecture 9 & 10 - !!!
Fei-Fei Li!
Problem for wide baselines: Foreshortening
• Matching with fixed-size windows will fail! • Possible solution: adaptively vary window size • Another solution: model-based stereo (CS231a)
Slide credit: J. Hayes
15-‐Oct-‐13 66
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we will learn today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 67
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 68
Ac2ve stereo (point)
Replace one of the two cameras by a projector -‐ Single camera -‐ Projector geometry calibrated -‐ What’s the advantage of having the projector?
P
O2
p’
Correspondence problem solved!
projector
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 69
Ac2ve stereo (stripe)
O -‐ Projector and camera are parallel -‐ Correspondence problem solved!
projector
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 70
Ac2ve stereo (shadows)
Light source O
-‐ 1 camera,1 light source -‐ very cheap setup -‐ calibrated light source
J. Bouguet & P. Perona, 99 S. Savarese, J. Bouguet & Perona, 00
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 71
Ac2ve stereo (shadows) J. Bouguet & P. Perona, 99 S. Savarese, J. Bouguet & Perona, 00
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 72
Ac2ve stereo (color-‐coded stripes)
-‐ Dense reconstrucEon -‐ Correspondence problem again -‐ Get around it by using color codes
projector O
L. Zhang, B. Curless, and S. M. Seitz 2002 S. Rusinkiewicz & Levoy 2002
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 73
Ac2ve stereo (color-‐coded stripes)
L. Zhang, B. Curless, and S. M. Seitz. Rapid Shape AcquisiEon Using Color Structured Light and MulE-‐pass Dynamic Programming. 3DPVT 2002
Rapid shape acquisiEon: Projector + stereo cameras
Lecture 9 & 10 - !!!
Fei-Fei Li! 15-‐Oct-‐13 74
Ac2ve stereo (stripe)
• OpEcal triangulaEon – Project a single stripe of laser light – Scan it across the surface of the object – This is a very precise version of structured light scanning
Digital Michelangelo Project http://graphics.stanford.edu/projects/mich/
Lecture 9 & 10 - !!!
Fei-Fei Li!
Laser scanned models
The Digital Michelangelo Project, Levoy et al. Slide credit: S. Seitz
15-‐Oct-‐13 75
Lecture 9 & 10 - !!!
Fei-Fei Li!
Slide credit: S. Seitz
15-‐Oct-‐13
The Digital Michelangelo Project, Levoy et al.
Laser scanned models
76
Lecture 9 & 10 - !!!
Fei-Fei Li!
Slide credit: S. Seitz
Laser scanned models
The Digital Michelangelo Project, Levoy et al.
15-‐Oct-‐13 77
Lecture 9 & 10 - !!!
Fei-Fei Li!
Slide credit: S. Seitz
Laser scanned models
The Digital Michelangelo Project, Levoy et al.
15-‐Oct-‐13 78
Lecture 9 & 10 - !!!
Fei-Fei Li!
1.0 mm resoluEon (56 million triangles)
Slide credit: S. Seitz
Laser scanned models
The Digital Michelangelo Project, Levoy et al.
15-‐Oct-‐13 79
Lecture 9 & 10 - !!!
Fei-Fei Li!
What we have learned today?
• IntroducEon to stereo vision • Epipolar geometry: a gentle intro • Parallel images • Image recEficaEon • Solving the correspondence problem • AcEve stereo vision system
15-‐Oct-‐13 80
Reading: [HZ] Chapters: 4, 9, 11 [FP] Chapters: 10