Lec3 StereoGeometry
Lec3 StereoGeometry
Epipolar geometry
Prof. H. Sahli
VUB-ETRO
2022-2023
1
CV
Why multiple views?
Structure and depth are inherently ambiguous from single views.
=> Many-to-one: any points along same ray map to same point in
image
Optical center
p’1=p’2
P2
P1
2
CV
Epipolar geometry
3
CV
Epipolar geometry
4
CV
Epipolar constraint
5
CV
Epipolar constraint
6
CV
Stereo geometry, with calibrated cameras
X X`
(1)
X' = RX + T T × X′ = T × RX + T × T
Normal to the plane
(2)
T × X′ = T× RX
CV
X′ ⋅ (T × X′) = X′ ⋅ (T × RX ) = 0 8
Essential matrix
(2) X′ ⋅ (T × RX ) = 0
X′ ⋅ ([Tx ]RX ) = 0
Let E = [T x ]R
′
X EX = 0
T
𝐗𝐗 ′𝑇𝑇 𝐄𝐄𝐄𝐄 = 0
these points are in camera coordinate systems => relates viewing rays
𝑓𝑓 𝑓𝑓
x= X x′ = X’
𝑍𝑍 𝑍𝑍′
𝑍𝑍 ′ ′ 𝑇𝑇 𝑍𝑍
( 𝑥𝑥 ) 𝐄𝐄( 𝑥𝑥) = 0
𝑓𝑓 𝑓𝑓
′𝑇𝑇
𝑥𝑥 𝐄𝐄𝑥𝑥 = 0
This relates 2D image points
10
Stereo system - Parameters
− Intrinsic parameters
− Characterize the transformation from image plane coordinates to
pixel coordinates in each camera
− Parameters intrinsic to each camera
− Extrinsic parameters (R, T)
− Describe the relative position and orientation of the two cameras
X' = RX + T
11
CV
Epipolar Lines
𝑙𝑙 = 𝑎𝑎𝑎𝑎 + 𝑏𝑏𝑏𝑏 + 𝑐𝑐 = 0
− Using homogenous coordinates:
x
p = y l′ = Ep T
p=
l l=T
p 0
1
- Re-wrire (change notation)
′𝑇𝑇 ′𝑇𝑇
𝒙𝒙 𝐄𝐄𝒙𝒙 = 0 𝒑𝒑 𝐄𝐄𝒑𝒑 = 0
12
CV
Epipolar Lines
′𝑇𝑇
𝑝𝑝 𝐄𝐄𝑝𝑝 = 0
a
l′T = b P’ belongs to the epipolar line in the right image defined by l′ = Ep
c
𝑝𝑝′𝑇𝑇 𝐄𝐄𝑝𝑝 = 0
a
l T = b p belongs to the epipolar line in the left image defined by l = E T p′
c
13
CV
Epipoles
Epipoles belong to the epipolar lines
′𝑇𝑇 ′𝑇𝑇
𝑒𝑒 𝐄𝐄𝑝𝑝 = 0 𝑝𝑝 𝐄𝐄𝑒𝑒 = 0
And they belong to all the epipolar lines
𝑒𝑒 ′𝑇𝑇 𝐄𝐄 = 0 𝐄𝐄𝑒𝑒 = 0
14
CV
Essential Matrix vs Homography
15
CV
Summary epipolar geometry
− Longuet-Higgins equation
′𝑇𝑇
𝑝𝑝 𝐸𝐸𝑝𝑝 = 0
− Epipolar lines:
l′ = Ep l = E T p′
p′T l′ = 0 p T l = 0
− Epipolees:
′𝑇𝑇 𝐸𝐸𝑒𝑒 = 0
𝑒𝑒 𝐸𝐸 = 0
16
CV
Fundamental matrix F
• When Cameras are not calibrated, we talk about
Fundamental Matrix
Image
correspondences
m0 = K l p 𝑝𝑝
m1 = K r p′
𝑝𝑝’
𝑓𝑓𝑥𝑥 𝑠𝑠 𝑐𝑐𝑥𝑥 1 0 0 0
𝐾𝐾 = 0 𝑓𝑓𝑦𝑦 𝑐𝑐𝑦𝑦 0 1 0 0
0 0 1 0 0 1 0
17
CV
Fundamental matrix F
m0 = K l p m1 = K r p′
𝑝𝑝′𝑇𝑇 𝐸𝐸𝑝𝑝 = 0
(K r−1m1 )T E (K l−1m0 ) = 0
18
CV
Fundamental matrix F
• When Cameras are not calibrated, we talk about
Fundamental Matrix
• Essential matrix: particular form of fundamental
matrix when calibration is available
Image
correspondences
19
CV
Properties of the Fundamental Matrix
• Epipolar lines
• Epipoles
Image
correspondences
CV
20
How to Derive F?
T
m1 Fm 0 = 0
x' xf11 + x' yf12 + x' f13 + y ' xf 21 + y ' yf 22 + y ' f 23 + xf 31 + yf 32 + f 33 = 0
separate known from unknown
[x' x, x' y, x' , y' x, y' y, y' , x, y,1][ f11 , f12 , f13 , f 21 , f 22 , f 23 , f 31 , f 32 , f 33 ]T = 0
(data) (unknowns)
x’1
x1
RANSAC
Step 3.1 select minimal sample (i.e. 7 matches)
Step 3.2 compute solution(s) for F
} (generate
hypothesis)
Step 3.3 determine inliers (verify hypothesis)
until Γ(#inliers,#samples)<95%
22
CV
Stereo – How we reconstruct 3D points
Assume
parallel optical axes,
known camera parameters (calibrated cameras):
T + xl − xr T
=
Z− f Z
T
Z= f
xr − xl
disparity
(wrt to camera origin of image plane) 24
CV
Essential matrix example: parallel cameras
R=I xl = [ x, y, f ]
T = [−d ,0,0]Τ xr = [ x ' , y ' , f ]
0 0 0
E = [T x]R = 0 0 d
0 –d 0
Τ
xr Exl = 0
(xr,yr)=(xl+D(x,y), yl)
x x'
27
Triangulation
28
CV
General Triangulation
29
CV
Stereo image rectification
In practice, it is
convenient if image
scanlines (rows) are the
epipolar lines.
For this rotation around the camera center, the 3D structure must not be
known
EpipolarPlane
Epipolar Plane
Principal Axis
Recti fi ed
Camera 1
Epipolar Plane
Camera 1 Camera 2
Rectification Algorithm:
� , decompose into 𝒕𝒕 and 𝑹𝑹, and construct 𝑹𝑹𝒓𝒓𝒓𝒓𝒓𝒓𝒓𝒓 as above
1. Estimate 𝑬𝑬
2. Warp pixels in the first image as follows: 𝑥𝑥�1′ = 𝑲𝑲𝑹𝑹𝒓𝒓𝒓𝒓𝒓𝒓𝒓𝒓 𝑲𝑲−𝟏𝟏 ′
𝟏𝟏 𝑥𝑥̅1
3. Warp pixels in the second image as follows: 𝑥𝑥�2′ = 𝑲𝑲𝑹𝑹𝑹𝑹𝒓𝒓𝒓𝒓𝒓𝒓𝒓𝒓 𝑲𝑲−𝟏𝟏 ′
𝟐𝟐 𝑥𝑥̅ 2
With 𝑲𝑲 a shared projection matrix that can be chosen arbitrarily (e.g 𝑲𝑲= 𝑲𝑲𝟐𝟐 )
In practice, the inverse transformation is used for warping
33
CV
Stereo image rectification: example
34
CV Source: Alyosha Efros
The Correspondence Problem
• Methods for establishing correspondences
− Two issues
− How to select candidate matches?
− How to determine the goodness of a match?
− Two main classes of correspondence (matching) algorithm:
− Correlation-based
− Attempt to establish a correspondence by matching image
intensities – usually over a window of pixels in each image
⇒Dense disparity maps
− Feature-based
− Attempt to establish a correspondence by matching a sparse
sets of image features – usually edges
− Disparity map is sparse
− Number of points is related to the number of image
features identified
38
CV
Correlation-Based Methods
• Match image sub-windows in the two images using image
correlation
− oldest technique for finding correspondence between image pixels
• Scene points must have the same intensity in each image
−
Assumes
a) All objects are perfect Lambertian scatterers
ie the reflected intensity is not dependent on angle or
objects scatter light uniformly in all directions
• Informally: matte surfaces only
b) Fronto-planar surfaces
− (Visible) surfaces of all objects are perpendicular
to camera optical axes
39
CV
Matching Windows:
?
=
f g
Sum of Squared
Minimize Differences
Cross correlation
Maximize
For each window, match to closest window on epipolar line in other image.
CV 40
Matching Windows:
Minimize Sum of Squared
Differences
Maximize
Cross correlation
CV 41
Solving for correspondences
Matching through correlation:
42
CV
Correlation-Based Methods
43
CV
Correlation-Based Methods
• Improvements
− Do not use image intensity values,
use intensity gradients instead!
− One scheme calculates thresholded signed gradient magnitudes at
each pixel
− Compute the gradient magnitude at each pixel in the two images
without smoothing
− Map the gradient magnitude values into three values: -1, 0, 1
(by thresholding the gradient magnitude)
− More sensitive correlations are produced this way
+ several dozen more
44
CV
Feature-Based Methods
45
CV
Correlation vs. feature-based approaches
• Correlation methods
− Easier to implement
− Provide a dense disparity map (useful for reconstructing surfaces)
− Need textured images to work well (many false matches otherwise)
− Do not work well when viewpoints are very different, due to
− change in illumination direction
− Objects are not perfect (Lambertian) scatterers
− foreshortening
− perspective problem – surfaces are not fronto-planar
• Feature-based methods
− Suitable when good features can be extracted from the scene
− Faster than correlation-based methods
− Provide sparse disparity maps
− OK for applications like visual navigation
− Relatively insensitive to illumination changes
46
CV
How can we improve window-based matching?
• The similarity constraint is local (each reference
window is matched independently)
• Need to enforce non-local correspondence
constraints
47
CV
Non-local constraints
• Uniqueness
• For any point in one image, there should be at most one
matching point in the other image
48
CV
Non-local constraints
• 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
49
CV
Non-local constraints
• 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
51
CV
Stereo matching as energy minimization
I1 I2 D
E = α Edata ( I1 , I 2 , D) + β Esmooth ( D)
55
CV
Summary
Essential Matrix Longuet-Higgins equation
E = [T x ]R 𝑝𝑝′𝑇𝑇 𝐸𝐸𝑝𝑝 = 0
Epipoles belong to the epipolar lines
′𝑇𝑇
𝑒𝑒 𝐄𝐄𝑝𝑝 = 0 𝑝𝑝′𝑇𝑇 𝐄𝐄𝑒𝑒 = 0
And they belong to all the epipolar lines
𝑒𝑒 ′𝑇𝑇 𝐄𝐄 = 0 𝐄𝐄𝑒𝑒 = 0
Fundamental Matrix
F = K r−1T R [Tx ]K l−1
• has rank 2
• depends on the INTRINSIC and EXTRINSIC Parameters
• Analogous to essential matrix. The fundamental matrix also tells how pixels in
each image are related to epipolar lines in the other image.
56
CV