=
+ +
Multi‐view 3D Reconstruction for Dummies
Jianxiong Xiao
SFMedu Program with Code
=
+ +
Download from:
http://mit.edu/jxiao/Public/software/SFMedu/
Camera projection
• When people take a picture of a point:
x = K R t X
Camera projection
• When people take two pictures with same camera setting:
x
1= K R
1t
1X
x
2= K R
2t
2X
Camera projection
• When people take three pictures with same camera setting:
x
1= K R
1t
1X
x
2= K R
2t
2X
x
3= K R
3t
3X
Image 1
Image 2
Image 3
R
1,t
1R
2,t
2R
3,t
3X
Camera projection
x
1x
2x
3Image 1
Image 2
Image 3
R
1,t
1R
2,t
2R
3,t
3X
1Camera projection
X
2X
3X
4X
5X
6X
7x
11x
12x
13Camera projection
x
11= K R
1t
1X
1x
12= K R
2t
2X
1x
13= K R
3t
3X
1x
12= K R
1t
1X
2x
22= K R
2t
2X
2x
23= K R
2t
2X
3x
33= K R
3t
3X
3Point 1 Point 2 Point 3
Image 1 Image 2 Image 3
Same Camera Same Setting = Same K
Image 1
Image 2
Image 3
R
1,t
1R
2,t
2R
3,t
3Triangulation
x
1x
2x
3X
Structure From Motion
• Structure = 3D Point Cloud of the Scene
• Motion = Camera Location and Orientation
• SFM = Get the Point Cloud from Moving Cameras
• Structure and Motion: Joint Problems to Solve
=
+ +
Multi‐view Stereo (MVS) Structure from Motion (SFM)
Pipeline
Multi‐view Stereo (MVS) Structure from Motion (SFM)
Pipeline
Two‐view Reconstruction
Two‐view Reconstruction
Two‐view Reconstruction
keypoints
keypoints
match fundamental matrix
essential
matrix [R|t] triangulation
Keypoints Detection
keypoints keypoints
match fundamental matrix
essential
matrix [R|t] triangulation
Descriptor for each point
keypoints keypoints
match fundamental matrix
essential
matrix [R|t] triangulation SIFT
descriptor SIFT descriptor
Same for the other images
keypoints keypoints
match fundamental matrix
essential
matrix [R|t] triangulation SIFT
descriptor
SIFT descriptor
SIFT descriptor SIFT
descriptor
Point Match for correspondences
keypoints keypoints
match fundamental matrix
essential
matrix [R|t] triangulation SIFT
descriptor
SIFT descriptor
SIFT descriptor SIFT
descriptor
Point Match for correspondences
keypoints keypoints
match fundamental matrix
essential
matrix [R|t] triangulation SIFT
descriptor
SIFT descriptor
SIFT descriptor SIFT
descriptor
Image 1
Image 2
R
1,t
1R
2,t
2X
Fundamental Matrix
x
1x
2x 1 T Fx 2 0
x
1 x
2Estimating Fundamental Matrix
• Given a correspondence
• The basic incidence relation is
x
1TFx
2 0
x
1 x
2x
1x
2, x
1y
2, x
1, y
1x
2, y
1y
2, y
1, x
2, y
2,1
f
11f
12f
13f
21f
22f
23f
31f
32f
33
0
Need 8 points
Estimating Fundamental Matrix
x
1TFx
2 0
x
11 x
12, x
12 x
22, x
13 x
32, x
14 x
42, x
15 x
52, x
16 x
62, x
17 x
72, x
18 x
82x
11x
12x
11y
12x
11y
11x
12y
11y
12y
11x
12y
121 x
12x
22x
12y
22x
12y
12x
22y
12y
22y
12x
22y
221 x
13x
23x
13y
32x
13y
13x
32y
13y
32y
13x
32y
321 x
14x
24x
14y
24x
14y
14x
42y
14y
42y
14x
42y
421 x
15x
25x
15y
52x
15y
15x
52y
15y
52y
15x
52y
521 x
16x
62x
16y
62x
16y
16x
62y
16y
62y
16x
62y
621 x
17x
72x
17y
27x
17y
17x
72y
17y
72y
17x
72y
721 x
18x
82x
18y
82x
18y
18x
82y
18y
82y
18x
82y
821
f
11f
12f
13f
21f
22f
23f
31f
32f
33
0
for 8 point correspondences:
Direct Linear Transformation (DLT)
Ax b
Af 0
RANSAC to Estimate Fundamental Matrix
• For many times
– Pick 8 points
– Compute a solution for using these 8 points – Count number of inliers
• Pick the one with the largest number of inliers
F
Image 1
Image 2
R
1,t
1R
2,t
2X
Fundamental Matrix Essential Matrix
x
1x
2x 1 T Fx 2 0
E K 1 T FK 2
Image 1
Image 2
R
1,t
1R
2,t
2X
Essential Matrix
x
1x
2x 1 T Fx 2 0
E K 1 T FK 2
R t
Result 9.19. For a given essential matrix
and the first camera matrix , there are four possible choices for the second camera matrix :
Page 259 of the bible (Multiple View Geometry, 2ndEd)
Essential Matrix R t
E Udiag 1,1, 0 V
T,
P
1 I 0
P
2P
2 UWV
Tu
3
P
2 UWV
Tu
3
P
2 UW
TV
Tu
3
P
2 UW
TV
Tu
3
W
0 1 0
1 0 0
0 0 1
Four Possible Solutions
Page 260 of the bible (Multiple View Geometry, 2ndEd)
In front of the camera?
• Camera Extrinsic
• Camera Center
• View Direction
R t
Xcam Ycam
Zcam
R
Xworld Yworld
Zworld
t
Xworld Yworld
Zworld
R1
Xcam Ycam
Zcam
t
RT
Xcam Ycam
Zcam
RTt
Xcam Ycam
Zcam
0 0 0
C
Xworld Yworld
Zworld
RT 0 0 0
RTt RTt
0 0 1
0 0 0
RT 0 0 1
RTt
C
R(3,:)
T RTt
R
Tt
R(3,:)TCamera Coordinate System World Coordinate System
In front of the camera?
• A point
• Direction from camera center to point
• Angle Between Two Vectors
• Angle Between and View Direction
• Just need to test
X
X C
A B A B cos
X C
R(3,:)
T 0?
X C
Pick the Solution
Page 260 of the bible (Multiple View Geometry, 2ndEd)
With maximal number of points in front of both cameras.
Two‐view Reconstruction
keypoints
keypoints
match fundamental matrix
essential
matrix [R|t] triangulation
Multi‐view Stereo (MVS) Structure from Motion (SFM)
Pipeline
Taught Next
Pipeline
Merge Two Point Cloud
Merge Two Point Cloud
There can be only one R
2t
2
Merge Two Point Cloud
• From the 1 st and 2 nd images, we have and
• From the 2 nd and 3 rd images, we have and
• Exercise: How to transform the coordinate
system of the second point cloud to align with the first point cloud so that there is only one
?
R
1t
1 R
2t
2
R
2t
2
R
3t
3
R
2t
2
Merge Two Point Cloud
Oops
See From a Different Angle
Bundle Adjustment
Image 1
Image 2
Image 3
R
1,t
1R
2,t
2R
3,t
3X
1Camera projection
X
2X
3X
4X
5X
6X
7x
11x
12x
13Camera projection
x
11= K R
1t
1X
1x
12= K R
2t
2X
1x
13= K R
3t
3X
1x
12= K R
1t
1X
2x
22= K R
2t
2X
2x
23= K R
2t
2X
3x
33= K R
3t
3X
3Point 1 Point 2 Point 3
Image 1 Image 2 Image 3
Same Camera Same Setting = Same K
Rethinking the SFM problem
• Input: Observed 2D image position
• Output:
Unknown Camera Parameters (with some guess) Unknown Point 3D coordinate (with some guess)
R
1t
1 , R
2t
2, R
3t
3
x
1 1x
12x
13x
1 2x
222x
32x
33X
1, X
2, X
3,
Bundle Adjustment
A valid solution and must let
x
11x
2 1x
3 1x
12x
222
x
2 3x
3 3R
1t
1 , R
2t
2, R
3t
3 X
1, X
2, X
3,
Observation Re‐projection
x
11= K R
1t
1X
1x
12= K R
2t
2X
1x
13= K R
3t
3X
1x
12= K R
1t
1X
2x
22= K R
2t
2X
2x
23= K R
2t
2X
3x
33= K R
3t
3X
3=
Bundle Adjustment
A valid solution and must let the Re‐projection close to the
Observation, i.e. to minimize the reprojection error
R
1t
1 , R
2t
2, R
3t
3 X
1, X
2, X
3,
min x i j K R i t i X j 2
j
i
Solving This Optimization Problem
• Theory:
The Levenberg–Marquardt algorithm
• Practice:
The Ceres‐Solver from Google
http://en.wikipedia.org/wiki/Levenberg‐Marquardt_algorithm