Lecture 9 - Fundamental Matrix & Structure from...

47
Fundamental Matrix & Structure from Motion Instructor - Simon Lucey 16-423 - Designing Computer Vision Apps

Transcript of Lecture 9 - Fundamental Matrix & Structure from...

Page 1: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Fundamental Matrix & Structure from

Motion Instructor - Simon Lucey

16-423 - Designing Computer Vision Apps

Page 2: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Today

• Transformations between images

• Structure from Motion

• The Essential Matrix

• The Fundamental Matrix

Page 3: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Transformations between images

• So far we have considered transformations between the image and a plane in the world

• Now consider two cameras viewing the same plane

• There is a homography between camera 1 and the plane and a second homography between camera 2 and the plane

• It follows that the relation between the two images is also a homography

Page 4: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Camera under pure rotation

Special case is camera under pure rotation.Homography can be showed to be

Page 5: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Camera under pure rotation

Special case is camera under pure rotation.Homography can be showed to be

Why is this?

Page 6: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Panorama Example418 15 Models for transformations

a) b) c)

d)

Figure 15.22 Computing visual panoramas. a-c) Three images of the samescene where the camera has rotated but not translated. Five matching pointshave been identified by hand between each pair. d) A panorama can becreated by mapping the first and third images into the frame of reference ofthe second image.

(middle) photo into the center of a much larger empty image. Then 5 matches wereidentified by hand between this expanded second image and the first image andthe homography from the expanded second image to the first image was computed.For each empty pixel in the expanded second image we compute the position inthe first image using this homography. If this falls within the image boundaries,we copy the pixel value.

This process can be completely automated by finding features and fitting ahomography to each pair of images using a robust technique such as RANSAC. Ina real system, the final result is typically projected onto a cylinder and unrolled togive a more visually pleasing result.

Discussion

This chapter has presented a number of important ideas. First, we discussed afamily of transformations and how each can be related to a camera viewing the sceneunder special conditions. These transformations are used widely within machinevision and we will see them exploited in chapters 17, 18 and 19. Second, we

Copyright c�2011,2012 by Simon Prince; published by Cambridge University Press 2012.For personal use only, not for distribution.

Page 7: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Review - Homography

• Start with basic projection equation:

• Combining these two matrices we get:

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 8: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Review - Homography

Homogeneous:

Cartesian:

For short:

Page 9: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Review - Homography

Homogeneous:

Cartesian:

For short:

How many unknowns?

Page 10: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Homography Estimation

• Re-arrange cartesian equations,

15.3 Inference in transformation models 401

2

4xi

yi

1

3

5 =

2

4�11 �12 �13

�21 �22 �23

�31 �32 �33

3

5

2

4ui

vi

1

3

5 . (15.34)

Each homogeneous coordinate can be considered as a direction in 3D space(figure 14.11). So, this equation states that the left-hand side x̃

i

represents thesame direction in space as the right-hand side, �w̃

i

. If this is the case, their crossproduct must be zero, so that

x̃⇥�w̃ = 0. (15.35)

Writing this constraint in full gives the relationsProblem 15.9

2

4y(�31u+ �32v + �33)� (�21u+ �22v + �23)(�11u+ �12v + �13)� x(�31u+ �32v + �33)x(�21u+ �22v + �23)� y(�11u+ �12v + �13)

3

5 = 0. (15.36)

This appears to provide three linear constraints on the elements of �. However,only two of these three equations are independent, so we discard the third. Wenow stack the first two constraints from each of the I pairs of points {x

i

,wi

} toform the system

2

6666666664

0 0 0 �u1 �v1 �1 y1u1 y1v1 y1u1 v1 1 0 0 0 �x1u1 �x1v1 �x1

0 0 0 �u2 �v2 �1 y2u2 y2v2 y2u2 v2 1 0 0 0 �x2u2 �x2v2 �x2...

......

......

......

......

0 0 0 �uI

�vI

�1 yI

uI

yI

vI

yI

uI

vI

1 0 0 0 �xI

uI

�xI

vI

�xI

3

7777777775

2

6666666666664

�11

�12

�13

�21

�22

�23

�31

�32

�33

3

7777777777775

= 0, (15.37)

which has the form A� = 0.We solve this system of equations in a least squares sense with the constraint

�T� = 1 to prevent the trivial solution � = 0. This is a standard problem (seeappendix C.7.2). To find the solution, we compute the SVDA = ULVT and choose� to be the last column of V. This is reshaped into a 3⇥3 matrix � and used as astarting point for the nonlinear optimization of the true criterion (equation 15.33).

15.3 Inference in transformation models

We have introduced four transformations (Euclidean, similarity, a�ne, projective)Algorithm 15.5

that relate positions w on a real-world plane to their projected positions x in the

Copyright c�2011,2012 by Simon Prince; published by Cambridge University Press 2012.For personal use only, not for distribution.

• Form linear system

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 11: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Homography Estimation

• In MATLAB this becomes, >> [U,S,V] = svd(A); >> Phi = reshape(V(:,end),[3,3])’;

• Both sides are 3x1 vectors; should be parallel, so cross product will be zero

• For you to try MATLAB, >> x = [randn(2,1);1]; cross(x,4*x)

Page 12: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Caution…

• Approach only minimizes algebraic error NOT the re-

projection error!!!

• Need to employ non-linear optimization.

Page 13: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Estimating Extrinsics

Page 14: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Estimating Extrinsics

• Writing out the camera equations in full

• Estimate the homography from matched points• Factor out the intrinsic parameters

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 15: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Estimating Extrinsics

• Find the last column using the cross product of first two columns

• Make sure the determinant is 1. If it is -1, then multiply last column by -1.

• Find translation scaling factor between old and new values

• Finally, set

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 16: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Augmented Reality

Page 17: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Today

• Transformations between images

• Structure from Motion

• The Essential Matrix

• The Fundamental Matrix

Page 18: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Taken from Agarwal et al. “Building Rome in a Day”, ICCV 2009.

Page 19: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Taken from Agarwal et al. “Building Rome in a Day”, ICCV 2009.

Page 20: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Structure from Motion

For simplicity, we’ll start with simpler problem

• Just J=2 images• Known intrinsic matrix

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 21: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Epipolar lines

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 22: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Epipole

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 23: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Special configurations

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 24: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Today

• Transformations between images

• Structure from Motion

• The Essential Matrix

• The Fundamental Matrix

Page 25: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Review - Cross Product

• Cross product between two 3D vectors is defined as,

• Operation is equivalent to the,

• Can be written in short as,

614 C Linear algebra

C.1.3 Cross product

The cross product or vector product is specialized to three dimensions. The opera-tion c = a⇥ b is equivalent to the matrix multiplication (section C.2.1):

2

4c1c2c3

3

5 =

2

40 �a3 a2a3 0 �a1�a2 a1 0

3

5

2

4b1b2b3

3

5 , (C.3)

or for short

c = A⇥b, (C.4)

where A⇥ is the 3⇥3 matrix from equation C.3 that implements the cross product.

It is easily shown that the result c of the cross product is orthogonal to both aand b. In other words,

aT (a⇥ b) = bT (a⇥ b) = 0. (C.5)

C.2 Matrices

Matrices are used extensively throughout the book and are written as bold, capital,Roman or Greek letters (e.g., A,�). We categorize matrices as landscape (morecolumns than rows), square (the same number of columns and rows) or portrait(more rows than columns). They are always indexed by row first and then column,so a

ij

denotes the element of matrix A at the ith row and the jth column.

A diagonal matrix is a square matrix with zeros everywhere except on thediagonal (i.e., elements a

ii

) where the elements may take any value. An importantspecial case of a diagonal matrix is the identitymatrix I. This has zeros everywhereexcept for the diagonal, where all the elements are ones.

C.2.1 Matrix multiplication

To take the matrix product C = AB, we compute the elements of C as

cij

=KX

k=1

aik

bkj

. (C.6)

This can only be done when the number of columns in A equals the number ofrows in B. Matrix multiplication is associative so that A(BC) = (AB)C = ABC.However it is not commutative so that in general AB 6= BA.

Copyright c�2011,2012 by Simon Prince; published by Cambridge University Press 2012.For personal use only, not for distribution.

614 C Linear algebra

C.1.3 Cross product

The cross product or vector product is specialized to three dimensions. The opera-tion c = a⇥ b is equivalent to the matrix multiplication (section C.2.1):

2

4c1c2c3

3

5 =

2

40 �a3 a2a3 0 �a1�a2 a1 0

3

5

2

4b1b2b3

3

5 , (C.3)

or for short

c = A⇥b, (C.4)

where A⇥ is the 3⇥3 matrix from equation C.3 that implements the cross product.

It is easily shown that the result c of the cross product is orthogonal to both aand b. In other words,

aT (a⇥ b) = bT (a⇥ b) = 0. (C.5)

C.2 Matrices

Matrices are used extensively throughout the book and are written as bold, capital,Roman or Greek letters (e.g., A,�). We categorize matrices as landscape (morecolumns than rows), square (the same number of columns and rows) or portrait(more rows than columns). They are always indexed by row first and then column,so a

ij

denotes the element of matrix A at the ith row and the jth column.

A diagonal matrix is a square matrix with zeros everywhere except on thediagonal (i.e., elements a

ii

) where the elements may take any value. An importantspecial case of a diagonal matrix is the identitymatrix I. This has zeros everywhereexcept for the diagonal, where all the elements are ones.

C.2.1 Matrix multiplication

To take the matrix product C = AB, we compute the elements of C as

cij

=KX

k=1

aik

bkj

. (C.6)

This can only be done when the number of columns in A equals the number ofrows in B. Matrix multiplication is associative so that A(BC) = (AB)C = ABC.However it is not commutative so that in general AB 6= BA.

Copyright c�2011,2012 by Simon Prince; published by Cambridge University Press 2012.For personal use only, not for distribution.

c = [a]⇥b

Page 26: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Review - Cross Product

• In other words,

614 C Linear algebra

C.1.3 Cross product

The cross product or vector product is specialized to three dimensions. The opera-tion c = a⇥ b is equivalent to the matrix multiplication (section C.2.1):

2

4c1c2c3

3

5 =

2

40 �a3 a2a3 0 �a1�a2 a1 0

3

5

2

4b1b2b3

3

5 , (C.3)

or for short

c = A⇥b, (C.4)

where A⇥ is the 3⇥3 matrix from equation C.3 that implements the cross product.

It is easily shown that the result c of the cross product is orthogonal to both aand b. In other words,

aT (a⇥ b) = bT (a⇥ b) = 0. (C.5)

C.2 Matrices

Matrices are used extensively throughout the book and are written as bold, capital,Roman or Greek letters (e.g., A,�). We categorize matrices as landscape (morecolumns than rows), square (the same number of columns and rows) or portrait(more rows than columns). They are always indexed by row first and then column,so a

ij

denotes the element of matrix A at the ith row and the jth column.

A diagonal matrix is a square matrix with zeros everywhere except on thediagonal (i.e., elements a

ii

) where the elements may take any value. An importantspecial case of a diagonal matrix is the identitymatrix I. This has zeros everywhereexcept for the diagonal, where all the elements are ones.

C.2.1 Matrix multiplication

To take the matrix product C = AB, we compute the elements of C as

cij

=KX

k=1

aik

bkj

. (C.6)

This can only be done when the number of columns in A equals the number ofrows in B. Matrix multiplication is associative so that A(BC) = (AB)C = ABC.However it is not commutative so that in general AB 6= BA.

Copyright c�2011,2012 by Simon Prince; published by Cambridge University Press 2012.For personal use only, not for distribution.

Page 27: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Right-hand rule

• Given three orthonormal 3D vectors (x,y, z)

z = x⇥ y

• Then,

Page 28: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

First camera:

Second camera:

Substituting:

This is a mathematical relationship between the points in the two images, but it’s not in the most convenient form.

The Essential Matrix

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 29: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

The Essential Matrix

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 30: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

The cross product term can be expressed as a matrix

Defining:

We now have the essential matrix relation

The Essential Matrix

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 31: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

• Rank 2:

• 5 degrees of freedom

• Non-linear constraints between elements

Properties of the Essential Matrix

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 32: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Recovering Epipolar Lines

Equation of a line:

or

or

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

T

Page 33: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Recovering Epipolar Lines

Equation of a line:

Now consider

This has the form where

So the epipolar lines are

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

T

T

Page 34: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Every epipolar line in image 1 passes through the epipole e1.

In other words for ALL

This can only be true if e1 is in the nullspace of E.

Similarly:

We find the null spaces by computing , and taking the last column of and the last row of .

Recovering Epipolar Lines

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 35: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Essential matrix:

To recover translation and rotation use the matrix:

We take the SVD and then we set

Decomposition of E

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 36: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Four Interpretations

To get the different

solutions, we mutliply τ by -1 and substitute

Page 37: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Today

• Transformations between images

• Structure from Motion

• The Essential Matrix

• The Fundamental Matrix

Page 38: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

The Fundamental Matrix Song

Taken from Daniel Wedge’s home page - http://danielwedge.com/fmatrix/

Page 39: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

The Fundamental Matrix Song

Taken from Daniel Wedge’s home page - http://danielwedge.com/fmatrix/

Page 40: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

The Fundamental MatrixNow consider two cameras that are not normalised

By a similar procedure to before, we get the relation

orwhere

Relation between essential and fundamental

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 41: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Estimation of the Fundamental Matrix

Page 42: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Estimation of Fundamental Matrix

When the fundamental matrix is correct, the epipolar line induced by a point in the first image should pass through the matching point in the second image and vice-versa.

This suggests the criterion

If and then

Unfortunately, there is no closed form solution for this quantity.

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 43: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

The 8 Point AlgorithmApproach:

• solve for fundamental matrix using homogeneous coordinates

• closed form solution (but to wrong problem!)• Known as the 8 point algorithm

Start with fundamental matrix relation

Writing out in full:

or

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 44: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

The 8 Point Algorithm

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Can be written as:

where

Stacking together constraints from at least 8 pairs of points, we get the system of equations

Page 45: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Minimum direction problem of the form Find minimum of subject to .

To solve, compute the SVD and then set to the last column of .

The 8 Point Algorithm

Adapted from: Computer vision: models, learning and inference. Simon J.D. Prince

Page 46: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

Fitting Concerns•This procedure does not ensure that solution is rank 2. Solution: set last singular value to zero.

•Can be unreliable because of numerical problems to do with the data scaling – better to re-scale the data first

•Needs 8 points in general positions (cannot all be planar).

•Fails if there is not sufficient translation between the views

•Use this solution to start non-linear optimisation of true criterion (must ensure non-linear constraints obeyed).

•There is also a 7 point algorithm.

Page 47: Lecture 9 - Fundamental Matrix & Structure from Motion16423.courses.cs.cmu.edu/slides/Spring_2017/Lecture_9.pdf · Problem 15.9 2 4 y(31u + 32v + 33) (21u + 22v + 23) (11u + 12v +

More to read…

• Prince et al. • Chapter 16, Sections 1-3.