Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for...

31
(c) 2010 Per-Erik Forssén Geometry for computer Vision Lecture 5b: Calibrated multi-view Geometry

Transcript of Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for...

Page 1: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Geometry for computer Vision

L e c t u r e 5 b :C a l i b r a t e d m u l t i - v i e w

G e o m e t r y

Page 2: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Lecture 5b: calibrated multi-view geometry

The 5-point Algorithm

P3P

Bundle Adjustment

2

Page 3: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Tools for image-based 3d models

E.g. Photo Tourism from University of Washington. (has a web demo)

3

Page 4: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Tools for image-based 3d models

E.g. Pons et al. at Inria Sophia-Antipolis CVPR’09

4

Page 5: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Planar degeneracy

In the uncalibrated case, two view geometry is encoded by the fundamental matrix

5

xT1 Fx2 = 0

Page 6: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Planar degeneracy

In the uncalibrated case, two view geometry is encoded by the fundamental matrix

If all scene points lie on a plane, or if the camera has undergone a pure rotation (no translation), we also have:

Big trouble!

6

xT1 Fx2 = 0

x1 = Hx2

Page 7: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Planar degeneracy

If , then the epipolar constraint becomes

For , this is true whenever M is skew-symmetric, i.e.

7

x1 = Hx2

xT1 Fx2 = x

T1 FH

−1x1 = 0

M = FH−1

MT + M = 0 M = [m]×⇔

Page 8: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Planar degeneracy

If , then the epipolar constraint becomes

For , this is true whenever M is skew-symmetric, i.e.

Thus where s may be chosen freely!

A two-parameter family of solutions.

8

x1 = Hx2

xT1 Fx2 = x

T1 FH

−1x1 = 0

M = FH−1

MT + M = 0

F = [s]×H

M = [m]×⇔

Page 9: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

The 5-point algorithm

Recap from last weeks lecture...

In the calibrated case, epipolar geometry is encoded by the essential matrix, E according to:

9

xT1 Ex2 = 0

Page 10: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

The 5-point algorithm

Recap from last weeks lecture...

In the calibrated case, epipolar geometry is encoded by the essential matrix, E according to:

In the calibrated setting there are just two possibilities if a plane is seen. See Negahdaripour, Closed-form relationship between the two interpretations of a moving plane. JOSA90

10

xT1 Ex2 = 0

Page 11: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

The 5-point algorithm

E can be estimated from 5 corresponding points (see today’s paper).

A small sample is useful for RANSAC (le 3).

The plane degeneracy is essentially avoided.

There are however up to 10 solutions for E to test.

11

Page 12: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

If we have the calibrated two view geometry, and want to add another view to the model.

Or, in general from N views to N+1 views...

First triangulate image points in two views to get 3D points X

Then relate X to image points in the new view

12

x

y ∼ [R|t]X

Page 13: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Each correspondencegives us 2 equations.

We have 6 unknowns.

at least 3 points are needed

13

y ∼ [R|t]X

Page 14: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Each correspondencegives us 2 equations.

We have 6 unknowns.

at least 3 points are needed

If we have outliers, we want to use RANSAC, with a minimal sample set.

14

y ∼ [R|t]X

Page 15: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Instead of determining R, t directly one typically computes the distances to the 3D points X from the new camera centre given the side lengths of the 3D triangle, and the projections in the image.

15

Page 16: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Recall the law of cosines:

16

c2 = a2 + b2 − 2ab cos γ

Page 17: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Recall the law of cosines:

By expressing the angles via scalar products, we get 3 equations with 3 unknowns.

17

c2 = a2 + b2 − 2ab cos γ

Page 18: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Define angles between rays as:

and the side lengths as:

18

cos γkl =xT

k xl

||xk||||xl||lkl = ||Xk −Xl||

s21 + s2

2 − 2s1s2 cos γ12 = l212s21 + s2

3 − 2s1s3 cos γ13 = l213s22 + s2

3 − 2s2s3 cos γ23 = l223

Page 19: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Define angles between rays as:

and the side lengths as:

This can be converted into a fourth degree polynomial, which is then solved.

19

cos γkl =xT

k xl

||xk||||xl||lkl = ||Xk −Xl||

s21 + s2

2 − 2s1s2 cos γ12 = l212s21 + s2

3 − 2s1s3 cos γ13 = l213s22 + s2

3 − 2s2s3 cos γ23 = l223

Page 20: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Numerical issues when solving the 4th degree polynomial.

Various approaches compared by Haralick et al. Analysis and Solutions of the Three Point Perspective Pose Estimation Problem, IJCV94

P3P has up to four real solutions that have to be checked inside RANSAC.

20

Page 21: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Perspective 3-point problem

Once we have solved P3P we have 3D points in the new camera.

By relating these to the known 3D points in the world coordinate system, R, t are uniquely defined.

21

Page 22: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

We can now build a decent 3D model by incrementally adding new cameras using P3P.

But...

22

Page 23: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

We can now build a decent 3D model by incrementally adding new cameras using P3P.

But for long trajectories, errors will start to accumulate.

23

Page 24: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

BA is essentially ML over all image correspondences given all cameras, and all 3D points.

24

{R∗, t∗,X∗} = arg min{R,t,X}

k,l

d(xkl,K[Rk|tk]Xl)2

Page 25: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

BA is essentially ML over all image correspondences given all cameras, and all 3D points. (Optionally also intrinsics.)

Needs initial guess. (Obtained by RANSAC on 5-point method and P3P)

Open source SBA, by M. Lourakis et al.25

{R∗, t∗,X∗} = arg min{R,t,X}

k,l

d(xkl,K[Rk|tk]Xl)2

Page 26: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

The choice of parametrisation of 3D points, and camera rotations is important.

If both near and far points are seen, it might be better to usethan

Good choices for rotations are unit quarternions, and axis-angle (see le 7)

26

X = [X1, X2, X3, X4]T

X = [X1, X2, X3, 1]T

Page 27: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

Descent on the cost function is typically done using a regularized Newton method, such as Levenberg-Marquardt

Block structure. Should be utilised for speed!

27

min�

k,l

(xkl − f(Xk,Sl))2

k,l

(xkl − f(Xk,Sl + δl))2 ≈�

k,l

(xkl − f(Xk,Sl) + Jklδl)2

Page 28: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

Block structure. Should be utilised for speed!

28

A-E features1-4 cameras

K1,K2 intrinsics

Page 29: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Bundle adjustment

Too many details to mention.

See the paper: Triggs et al., Bundle Adjustment - A Modern Synthesis, LNCS Book chapter, 2000

29

Page 30: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

Discussion

Discussion of the paper:David Nistér, An Efficient Solution to the Five-Point Relative Pose Problem, CVPR’03

30

Page 31: Geometry for computer Vision - Linköping University · (c) 2010 Per-Erik Forss n Tools for image-based 3d models E.g. Photo Tourism from University of Washington. (has a web demo)

( c ) 2 0 1 0 P e r - E r i k F o r s s é n

for next week...

Quan Invariants of Six Points and Projective Reconstruction From Three Uncalibrated Images PAMI’95. Sec 1-3

Ondrej Chum and Jiri Matas, Matching with PROSAC – Progressive Sample Consensus, CVPR’05

31