47
Structure from motion Class 9 Read Chapter 5

Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Embed Size (px)

Citation preview

Page 1: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Structure from motionClass 9

Read Chapter 5

Page 2: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

3D photography course schedule(tentative)

Lecture Exercise

Sept 26 Introduction -

Oct. 3 Geometry & Camera model Camera calibration

Oct. 10 Single View Metrology Measuring in images

Oct. 17 Feature Tracking/matching(Friedrich Fraundorfer)

Correspondence computation

Oct. 24 Epipolar Geometry F-matrix computation

Oct. 31 Shape-from-Silhouettes(Li Guan)

Visual-hull computation

Nov. 7 Stereo matching Project proposals

Nov. 14 Structured light and active range sensing

Papers

Nov. 21 Structure from motion Papers

Nov. 28 Multi-view geometry and self-calibration

Papers

Dec. 5 Shape-from-X Papers

Dec. 12 3D modeling and registration Papers

Dec. 19 Appearance modeling and image-based rendering

Final project presentations

Page 3: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Today’s class

• Structure from motion

• factorization • sequential

• bundle adjustment

Page 4: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Factorization

• Factorise observations in structure of the scene and motion/calibration of the camera

• Use all points in all images at the same time

Affine factorisation Projective factorisation

Page 5: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Affine cameraThe affine projection equations are

1

j

j

j

yi

xi

ij

ij

Z

Y

X

P

Py

x

10001

1

j

j

j

yi

xi

ij

ij

Z

Y

X

P

P

y

x

~

~

4

4

j

j

j

yi

xi

ij

ij

yiij

xiij

Z

Y

X

P

Py

x

Py

Px

how to find the origin? or for that matter a 3D reference point?

affine projection preserves center of gravity

i

ijijij xxx~ i

ijijij yyy~

Page 6: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Orthographic factorizationThe ortographic projection equations are

where njmijiij ,...,1,,...,1,Mm P

All equations can be collected for all i and j

where

n

mmnmm

n

n

M,...,M,M,,

mmm

mmm

mmm

212

1

21

22221

11211

M

P

P

P

Pm

MPm

M ~

~m

j

j

j

jyi

xi

iij

ijij

Z

Y

X

,P

P,

y

xP

Note that P and M are resp. 2mx3 and 3xn matrices and

therefore the rank of m is at most 3

(Tomasi Kanade’92)

Page 7: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Orthographic factorizationFactorize m through singular value

decomposition

An affine reconstruction is obtained as follows

TVUm

TVMUP ~,

~

(Tomasi Kanade’92)

nm

mnmm

n

n

M,...,M,M

mmm

mmmmmm

min 212

1

21

22221

11211

P

P

P

Closest rank-3 approximation yields MLE!

Page 8: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

0~~

1~~

1~~

1

1

1

TT

TT

TT

yi

xi

yi

yi

xi

xi

PP

PP

PP

AA

AA

AA

0~~

1~~

1~~

T

T

T

yi

xi

yi

yi

xi

xi

PP

PP

PP

C

C

C

A metric reconstruction is obtained as follows

Where A is computed from

Orthographic factorizationFactorize m through singular value

decomposition

An affine reconstruction is obtained as follows

TVUm

TVMUP ~,

~

MAMAPP~

,~ 1

0

1

1

T

T

T

yi

xi

yi

yi

xi

xi

PP

PP

PP 3 linear equations per view on

symmetric matrix C (6DOF)

A can be obtained from C through Cholesky factorisation

and inversion

(Tomasi Kanade’92)

Page 9: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Examples

Tomasi Kanade’92,Poelman & Kanade’94

Page 10: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Examples

Tomasi Kanade’92,Poelman & Kanade’94

Page 11: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Examples

Tomasi Kanade’92,Poelman & Kanade’94

Page 12: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Examples

Tomasi Kanade’92,Poelman & Kanade’94

Page 13: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Perspective factorizationThe camera equations

for a fixed image i can be written in matrix form as

where

mjmijiijij ,...,1,,...,1,Mmλ P

MPm iii

imiii

mimiii

λ,...,λ,λdiagM,...,M,M , m,...,m,m

21

2121

Mm

Page 14: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Perspective factorizationAll equations can be collected for all i as

wherePMm

mnn P

P

P

P

m

m

m

m...

,...

2

1

22

11

In these formulas m are known, but Li,P and M are unknown

Observe that PM is a product of a 3mx4 matrix and a 4xn matrix, i.e. it is a rank-4 matrix

Page 15: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Perspective factorization algorithm

Assume that Li are known, then PM is known.

Use the singular value decomposition PM=US VT

In the noise-free case

S=diag(s1,s2,s3,s4,0, … ,0)and a reconstruction can be obtained by setting:

P=the first four columns of US.M=the first four rows of V.

Page 16: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Iterative perspective factorization

When Li are unknown the following algorithm can be used:

1. Set lij=1 (affine approximation).

2. Factorize PM and obtain an estimate of P and M. If s5 is sufficiently small then STOP.

3. Use m, P and M to estimate Li from the camera equations (linearly) mi Li=PiM

4. Goto 2.

In general the algorithm minimizes the proximity measure P(L,P,M)=s5

Note that structure and motion recovered up to an arbitrary projective transformation

Page 17: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Further Factorization work

Factorization with uncertainty

Factorization for dynamic scenes

(Irani & Anandan, IJCV’02)

(Costeira and Kanade ‘94)

(Bregler et al. ‘00, Brand ‘01)

(Yan and Pollefeys, ‘05/’06)

Page 18: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

practical structure and motion recovery from images

• Obtain reliable matches using matching or tracking and 2/3-view relations

• Compute initial structure and motion• Refine structure and motion• Auto-calibrate• Refine metric structure and motion

Page 19: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Initialize Motion (P1,P2 compatibel with F)

Sequential Structure and Motion Computation

Initialize Structure (minimize reprojection error)

Extend motion(compute pose through matches seen in 2 or more previous views)

Extend structure(Initialize new structure, refine existing structure)

Page 20: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Computation of initial structure and motion

according to Hartley and Zisserman “this area is still to some extend a

black-art”All features not visible in all imagesÞ No direct method (factorization not applicable)Þ Build partial reconstructions and assemble (more views is more stable, but less corresp.)

1) Sequential structure and motion recovery

2) Hierarchical structure and motion recovery

Page 21: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sequential structure and motion recovery

• Initialize structure and motion from two views

• For each additional view• Determine pose• Refine and extend structure

• Determine correspondences robustly by jointly estimating matches and epipolar geometry

Page 22: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Initial structure and motion

eeaFeP

0IPT

x

2

1

Epipolar geometry Projective calibration

012 FmmT

compatible with F

Yields correct projective camera setup(Faugeras´92,Hartley´92)

Obtain structure through triangulation

Use reprojection error for minimizationAvoid measurements in projective space

Page 23: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Compute Pi+1 using robust approach (6-point RANSAC)

Extend and refine reconstruction

)x,...,X(xPx 11 iii

2D-2D

2D-3D 2D-3D

mimi+1

M

new view

Determine pose towards existing structure

Page 24: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Compute P with 6-point RANSAC

• Generate hypothesis using 6 points

• Count inliers • Projection error ?x,x...,,xXP 11 td iii

• Back-projection error ijtd jiij ?,x,xF

• Re-projection error td iiii x,x,x...,,xXP 11

• 3D error ?X,xP 3-1

Dii td

• Projection error with covariance

td iii x,x...,,xXP 11

• Expensive testing? Abort early if not promising• Verify at random, abort if e.g. P(wrong)>0.95(Chum and Matas, BMVC’02)

Page 25: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Dealing with dominant planar scenes

• USaM fails when common features are all in a plane

• Solution: part 1 Model selection to detect problem

(Pollefeys et al., ECCV‘02)

Page 26: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Dealing with dominant planar scenes

• USaM fails when common features are all in a plane• Solution: part 2 Delay ambiguous computations

until after self-calibration(couple self-calibration over all 3D

parts)

(Pollefeys et al., ECCV‘02)

Page 27: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Non-sequential image collections

4.8im/pt64 images

3792

po

ints

Problem:Features are lost and reinitialized as new features

Solution:Match with other close views

Page 28: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

For every view iExtract featuresCompute two view geometry i-1/i and matches Compute pose using robust algorithmRefine existing structureInitialize new structure

Relating to more views

Problem: find close views in projective frame

For every view iExtract featuresCompute two view geometry i-1/i and matches Compute pose using robust algorithmFor all close views k

Compute two view geometry k/i and matchesInfer new 2D-3D matches and add to list

Refine pose using all 2D-3D matchesRefine existing structureInitialize new structure

Page 29: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Determining close views

• If viewpoints are close then most image changes can be modelled through a planar homography

• Qualitative distance measure is obtained by looking at the residual error on the best possible planar homography

Distance = m´,mmedian min HD

Page 30: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

9.8im/pt

4.8im/pt

64 images

64 images

3792

po

ints

2170

po

ints

Non-sequential image collections (2)

Page 31: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Hierarchical structure and motion recovery

• Compute 2-view• Compute 3-view• Stitch 3-view reconstructions• Merge and refine reconstruction

FT

H

PM

Page 32: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Stitching 3-view reconstructions

Different possibilities1. Align (P2,P3) with (P’1,P’2) -1

23-1

12H

HP',PHP',Pminarg AA dd

2. Align X,X’ (and C’C’) j

jjAd HX',XminargH

3. Minimize reproj. error

jjj

jjj

d

d

x',HXP'

x,X'PHminarg 1-

H

4. MLE (merge) j

jjd x,PXminargXP,

Page 33: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Refining structure and motion

• Minimize reprojection error

• Maximum Likelyhood Estimation (if error zero-mean

Gaussian noise)• Huge problem but can be solved

efficiently (Bundle adjustment)

m

k

n

iikD

ik 1 1

2

kiM̂,P̂

M̂P̂,mmin

Page 34: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Non-linear least-squares

• Newton iteration• Levenberg-Marquardt • Sparse Levenberg-Marquardt

(P)X f (P)X argminP

f

Page 35: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Newton iteration

Taylor approximation

J)(P )(P 00 ffP

XJ

Jacobian

)(PX 1f

JJ)(PX)(PX 001 eff

0T-1T

0TT JJJJJJ ee

i1i PP 0T-1T JJJ e

01-T-11-T JJJ e

normal eq.

Page 36: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Levenberg-Marquardt

0TT JNJJ e

0TJN' e

Augmented normal equations

Normal equations

J)λdiag(JJJN' TT

30 10λ

10/λλ :success 1 ii

ii λ10λ :failure solve again

accept

l small ~ Newton (quadratic convergence)

l large ~ descent (guaranteed decrease)

Page 37: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Levenberg-Marquardt

Requirements for minimization• Function to compute f• Start value P0 • Optionally, function to compute

J(but numerical ok, too)

Page 38: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sparse Levenberg-Marquardt

• complexity for solving• prohibitive for large problems

(100 views 10,000 points ~30,000 unknowns)

• Partition parameters• partition A • partition B (only dependent on A and

itself)

0T-1 JN' e3N

Page 39: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sparse bundle adjustment

residuals:normal equations:

with

note: tie points should be in partition A

Page 40: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sparse bundle adjustment

normal equations:

modified normal equations:

solve in two parts:

Page 41: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sparse bundle adjustment

U1

U2

U3

WT

W

V

P1 P2 P3 M

Jacobian of has sparse block structure

J JJN T

12xm 3xn(in general

much larger)

im.pts. view 1

m

k

n

iikD

1 1

2ki M̂P̂,m

Needed for non-linear minimization

Page 42: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sparse bundle adjustment• Eliminate dependence of

camera/motion parameters on structure parametersNote in general 3n >> 11m

WT V

U-WV-1WT

NI0WVI 1

11xm 3xn

Allows much more efficient computations

e.g. 100 views,10000 points,

solve 1000x1000, not 30000x30000

Often still band diagonaluse sparse linear algebra algorithms

Page 43: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sparse bundle adjustment

normal equations:

modified normal equations:

solve in two parts:

Page 44: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Sparse bundle adjustment

• Covariance estimation

-1WVY

1a

Tb

1-a

VYY

WWVU

Yaab -

Page 45: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Related problems

• On-line structure from motion and SLaM (Simultaneous Localization and Mapping)• Kalman filter (linear)• Particle filters (non-linear)

Page 46: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Open challenges

• Large scale structure from motion• Complete building• Complete city

Page 47: Structure from motion Class 9 Read Chapter 5. 3D photography course schedule (tentative) LectureExercise Sept 26Introduction- Oct. 3Geometry & Camera

Next class: Multi-View Geometry and Self-Calibration