Computer Vision I -
Robust Geometry Estimation from two Cameras
Carsten Rother
Computer Vision I: Image Formation Process 16/01/2015
FYI
16/01/2015
Computer Vision I: Image Formation Process 2
β’ Microsoft Research Cambridge
β’ excellent 8 week paid summer internship
β’ Deadline: 16
thJanuary 2015
β’ If interested, please contact me
β’ The last lecture on 6.2.2015 will mainly be a Q&A session.
Please look through all lectures again and prepare questions!
Roadmap for next five lecture
β’ Appearance based matching (sec. 4.1)
β’ How do we get an RGB image? (sec 2.2-2.3)
β’ The Human eye
β’ The Camera and Image formation model
β’ Projective Geometry - Basics (sec. 2.1.1-2.1.4)
β’ Geometry of a single camera (sec 2.1.5, 2.1.6)
β’ Pinhole camera
β’ Lens effects
β’ Geometry of two cameras (sec. 7.2)
β’ Robust Geometry estimation for two cameras (sec. 6.1.4)
β’ Multi-View 3D reconstruction (sec. 7.3-7.4)
16/01/2015 3 Computer Vision I: Image Formation Process
Camera parameters - Summary
β’ Camera matrix P has 11 DoF:
β’ Intrinsic parameters
β’ Focal length π
β’ Pixel y-direction magnification factors π
β’ Skew (non-rectangular pixels) π
β’ Principal point coordinates (ππ₯, ππ¦)
β’ Extrinsic parameters
β’ Rotation πΉ (3DoF) and translation π (3DoF) relative to world coordinate system
16/01/2015
Computer Vision I: Image Formation Process 4
π = π² πΉ (π°πΓπ | β πͺ) πΏ~
~
π² =
π π ππ₯ 0 ππ ππ¦
0 0 1
π = π· πΏ Image
3D world point
π
Reminder: The upcoming tasks
β’
Two-view transformations we look at:
β’ Homography π»: between two views
β’ Camera matrix π
(mapping from 3D to 2D)
β’ Fundamental matrix πΉ
between two un-calibrated views
β’ Essential matrix πΈ
between two calibrated views
β’ Derive geometrically: π», π, πΉ, πΈ, i.e. what do they mean?
β’ Calibration: Take primitives (points, lines, planes, cones,β¦)
to compute π», π, πΉ, πΈ :
β’
What is the minimal number of points to compute them (very important for next lecture on robust methods)
β’
If we have many points with noise: what is the best way to computer them: algebraic error versus geometric error?
β’
Can we derive the intrinsic (πΎ) an extrinsic (π , πΆ
) parameters from π», π, πΉ, πΈ?
β’ What can we do with π», π, πΉ, πΈ? (e.g. Panoramic Stitching)
16/01/2015
Computer Vision I: Two-View Geometry 5
Homography π» : Summary
β’
Derive geometrically π»
β’
Calibration: Take measurements (points) to compute π»
β’
Minimum of 4 points. Solution: right null space of π΄β = 0
β’
Many points. Use SVD to solve π
β = ππππππβ π΄πβ’
Can we derive the intrinsic (πΎ) an extrinsic (π , πΆ ) parameters from π»?
-> hard. Not discussed much
β’
What can we do with π» ?
-> augmented reality on planes, panoramic stitching
16/01/2015
Computer Vision I: Two-View Geometry 6
Camera Matrix π : Summary
β’
Derive geometrically π
β’
Calibration: Take measurements (points) to compute π
β’
6 or more points. Use SVD to solve π
β = ππππππβ π΄πβ’
Can we derive the intrinsic (πΎ) an extrinsic (π , πΆ ) parameters from π»?
-> yes, use SVD and RQ decomposition
β’
What can we do with π ?
-> very many things (robotic, photogrammetry, augmented reality, β¦)
16/01/2015
Computer Vision I: Two-View Geometry 7
π = π² πΉ (π°πΓπ | β πͺ) πΏ~ π = π· πΏ
Topic 3: Fundamental/Essential Matrix πΉ/πΈ
β’
Derive geometrically πΉ/πΈ
β’
Calibration: Take measurements (points) to compute
πΉ/πΈβ’
How do we do that with a minimal number of points?
β’
How do we do that with many points?
β’
Can we derive the intrinsic (πΎ) an extrinsic (π , πΆ ) parameters from πΉ/πΈ ?
β’
What can we do with πΉ/πΈ?
16/01/2015
Computer Vision I: Two-View Geometry 8
Reminder: Matching two Images
16/01/2015
Computer Vision I: Image Formation Process 9
v
β’ Find interest points
β’ Find orientated patches around interest points to capture appearance
β’ Encode patch appearance in a descriptor
β’ Find matching patches according to appearance (similar descriptors)
β’ Verify matching patches according to geometry (later lecture)
We will discover in next slides:
Seven 3D points define how other 3D points match between 2 views!
Reminder: 3D Geometry
16/01/2015
Computer Vision I: Two-View Geometry 10
Non-moving scene
πβ
Rigidly (6D) moving scene
Both cases are equivalent for the following derivations
Reminder: Epipolar Geometry
16/01/2015
Computer Vision I: Two-View Geometry 11
β’ Epipole: Image location of the optical center of the other camera.
(Can be outside of the visible area)
Reminder: Epipolar Geometry
16/01/2015
Computer Vision I: Two-View Geometry 12
Epipolar plane: Plane through both camera centers and world point.
Reminder: Epipolar Geometry
16/01/2015
Computer Vision I: Two-View Geometry 13
β’ Epipolar line: Constrains the location where a particular point (here π1) from one view can be found in the other.
Reminder: Epipolar Geometry
16/01/2015
Computer Vision I: Two-View Geometry 14
β’ Epipolar lines:
β’ Intersect at the epipoles
β’ In general not parallel
Reminder: Example: Converging Cameras
16/01/2015
Computer Vision I: Two-View Geometry 15
Reminder: Example: Motion Parallel to Camera
16/01/2015
Computer Vision I: Two-View Geometry 16
β’ We will use this idea when it comes to stereo matching
Reminder: Example: Forward Motion
16/01/2015
Computer Vision I: Two-View Geometry 17
β’ Epipoles have same coordinate in both images
β’ Points move along lines radiating from epipole
βfocus of expansionβ
The maths behind it: Fundamental/Essential Matrix
derivation on black board
16/01/2015
Computer Vision I: Robst Two-View Geometry 18
π
(π , π)
~
~
Camera 0 Camera 1
The maths behind it: Fundamental/Essential Matrix
16/01/2015
Computer Vision I: Two-View Geometry 19
The 3 vectors are in same plane (co-planar):
1) π = πΆ1 β πΆ0 2) π β πΆ0
3) π β πΆ1
Set camera matrix: π₯0 = πΎ0 πΌ 0 π and π₯1 = πΎ1π β1 πΌ βπΆ1 π The three vectors can be re-writting using π₯0,1, πΎ:
1) T
2) πΎ0β1π₯0
3) π πΎ1β1π₯1 + πΆ1 β πΆ1 = π πΎ1β1π₯1
We know that:
πΎ0β1π₯0 π π Γ π (πΎ1β1π₯1) = 0 which gives: π₯0ππΎ0βπ π Γ π (πΎ1β1π₯1) = 0
~ ~ ~
~ ~
~ ~
~
~
~ ~
~ ~
π~
The maths behind it: Fundamental/Essential Matrix
β’ In an un-calibrated setting (πΎβπ not known):
π₯
0ππΎ
0βππ
Γπ (πΎ
1β1π₯
1) = 0
β’ In short: π₯
0ππΉπ₯
1= 0 where F is called the Fundamental Matrix
(discovered by Faugeras and Luong 1992, Hartley 1992)
β’ In an calibrated setting (πΎβs are known):
we use rays: π₯
π= πΎ
πβ1π₯
πthen we get: π₯
0ππ
Γπ π₯
1= 0
In short: π₯
0ππΈπ₯
1= 0 where E is called the Essential Matrix
(discovered by Longuet-Higgins 1981)
16/01/2015
Computer Vision I: Two-View Geometry 20
~
~
Fundamental Matrix: Properties
β’ We have π₯
0ππΉπ₯
1= 0 where F is called the Fundamental Matrix
β’ It is det πΉ = 0. Hence F has 7 DoF Proof: πΉ = πΎ
0βππ
Γπ πΎ
1β1πΉ has Rank 2 since π
Γhas Rank 2
16/01/2015
Computer Vision I: Two-View Geometry 21
~
Check: det( π₯ Γ) = π₯3 π₯30 β π₯1π₯2 + π₯2 π₯1π₯3 + π₯20 = 0
π Γ =
0 βπ₯3 π₯2 π₯3 0 βπ₯1
βπ₯2 π₯1 0
~
Fundamental Matrix: Properties
β’ For any two matching points (i.e. they have the same 3D point) we have: π₯
0ππΉπ₯
1= 0
β’ Compute epipolar line in camera 1 of a point π₯
0: π
1π= π₯
0ππΉ (since π
1ππ₯
1= π₯
0ππΉπ₯
1= 0)
β’ Compute epipolar line in camera 0 of a point π₯
1: π
0= πΉπ₯
1(since π₯
0ππ
0= π₯
0ππΉπ₯
1= 0)
16/01/2015
Computer Vision I: Two-View Geometry 22
Camera 0
Camera 1
π
(π , π)~
~
Fundamental Matrix: Properties
16/01/2015
Computer Vision I: Robust Two-View Geometry 23 Camera 0
Camera 1
β’ For any two matching points (i.e. have the same 3D point) we have: π₯
0ππΉπ₯
1= 0
β’ Epipole π
0is the left nullspace of πΉ (can be computed with SVD) It is: π
0ππΉπ₯
π= 0 for all points π₯
π (since all lines π0 = πΉπ₯π go through π0π)This means: π
0ππΉ = 0
β’ Epipole π
1is right null space of πΉ (πΉπ
1= 0)
How can we compute πΉ (2-view calibration) ?
16/01/2015
Computer Vision I: Two-View Geometry 24
β’ Each pair of matching points gives one linear constraint π₯ππΉπ₯β² = 0 in πΉ. For π₯, π₯β² we get:
β’ Given π β₯ 8 matching points (π₯β², π₯) we can compute the πΉ in a simple way.
π11 π12 π13 π21 π22 π23 π31 π32 π33
= 0
π₯1π₯1β² π₯1π₯2β² π₯1π₯3β² π₯2π₯1β² π₯2π₯2β² π₯2π₯3β² π₯3π₯1β² π₯3π₯2β² π₯3π₯3β² .
. .
How can we compute πΉ (2-view calibration) ?
Method (normalized 8-point algorithm):
1) Take π β₯ 8 points
2) Compute π, and condition points: π₯ = ππ₯; π₯β = πβπ₯β
3) Assemble π΄ with π΄π = 0, here π΄ is of size π Γ 9, and π vectorized πΉ 4) Compute πβ = πππππππ π΄π subject to π = 1.
Use SVD to do this.
5) Get πΉ of unconditioned points: πππΉπβ² (note: (ππ₯)ππΉ πβ²π₯β² = 0)
4) Make ππππ πΉ = 2
16/01/2015
Computer Vision I: Two-View Geometry 25
[See HZ page 282]
How to make πΉ Rank 2
β’ (Again) use SVD:
16/01/2015
Computer Vision I: Two-View Geometry 26
Set last singular value ππβ1 to 0 then π΄ has Rank π β 1 and not π (assuming π΄ has originally full Rank)
Proof: diagonal matrix has Rank π β 1 hence π΄ has Rank π β 1
Can we compute πΉ with just 7 points?
16/01/2015
Computer Vision I: Robust Two-View Geometry 27
Method (7-point algorithm):
1) Take π = 7 points
2) Assemble π΄ with π΄π = 0, here π΄ is of size 7 Γ 9, and π vectorized πΉ 3) Compute 2D right null space: πΉ1 and πΉ2 from last two rows in ππ
(use the SVD decomposition: π΄ = ππ·ππ)
4) Choose: πΉ = πΌπΉ1 + 1 β πΌ πΉ2 (see comments next slide)
5) Determine πΌβ²π (either 1 or 3 solutions for πΌ) (see comments next slide) by using the constraint: det(πΌπΉ1 + 1 β πΌ πΉ2) = 0.
(This is a cubic polynomial equation for πΌ which has one or three real-value solutions for πΌ)
β’ Note an 8th point would determine which of these 3 solutions is the correct one.
β’ We will see later that the 7-point algorithm is the best choice for the robust case.
Comments to previous slide
Step 4) Choose: πΉ = πΌπΉ1 + 1 β πΌ πΉ2
β’ The full null-space is given by: πΉ = πΌπΉ1 + π½πΉ2
β’ We are free to say that we want: πΌπΉ1 + π½πΉ2 β₯ 1
(here πΉ1, πΉ2 are in vectorised form. Note that this is the same as having πΉ1, πΉ2 in matrix form and using the Frobenius norm for matrices)
β’ It is: πΌ πΉ1 + π½ πΉ2 = πΌπΉ1 + π½πΉ2 β₯ πΌπΉ1 + π½πΉ2 (triangulation inequality)
β’ Hence we want: πΌ πΉ1 + π½ πΉ2 β₯ 1
β’ Hence we want: πΌ + π½ β₯ 1 (since πΉ1, πΉ2 are rows in ππ)
β’ Hence we can choose: π½ = 1 β πΌ
16/01/2015
Computer Vision I: Image Formation Process 28
Comments to previous slide
Step 5) Compute det(πΌπΉ1 + 1 β πΌ πΉ2) = 0.
16/01/2015
Computer Vision I: Image Formation Process 29
Can we get πΎβπ , π , π from πΉ ?
β’
Assume we have
πΉ = π₯0ππΎ0βπ π Γ π πΎ1β1can we get out πΎ
1, π , πΎ0, π?
β’ πΉ
has 7 DoF
β’ πΎ1, π , πΎ0, π
have together 16 DoF
β’
Not directly possible. Only with assumptions such as:
β’
External constraints
β’
Camera does not change over several frames
β’
This is an important topic (more than 10 years of research!) called
auto-calibration or self-calibration. We look at it in detail in next lecture.
16/01/2015
Computer Vision I: Robust Two-View Geometry 30
~
~
~
Coming back to Essential Matrix
β’ In a calibrated setting ( πΎ βs are known):
we use rays: π₯
π= πΎ
πβ1π₯
πthen we get: π₯
0ππ
Γπ π₯
1= 0
In short: π₯
0ππΈπ₯
1= 0 where E is called the Essential Matrix
β’ πΈ has 5 DoF , since π has 3DoF, π 3DoF (note overall scale of π is unknown)
β’ πΈ has also Rank 2
16/01/2015
Computer Vision I: Robust Two-View Geometry 31
~
~
π
(π , π)~
~
~
How to compute πΈ
β’ We have: π₯
0ππΈπ₯
1= 0 (reminder: π₯
0ππΉπ₯
1= 0)
β’ Given π β₯ 8 matching run 8-point algorithm (as for πΉ)
β’ Given π = 7 run 7-point algorithm and get 1 or 3 solutions
β’ Given π = 5 run 5-point algorithm to get up to 10 solutions.
This is the minimal case since πΈ has 5 DoF.
β’ 5-point algorithm history:
β’ Kruppa, βZur Ermittlung eines Objektes aus zwei Perspektiven mit innere
Orientierung,β Sitz.-Ber. Akad. Wiss., Wien, Math.-Naturw. Kl., Abt. IIa, (122):1939- 1948, 1913.
found 11 solutions
β’ M. Demazure, βSur deux problemes de reconstruction,β Technical Report Rep. 882, INRIA, Les Chesnay, France, 1988
showed that only 10 valid solutions exist
β’ D. Nister, βAn Efficient Solution to the Five-Point Relative Pose Problem,β IEEE Conference on Computer Vision and Pattern Recognition, Volume 2, pp. 195-202, 2003
fast method which gives out 10 solutions of a 10 degree polynomial
16/01/2015
Computer Vision I: Robust Two-View Geometry 32
Can we get π , π from πΈ ?
β’
Assume we have
πΈ = π Γ π ,can we get out π , π ?
β’
E has 5 DoF
β’ π , π
have together 6 DoF
β’
We can get
πup to scale, and a unique
π16/01/2015
Computer Vision I: Robust Two-View Geometry 33
~
~
~
~
~
π
(π , π)~
~
How to get a unique π, π ?
1) Compute π
Note: πΈ has rank 2, and π is in the left nullspace of πΈ since This means that an SVD of πΈ must look like:
2) Compute 4 possible solutions for π
3) Derive the unique solution for π and sign for π:
1) dππ‘(π ) = 1
2) Reconstruct a 3D point and choose the solution where it lies in front of the two cameras. (In robust case: Take solution where most (β₯ 5) points lie in front of the cameras)
16/01/2015
Computer Vision I: Image Formation Process 34
~
~
~ ~ ~
πΈ = ππ·ππ = π0 π1 π
1 0 0 0 1 0 0 0 0
π0π π1π π2π
~
This fixes the norm of π~ to 1, but correct sign (+/βπ)~ is done in step 3
π 1,2 =+/βππ 90π πππ; π 3,4 =+/βππ β90π πππ (see derivation HZ page 259; Szeliski page 310)
where πΈ = ππ·ππ, π 90 =
0 β1 0
1 0 0
0 0 0
, π β90 =
0 1 0
β1 0 0
0 0 0
~
ππ‘ π Γ= (0,0,0)
Visualization of the 4 solutions for π , π
16/01/2015
Computer Vision I: Robust Two-View Geometry 35
The property that points must lie in front of the camera is known as Chirality (Hartley 1998) This is the correct solution, since
point is in front of cameras!
π~ βπ~
π~ βπ~
~
What can we do with πΉ, πΈ ?
β’ πΉ/πΈ encode the geometry of 2 cameras
β’ Can be used to find matching points (dense or sparse) between two views
β’ πΉ/πΈ encodes the essential information to do 3D reconstruction
16/01/2015
Computer Vision I: Robust Two-View Geometry 36
Fundamental and Essential Matrix: Summary
β’
Derive geometrically πΉ, πΈ βΆ
β’ πΉ
for un-calibrated cameras
β’ πΈ
for calibrated cameras
β’
Calibration: Take measurements (points) to compute πΉ, πΈ
β’ πΉ
minimum of 7 points -> 1 or 3 real solutions.
β’ πΉ
many points -> least square solution with SVD
β’ πΈ
minimum of 5 points -> 10 solutions
β’ πΈ
many points -> least square solution with SVD
β’
Can we derive the intrinsic (πΎ) an extrinsic (π , π) parameters from πΉ, πΈ?
-> πΉ next lecture
-> πΈ yes can be done (translation up to scale)
β’
What can we do with πΉ, πΈ ?
-> essential tool for 3D reconstruction
16/01/2015
Computer Vision I: Robust Two-View Geometry 37
Half-way slide
3 Minutes break
16/01/2015 Computer Vision I: Multi-View 3D
reconstruction 38
In last lecture we asked (for rotating camera)β¦
16/01/2015
Computer Vision I: Robust Two-View Geometry 39
Question 1: If a match is completely wrong then is a bad idea
Question 2: If a match is slightly wrong then might not be perfect.
Better might be a geometric error:
ππππππβ π΄π ππππππβ π΄π
ππππππβ π―π₯ β π₯β²
Robust model fitting
RANSAC:
Random Sample Consensus: A Paradigm for Model Fitting with Applications to Image Analysis and
Automated Cartography
Martin A. Fischler and Robert C. Bolles (June 1981).
16/01/2015
Computer Vision I: Robust Two-View Geometry 40
[Side credits: Dimitri Schlesinger]
Example Tasks
16/01/2015
Computer Vision I: Robust Two-View Geometry 41
Search for a straight line in a clutter of points
i.e. search for parameters and for the model given a training set
π₯ π¦
Example Tasks
16/01/2015
Computer Vision I: Robust Two-View Geometry 42
Estimate the fundamental matrix
i.e. parameters satisfying
given a training set of correspondent pairs
For Homography of rotating camera we have: π₯πππ» = π₯ππ
Two sources of errors
16/01/2015
Computer Vision I: Robust Two-View Geometry 43
1. Noise: the coordinates deviate from the true ones according to some βruleβ (probability) β the father away the less confident
2. Outliers: the data have nothing in common with the model to be estimated
Ignoring outliers can lead to a wrong
estimation.
β The way out β find outliers explicitly,
estimate the model from inliers only
Task formulation
16/01/2015
Computer Vision I: Robust Two-View Geometry 44
Let be the input space and be the parameter space.
The training data consist of data points
Let an evaluation function be given that checks the consistency of a point with a model .
β’ Straight line
β’ Fundamental matrix
The task is to find the parameter that is consistent with the majority of the data points: π¦β = πππππππ¦ ππ(π₯π, π¦)
π π₯1, π₯2, π, π = 0 ππ ππ₯1 + ππ₯2 β 1 β€ π‘ (π. π. 0.1)
1 ππ‘βπππ€ππ π
π π₯π, π₯π, πΉ = 0 ππ π₯ππ‘πΉπ₯π β€ π‘ (π. π. 0.1)
1 ππ‘βπππ€ππ π
Inlier Outlier
π₯1 π₯2
First Idea: 2D Line estimation
16/01/2015
Computer Vision I: Robust Two-View Geometry 45
A naΓ―ve approach: enumerate all parameter values
β know as Hough Transform (very time consuming and not
possible at all for many free parameters (i.e. high dimensional parameter space)
π¦β = πππππππ¦
π
π(π₯π, π¦)
Question: How to compute:
Image with points
Encode all line with two parameters (π, Ξ)
π₯ π¦
π Ξ
Image with just 3 points
Goal: Find βpointβ in the figure where most lines meet Hough transform
All lines that go through these 3 points
First Idea: 2D Line estimation
β’ Observation: The parameter space have very low counts
β’ Idea: do not try all values but only some of them. Which ones?
16/01/2015
Computer Vision I: Robust Two-View Geometry 46
Accumulator space number of inliers (sketched)
0 1 0 0 2 1 0 0
2 0 3 0 0 1 0 0
2 3 1 0 2 0 0 1
3 3 3 4 4 1 3 0
3 3 4 3 1 0 1 0
9 10 9 3 1 3 1 0
20 25 4 2 3 0 0
50 35 5 10 5 2 4 4
Ξ π
200
Hough transform
Data-driven Oracle
16/01/2015
Computer Vision I: Robust Two-View Geometry 47
An Oracle is a function that predicts a parameter given the minimum amount of data points (π-tuple):
Examples:
β’ Line can be estimated from π = 2 points
β’ Fundamental matrix from π = 7 or 8 points correspondences
β’ Homography can be computed from π = 4 points correspondences
First Idea: Do not enumerate all parameter values but all π-tuples of data points That is then ππ number of tests, e.g. π2 for lines (with π points)
The optimization is performed over a discrete domain.
π¦β = πππππππ¦
π
π(π₯π, π¦)
Second Idea: Do not try all subsets, but sample them randomly
RANSAC
16/01/2015
Computer Vision I: Robust Two-View Geometry 48
Basic RANSAC method:
β’
Sometimes we get a discrete set of intermediate solutions π¦. For example for πΉ -matrix computation from 7 points we have up to 3 solutions. The we simply evaluate πβ² π¦ for all solutions.
β’
How many times do you have to sample in order to reliable estimate the true model?
Can be done in parallel!
Repeat many times
select d-tuple, e.g. (π₯
1, π₯
2) for lines
compute parameter(s) π¦, e.g. line π¦ = π π₯
1, π₯
2evaluate πβ² π¦ =
ππ(π₯
π, π¦)
If πβ² π¦ β€ πβ² π¦
βset π¦
β= π¦ and keep value πβ² π¦
β[Random Sample Consensus, Fischler and Bolles 1981]
Convergence
16/01/2015
Computer Vision I: Robust Two-View Geometry 49
Observation: it is necessary to sample any -tuple of inliers just once in order to estimate the model correctly.
Let π be the probability of outliers.
The probability to sample π inliers is 1 β π
π(here 0.8
2= 0.64) The probability of a βwrongβ π-tuple is (here 0.36) The probability to sample π times only wrong tuples is
(here 0.36
20= 0.0000000013)
The probability to sample the βrightβ tuple at least once during the process (i.e. to estimate the correct model according to assumptions)
π ~ 0.2 200
1000 points overall
(here 99.999999866 %)
800
Convergence
16/01/2015
Computer Vision I: Robust Two-View Geometry 50
π
ππππ ππππ‘π¦
π
(outliers)
Comment
β’ In our derivation for π = we were slightly optimistic since
βdegenerateβ inliers may give rise to bad lines
16/01/2015
Computer Vision I: Image Formation Process 51 ++
β’ However, these bad lines have little support wrt number of inliers
β’ We also define later a refinement procedure which can correct such bad lines
The choice of the oracle is crucial
16/01/2015
Computer Vision I: Robust Two-View Geometry 52
Example β the fundamental matrix:
a) 8-point algorithm
Probability: 70% (π = 300; π = 0.5; π = 8) b) 7-point algorithm
Probability: 90% (π = 300; π = 0.5; π = 7) Number of trials to get p% accuracy (here 99%)
π = log 1 β π
log(1 β 1 β π π) π = 1 β 1 β 1 β π π π
π π
The choice of evaluation function is crucial
β’ Algebraic error: Is a measure that has no geometric meaning Example:
16/01/2015
Computer Vision I: Image Formation Process 53
For a line: π π₯1, π₯2, π, π = ππ₯1 + ππ₯2 β 1 For a homograpy: π π₯1, π₯2, π, π = |π¨π|
(where π¨ is 1 Γ 8 matrix derived as above For πΉ-matrix: π π₯π, π₯π, πΉ = π₯ππ‘πΉπ₯π
β’ Geometric error: Is a measure that considers a distance in image plane Example: For a line: π π₯1, π₯2, π, π = π( π₯1, π₯2 , π π, π )
β’ Evaluation function: π π₯1, π₯2, π, π = 1 ππ ππ₯1 + ππ₯2 β 1 β€ π‘ (π. π. 0.1)
0 ππ‘βπππ€ππ π
error function
Line: π π, π
Geometric error: for homography and F-matrix to come
(π is Euclidean distance between point to line)
π₯1, π₯2
π( π₯1, π₯2 , π π, π )
The choice of confidence interval is crucial
16/01/2015
Computer Vision I: Robust Two-View Geometry 54
Large confidence,
βrightβ model, 2 outliers
Large confidence,
βwrongβ model, 2 outliers
Small confidence,
Almost all points are outliers (independent of the model)
Examples:
Extension: Adaptive number of samples π
Choose π in an adaptive way:
1) Fix π = 99.9% (very large value)
2) Set π = β and π = 0.9 (large value for outlier) 3) During RANSAC adapt π, π :
1) Re-compute π from current best solution π = outliers / all points
2) Re-Compute new π:
π =
log 1βπlog(1β 1βπ π)
16/01/2015
Computer Vision I: Robst Two-View Geometry 55
MSAC (M-Estimator SAmple Consensus)
16/01/2015
Computer Vision I: Robust Two-View Geometry 56
If a data point is an inlier the penalty is not 0, but it depends on the
βdistanceβ to the model.
Example for the fundamental matrix:
becomes
β the task is to find the model with the minimum average penalty
[P.H.S. Torr und A. Zisserman 1996]
βrobust functionβ
π‘)
π π₯π, π₯π, πΉ = 0 ππ π₯ππ‘πΉπ₯π β€ π‘ (π. π. 0.1)
1 ππ‘βπππ€ππ π
π π₯π, π₯π, πΉ = π₯ππ‘πΉπ₯π ππ π₯ππ‘πΉπ₯π β€ π‘ (π. π. 0.1)
π‘ ππ‘βπππ€ππ π
π‘
Randomized RANSAC
16/01/2015
Computer Vision I: Robust Two-View Geometry 57
Evaluation of a hypothesis , i.e. is often time consuming
RandomizedRANSAC:
instead of checking all data points 1. Sample π points from
2. If all of them are good, check all others as before
3. If there is at least one bad point, among π, reject the hypothesis It is possible that good hypotheses are rejected.
However it saves time (bad hypotheses are recognized fast)
β one can sample more often
β overall often profitable (depends on application).
Refinement after RANSAC
Typical procedure:
1. RASNAC: compute model π¦ in a robust way 2. Find all inliers π₯
πππππππ3. Refine model π¦ from inliers π₯
πππππππ4. Go to Step 2.
(until numbers of inliers or model does not change much)
16/01/2015
Computer Vision I: Image Formation Process 58
In last lecture we asked (for rotating camera)β¦
16/01/2015
Computer Vision I: Robust Two-View Geometry 59
Question 1: If a match is completly wrong then is a bad idea Answer: RANSAC with π = 4
Question 2: If a match is slighly wrong then might not be perfect.
Better might be a geometric error:
Answer: see next slides
ππππππβ π΄π
ππππππβ π΄π
ππππππβ π―π₯ β π₯β²
Reminder from last Lecture: Homography for rotating camera
16/01/2015
Computer Vision I: Robust Two-View Geometry 60
image
Algorithm:
1) Take π β₯ 4 point matches (π₯, π₯β) 2) Assemble π΄ with π΄π = 0
3) compute π
β= ππππππ
ππ΄π subject to π = 1,
use SVD to do this.
Refine Hypothesis π» with inliers
16/01/2015
Computer Vision I: Robust Two-View Geometry 61
1. Algebraic error: ππππππ
β π΄π2. First
geometric error:
π»β = πππππππ» π π(π₯πβ², π»π₯π)This is not symmetric
π₯π π»π₯π π₯πβ²
where π(π, π)is 2D geometric distance π β π 2
Refine Hypothesis π» with inliers
16/01/2015
Computer Vision I: Robust Two-View Geometry 62
1. Algebraic error: ππππππ
β π΄π2. First
geometric error:
π»β = πππππππ» π π(π₯πβ², π»π₯π)where π(π, π)is 2D geometric distance π β π 2
π₯π π»β1π₯β²π π»π₯π π₯πβ²
3. Second, symmetric geometric error:
π»β = πππππππ» ππ π₯πβ², π»π₯π + π π₯π, π»β1π₯β²πRefine Hypothesis π» with inliers
16/01/2015
Computer Vision I: Robust Two-View Geometry 63
1. Algebraic error: ππππππ
β π΄π2. First
geometric error:
π»β = πππππππ» π π(π₯πβ², π»π₯π)where π(π, π)is 2D geometric distance π β π 2
3. Second, symmetric geometric error:
π»β = πππππππ» ππ π₯πβ², π»π₯π + π π₯π, π»β1π₯β²π4. Third, optimal geometric error (gold standard error):
{π»β, π₯π, π₯β²π} = ππππππ π π(π₯π, π₯π) + π(π₯β²π, π₯β²π)
π₯π π₯πβ²
the true 3D points π are searched for π₯π ^
^ π₯πβ²
π»
Comment: This is optimal in the sense that it is the maximum-likelihood (ML) estimation under isotropic Gaussian noise assumption for π₯^ (see page 103 HZ)
^
^ ^
^ π π’πππππ‘ π‘π π₯^πβ² = π»π₯^π
π», π₯^π, π₯β²π
^ ^
Full Homography Method (HZ page 123)
16/01/2015
Computer Vision I: Robust Two-View Geometry 64
[see details on page 114ff in HZ]
we discussed : Harries corner detector we discussed : Kd-tree to make it fast
This is the optimal geometric error
See next slides This is a geometric error (for fixed H, see next slides).
Depending on runtime one can choose different once.
See next slide
Example
16/01/2015
Computer Vision I: Robust Two-View Geometry 65
Input images
~500 interest points
Example
16/01/2015
Computer Vision I: Robust Two-View Geometry 66
268 putative
matches 117
outliers found
151 inliers found
262 inliers after guided matching
Guided matching Variant: use given π» and look for new inliers. Here we also double the threshold on appearance feature matches to get more inliers.
To have a 95% chance that an inlier is inside the confidence interval, we require:
1. For a 2D line: π π₯, π β€ π 3.84 = π‘
2. For a Homography: π π₯π, π₯π, π» β€ π 5.99 = π‘ 3. For an F-matrix: π π₯π, π₯π, πΉ β€ π 3.84 = π‘
Geometric derivation of confidence interval
16/01/2015
Computer Vision I: Image Formation Process 67
Assume Gaussian noise for a point with π standard deviation and 0 mean:
(see page 119 HZ)
π₯, π₯β²^ ^
ππππππ
π
π(π₯π, π₯π) + π(π₯β²π, π₯β²π)
Methods for πΉ/πΈ/π» Matrix computation - Summary
Procedure (as mentioned above):
1. RASNAC: compute model πΉ/πΈ/π» in a robust way 2. Find all inliers π₯πππππππ (with potential relaxed criteria) 3. Refine model πΉ/πΈ/π» from inliers π₯πππππππ
4. Go to Step 2.
(until numbers of inliers or model does not change much)
16/01/2015
Computer Vision I: Image Formation Process 68
1. For a Homography: π π₯, π₯β², π» = min π π₯, π₯ + π π₯β², π₯β²^ ^ subject to π₯β² = π»π₯^ ^
2. For an πΉ/πΈ-matrix: π π₯, π₯β², πΉ/πΈ = min π π₯, π₯ + π π₯β², π₯β²^ ^ subject to π₯^β²π‘πΉ/πΈπ₯ = 0^
We need geometric error for model refinement πΉ/πΈ/π» :
1. For a Homography: {π»β, π₯π, π₯πβ²} = ππππππ
π
π(π₯π, π₯π) + π(π₯β²π, π₯β²π) subject toπ₯β²π = π»π₯π 2. For an πΉ/πΈ-matrix: {πΉβ/πΈβ, π₯π, π₯πβ²}= sbj. to π₯β²ππ‘πΉ/πΈπ₯π = 0
^ ^
^
π», π₯π, π₯β²^π
πΉ/πΈ, π₯π, π₯β²^ π
^
^
^
^
^ ^
^
βwe see in next lecture that this one can be computed in closed-formβ
^ ^
^ ^
We need geometric error for a fixed model πΉ/πΈ/π» :
^ π₯, π₯β²^
A few word on iterative continuous optimization
So far we had linear (least square) optimization problems:
π₯β = πππππππ₯ π΄π₯
For non-linear (arbitrary) optimization problems:
π₯β = πππππππ₯ π(π₯)
β’ Iterative Estimation methods (see Appendix 6 in HZ; page 597ff)
β’ Gradient Descent Method
(good to get roughly to solution)
β’ Newton Methods (e.g. Gauss-Newton):
second order Method (Hessian). Good to find accurate result
β’ Levenberg β Marquardt Method:
mix of Newton method and Gradient descent
16/01/2015
Computer Vision I: Robust Two-View Geometry 69 Red Newtonβs method;
green gradient descent
Application: Automatic Panoramic Stitching
16/01/2015
Computer Vision I: Robust Two-View Geometry 70
Run Homography search between all pairs of images An unordered set of images:
Application: Automatic Panoramic Stitching
16/01/2015
Computer Vision I: Robust Two-View Geometry 71
... automatically create a panorama
Application: Automatic Panoramic Stitching
16/01/2015
Computer Vision I: Robust Two-View Geometry 72
... automatically create a panorama
Application: Automatic Panoramic Stitching
16/01/2015
Computer Vision I: Robust Two-View Geometry 73