Professional Documents
Culture Documents
Estimation – 2D Projective
Transformations
Session 06-07
Estimation – 2D Projective
Transformations
Acknowledgement
Chapter 4
Learning Objectives
• 2D homography
Given a set of (xi,xi’), compute H (xi’=Hxi)
• 3D to 2D camera projection
Given a set of (Xi,xi), compute P (xi=PXi)
• Fundamental matrix
Given a set of (xi,xi’), compute F (xi’TFxi=0)
• Trifocal tensor
Given a set of (xi,xi’,xi”), compute T
Number of measurements
required
• At least as many independent
equations as degrees of freedom
required
x h11 h12 h13 x
• Example:
λ y h21 h22 h23 y
x' Hx
1 h31 h32 h33 1
2 independent equations / point
8 degrees of freedom
4x2≥8
Approximate solutions
• Minimal solution
4 points yield an exact solution for H
• More points
– No exact solution, because measurements are inexact
(“noise”)
– Search for “best” according to some cost function
– Algebraic or geometric/statistical cost
Gold Standard algorithm
• Cost function that is optimal for some assumptions
• Computational algorithm that minimizes it is called
“Gold Standard” algorithm
• Other algorithms can then be compared to it
Direct Linear Transformation
(DLT)
h 1T x
x i Hx i T i
xi xi, yi, wi Hx i h 2 x i
T
xi Hx i 0 3T
yh 3 T x wh 2 T x h x i
i T i i i
3T
xi Hx i wih x i xih x i
1
2T 1T
xih x i yih x i
0T
wi x i
T
yi x iT
h
1
T
2
T
wi x i 0 T
xix i h 0
yix iT T T 3
xi x i 0 h
Ai h 0
Direct Linear Transformation
(DLT)
• Equations are linear in h
Ai h 0
• Only 2 out of 3 are linearly independent
(indeed, 2 eq/pt)
0T wix iT yix iT h1 h 1
T
2 0 T
wix i T
yix i 2
T
wix i xix i h 0 h 0
T T
0 T
yix iT T T 3 wix i
T
0 T
xix i 3
xi x i 0 h h
(only drop third row if wi’≠0) x A
i i
1
y A
i i
2
w
i i 0
A 3
Objective
Given n≥4 2D to 2D point correspondences {xi↔xi’}, determine
the 2D homography matrix H such that xi’=Hxi
Algorithm
(i) For each correspondence xi ↔xi’ compute Ai. Usually only two first
rows needed.
(ii) Assemble n 2x9 matrices Ai into a single 2nx9 matrix A
(iii) Obtain SVD of A. Solution for h is last column of V
(iv) Determine H from h
Inhomogeneous solution
Since h can only be computed up to scale, ~
pick hj=1, e.g. h9=1, and solve for 8-vector h
Constraints: x i Hx i 0 i=1,2,3,4
Define: H * x 4 l T
Then,
H* x i x4 l T x i 0, i 1,2,3
H*x 4 x l x kx
4
T
4 4
li H T li Ah 0
Minimum of 4 lines
2D affinities (6 dof)
Mixed configurations?
Cost functions
• Algebraic distance
• Geometric distance
• Reprojection error
• Comparison
• Geometric interpretation
• Sampson error
Algebraic distance
DLT minimizes Ah
e Ah residual vector
ei partial vector for each (xi↔xi’)
algebraic error vector
2
0 wix T
yix T T
d alg x i , Hx i ei
2 2 i i
h
wix i xix
T T T
0 i
algebraic distance
d alg x1 , x 2 a12 a22 where a a1 , a2 , a3 T x1 x 2
2
x̂ estimated coordinates
x true coordinates
H i
H i
Reprojection error
Ĥ, x̂ , x̂ argmin d x , x̂
i i
H, x̂ i , x̂ i
i i
2
d x i , x̂ i 2
i
subject to x̂ i Ĥx̂ i
Reprojection error
-1
d x, H x d x , Hx
2 2
d x, x̂ d x , x̂
2 2
Comparison of geometric
and algebraic distances
Error in one image
xi xi, yi, wi x̂i xˆi, yˆ i, wˆ i Hx
T T
h 1
yiwˆ i wi yˆ i 0T wix iT yix i 2
T
A i h ei T T
h
wixˆi xiwˆ i wix i 0T xix i 3
h
d alg x i , x̂i yiwˆ i wi yˆ i wixˆi xiwˆ i
2 2 2
2
d x i , x̂ i yi / wi yˆ i / wˆ i xˆi / wˆ i xi / wi
2
2 1/ 2
d alg x i , x̂ i / wiwˆ i
wi 1 wˆ i h 3 x,iexcept for affinities
typical, but not
xi Hx irepresents
0 2 quadrics in 4
(quadratic in X)
xi xˆi yi yˆ i xi xˆi yi yˆ i
2 2 2 2 2
X i X̂ i
d x i , x̂ i d xi , x̂i
2 2
d x i , x̂ i d x i , x̂ i d X i , H
2 2 2
d alg x , C x T Cx
2
d x, C
2
Sampson error
2
X̂
Vector that minimizes the geometric error
measurement
X X̂
is the closest point on the variety to the
CH X δ X CH X
CH
X
δX δ X X̂ X
CH X̂ 0
CH CH
CH X δX 0 Jδ X e with J
X X
Find the vector that minimizes
δX subject to
δX Jδ X e
Find the vector that minimizes
δX subject to
δX Jδ X e
minimize
δ X δ X - 2λ Jδ X e 0
T
derivatives
2δ X - 2λ T J 0 T δX J T λ
2 Jδ X e 0 JJ T λ e 0
λ JJ T e
1
δ X J JJ T
T 1
e
X̂ X δ X δX
2
δ TX δ X e T JJ T
1
e
Sampson error
between algebraic and geometric error
2
X̂
Vector that minimizes the geometric error
measurement
X X̂
is the closest point on the variety to the
Ah CH X 0
CH X δ X CH X
CH
X
δX δ X X̂ X CH X̂ 0
CH
CH X δX 0 Jδ X e
X
Find the vector that minimizes
δX subject to
δX Jδ X e
δX
2
δ δ e JJ
T
X X
T
T 1
e (Sampson error)
Sampson approximation
A few points
δX
2
e JJ
T
T 1
e
(i) For a 2D homography X=(x,y,x’,y’)
(ii) e C X is the algebraic error vector
H
(iii) CH is a 2x4 matrix, e.g.
J
X J
(iv) Similar to algebraic error
11 w
i
x i h 2 yix i h 3 / x wih21 yih31
T T
in fact,
2
same as Mahalanobis distancee eTe
(v) Sampson error independent of linear e 2 T
JJ
reparametrization (cancels out in between e and J)
(vi) Must be summed for all points
(vii) Close to geometric error, but muchefewer T 1
T unknowns
JJ e
Statistical cost function and
Maximum Likelihood Estimation
• Optimal cost function related to noise model
• Assume zero-mean isotropic Gaussian noise (assume
outliers removed)
1 d x, x 2 / 2 2
Pr x 2
e
2 πσ
Error in one image
1 xi ,Hx i 2 / 2 2
Pr xi | H 2
e d
i 2 πσ
1
log Pr x i | H d x i , Hx i constant
2
2
2σ
Maximum Likelihood Estimate
d x i , Hx i
2
Statistical cost function and
Maximum Likelihood Estimation
• Optimal cost function related to noise model
• Assume zero-mean isotropic Gaussian noise (assume
outliers removed)
Pr x
1
e
d x, x 2 / 2 2
2
2 πσ
Error in both images
1 d x i , x i 2 d xi ,Hx i 2 / 2 2
Pr x i | H 2
e
i 2 πσ
d x i , x̂ i d xi , x̂i
2 2
Mahalanobis distance
• General Gaussian case
Measurement 2X with covariance matrix Σ
X X 1 X X
T
XX
Varying covariances
X
2 2
i Xi i
Xi Xi i
i
Invariance to transforms ?
~
x Tx ~~
x Hx ~
x Hx
~
x Tx ~
Tx HTx
-1 ~
? ~ x T HTx
H T HT
-1
~~
A i h e~1 , e~2 sR e1 , e2 s A i h
T T
i
~ ~~ 2
minimize d alg xi , Hx i subject to H 1
i
~ ~~ 2 ~
minimize d alg xi , Hx i subject to H 1
i
Invariance of geometric error
X f P X f P 1 X f P
2 T
d
i ix , Hx 2
f : h Hx1 , Hx 2 ,..., Hx n
X f h
Symmetric transfer error
-1
d x i , H xi d xi , Hxi
2 2
• Powell’s method
• Simplex method
Gold Standard algorithm
Objective
Given n≥4 2D to 2D point correspondences {xi↔xi’}, determine
the Maximum Likelyhood Estimation of H
(this also implies computing optimal xi’=Hxi)
Algorithm
(i) Initialization: compute an initial estimate using normalized DLT or
RANSAC
(ii) Geometric minimization of -Either Sampson error:
● Minimize the Sampson error
● Minimize using Levenberg-Marquardt over 9 entries of h
or Gold Standard error:
● compute initial estimate for optimal {xi}
● minimize cost over {H,x 1,x2,…,xn}
● if many points, use d x i ,method
x̂ i d x i , x̂i
2 2
sparse
Robust estimation
Objective
Robust fit of model to data set S which contains outliers
Algorithm
(i) Randomly select a sample of s data points from S and instantiate the
model from this subset.
(ii) Determine the set of data points Si which are within a distance
threshold t of the model. The set Si is the consensus set of samples
and defines the inliers of S.
(iii) If the subset of Si is greater than some threshold T, re-estimate the
model using all the points in Si and terminate
(iv) If the size of Si is less than T, select a new subset and repeat the
above.
(v) After N trials the largest consensus set Si is selected, and the model is
re-estimated using all the points in the subset Si
Distance threshold
Codimension Model t2
1 l,F 3.84σ2
2 H,P 5.99σ2
3 T 7.81σ2
How many samples?
1 1 e
s N
1 p
N log 1 p / log 1 1 e
s
proportion of outliers e
s 5% 10% 20% 25% 30% 40% 50%
2 2 3 5 6 7 11 17
3 3 4 7 9 11 19 35
4 3 5 9 13 17 34 72
5 4 6 12 17 26 57 146
6 4 7 16 24 37 97 293
7 4 8 20 33 54 163 588
8 5 9 26 44 78 272 1177
Acceptable consensus set?
• Typically, terminate when inlier ratio reaches expected
T 1 e n
ratio of inliers
Adaptively determining
the number of samples
– N=∞, sample_count =0
– While N >sample_count repeat
• Choose a sample and count the number of inliers
• Set e=1-(number of inliers)/(total number of points)
• Recompute N from e
N log1 p / log 1 1 e s
• Increment the sample_count by 1
– Terminate
Robust Maximum Likelyhood
Estimation
Previous MLE algorithm considers fixed set of inliers
Outliers (117)
Inliers (151)