70
Lecture 03 Image Formation 2 Davide Scaramuzza Lecture given my Guillermo Gallego http://rpg.ifi.uzh.ch Institute of Informatics – Institute of Neuroinformatics 1

Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Lecture 03Image Formation 2

Davide Scaramuzza

Lecture given my Guillermo Gallegohttp://rpg.ifi.uzh.ch

Institute of Informatics – Institute of Neuroinformatics

1

Page 2: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Lab Exercise 2 - Today afternoon

Room ETH HG E 1.1 from 13:15 to 15:00

Work description: your first camera motion estimator using DLT

2

Page 3: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Goal of today’s lecture• Study the algorithms behind robot-position control and augmented reality

3

Page 4: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Outline of this lecture

• (Geometric) Camera calibration

– Non-linear algorithms: P3P and PnP for calibrated cameras

• From general 3D objects

– Linear algorithms (DLT) for uncalibrated cameras

• From 3D objects

• From planar grids

• Non conventional camera models

• Photometric Calibration

4

Page 5: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera

world

3D Landmarks

Image

Pose determination from n Points (PnP) Problem

• Given known 3D landmarks in the world frame and given their image correspondences in the camera frame, determine the 6DOF pose of the camera in the world frame (including the intrinsinc parameters if uncalibrated)

5

Page 6: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

How Many Points are Enough?

• 1 Point: infinitely many solutions.

• 2 Points: infinitely many solutions, but bounded.

• 3 Points: – (no 3 collinear) finitely many solutions (up to 4).

• 4 Points:– Unique solution

6

Page 7: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

1 Point

C

7

Page 8: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

2 Points

C

A

B

8

Page 9: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Inscribed Angles are Equal

q

q

q

C

C

C

A B9

Page 10: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

C

A

B

CP

LC

LB

LA

qBCqAB

qCA

s1

s3s2

ABBABA LLLLs qcos222

1

A’

B’

C’

Image Plane

BCCBCB LLLLs qcos222

2

ACCACA LLLLs qcos222

3

𝑠1

𝑠2

𝑠3

𝐿𝐴

𝐴

𝐵

𝐶

𝐿𝐵

𝐿𝐶

𝜃𝐴𝐵

𝜃𝐴𝐶

𝜃𝐵𝐶

3 Points

C

𝑠12 = 𝐿𝐵

2 + 𝐿𝐶2 − 2𝐿𝐵𝐿𝐶 cos 𝜃𝐵𝐶

𝑠22 = 𝐿𝐴

2 + 𝐿𝐶2 − 2𝐿𝐴𝐿𝐶 cos 𝜃𝐴𝐶

𝑠32 = 𝐿𝐴

2 + 𝐿𝐵2 − 2𝐿𝐴𝐿𝐵 cos 𝜃𝐴𝐵

From Carnot’s Theorem:

10

Page 11: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Algebraic Approach: reduce to 4th order equation(Fischler and Bolles, 1981)

• It is known that 𝑛 independent polynomial equations, in 𝑛 unknowns, can have no more solutions than the product of their respective degrees. Thus, the system can have a maximum of 8 solutions. However, because every term in the system is either a constant or of second degree, for every real positive solution there is a negative solution.

• Thus, with 3 points, there are at most 4 valid (positive) solutions.

• A 4th point can be used to disambiguate the solutions.

𝑠12 = 𝐿𝐵

2 + 𝐿𝐶2 − 2𝐿𝐵𝐿𝐶 cos 𝜃𝐵𝐶

𝑠22 = 𝐿𝐴

2 + 𝐿𝐶2 − 2𝐿𝐴𝐿𝐶 cos 𝜃𝐴𝐶

𝑠32 = 𝐿𝐴

2 + 𝐿𝐵2 − 2𝐿𝐴𝐿𝐵 cos 𝜃𝐴𝐵

04

4

3

3

2

210 xGxGxGxGG

By defining 𝑥 = 𝐿𝐵/𝐿𝐴, it can be shown that the system can be reduced to a 4th order equation:

11

Page 12: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Application to Monocular Visual Odometry: camera pose estimation from known 3D-2D correspondences

Keyframe 1 Keyframe 2

Initial point cloud New triangulated points

Current frameNew keyframe

12

Page 13: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

AR Application: Microsoft HoloLens

13

Page 14: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Outline of this lecture

• (Geometric) Camera calibration

– Non-linear algorithms: P3P and PnP for calibrated cameras

• From general 3D objects

– Linear algorithms (DLT) for uncalibrated cameras

• From 3D objects

• From planar grids

• Non conventional camera models

• Photometric Calibration

14

Page 15: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera calibration• Calibration is the process to determine the intrinsic and extrinsic parameters of the

camera model

• A method proposed in 1987 by Tsai consists of measuring the 3D position of 𝑛 ≥ 6 control points on a three-dimensional calibration target and the 2D coordinates of their projection in the image. This problem is also called “Resection”, or “Perspective from 𝒏 Points”, or “Camera pose from 3D-to-2D correspondences”, and is one of the most widely used algorithms in Computer Vision and Robotics

• Solution: The intrinsic and extrinsic parameters are computed directly from the perspective projection equation; let’s see how!

Pc

O

u

v

p

XcCZc

Yc

W

Zw

Yw

Xw

= Pw

3D position of control points is assignedin a reference frame specified by the user

15

Page 16: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera calibration: Direct Linear Transform (DLT)

Our goal is to compute K, R, and T that satisfy the perspective projection equation (we neglect the radial distortion)

1

1~

~

~

~

w

w

w

Z

Y

X

TRKv

u

w

v

u

p

1100

0

0

~

~

~

3333231

2232221

1131211

0

0

w

w

w

v

u

Z

Y

X

trrr

trrr

trrr

v

u

w

v

u

1

~

~

~

3333231

302330233202231021

301330133201231011

w

w

w

vvvv

uuuu

Z

Y

X

trrr

tvtrvrrvrrvr

tutrurrurrur

w

v

u

16

Page 17: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera calibration: Direct Linear Transform (DLT)

Our goal is to compute K, R, and T that satisfy the perspective projection equation (we neglect the radial distortion)

1

1~

~

~

~

w

w

w

Z

Y

X

TRKv

u

w

v

u

p

1100

0

0

~

~

~

3333231

2232221

1131211

0

0

w

w

w

v

u

Z

Y

X

trrr

trrr

trrr

v

u

w

v

u

1

~

~

~

34333231

24232221

14131211

w

w

w

Z

Y

X

mmmm

mmmm

mmmm

w

v

u

17

Page 18: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera calibration: Direct Linear Transform (DLT)

Our goal is to compute K, R, and T that satisfy the perspective projection equation (we neglect the radial distortion)

where is the i-th row of M

1

~

~

~

34333231

24232221

14131211

w

w

w

Z

Y

X

mmmm

mmmm

mmmm

w

v

u

1

~

~

~

w

w

w

Z

Y

X

M

w

v

u

1

~

~

~

3

2

1

w

w

w

T

T

T

Z

Y

X

m

m

m

w

v

u

T

im

18

Page 19: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera calibration: Direct Linear Transform (DLT)

~

~

~

~

3

2

3

1

Pm

Pm

w

vv

Pm

Pm

w

uu

T

T

T

T

Conversion back from homogeneous coordinates to pixel coordinates leads to:

1

~

~

~

3

2

1

w

w

w

T

T

T

Z

Y

X

m

m

m

w

v

u

0)(

0)(

32

31

i

T

i

T

i

T

i

T

Pmvm

Pmum

P

19

Page 20: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

By re-arranging the terms, we obtain

For 𝑛 points, we can stack all these equations into a big matrix:

0

0

0

0

0

0

0

0

3

2

1111

111

m

m

m

PvP

PuP

PvP

PuP

T

nn

T

n

T

T

nn

TT

n

TTT

TTT

Camera calibration: Direct Linear Transform (DLT)

0

0

0

0

0)(

0)(

3

2

1

111

111

32

31

m

m

m

PvP

PuP

Pmvm

Pmum

TTT

TTT

i

T

i

T

i

T

i

T

20

Page 21: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

By re-arranging the terms, we obtain

For 𝑛 points, we can stack all these equations into a big matrix:

Camera calibration: Direct Linear Transform (DLT)

0

0

0

0

10000

00001

10000

00001

34

33

32

31

24

23

22

21

14

13

12

11

1

1

1

1

1

1

1

111

1

1

1

1

1

1

1

111

m

m

m

m

m

m

m

m

m

m

m

m

vZvYvXvZYX

uZuYuXuZYX

vZvYvXvZYX

uZuYuXuZYX

n

n

wn

n

wn

n

wn

n

w

n

w

n

w

n

n

wn

n

wn

n

wn

n

w

n

w

n

w

wwwwww

wwwwww

Q (this matrix is known) M (this matrix is unknown)

0MQ

0

0

0

0

0)(

0)(

3

2

1

111

111

32

31

m

m

m

PvP

PuP

Pmvm

Pmum

TTT

TTT

i

T

i

T

i

T

i

T

21

Page 22: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Minimal solution

• 𝑄(2𝑛×12) should have rank 11 to have a unique (up to a scale) non-trivial solution 𝑀

• Each 3D-to-2D point correspondence provides 2 independent equations

• Thus, 5+1

2point correspondences are needed (in practice 6 point correspondences!)

Over-determined solution

• n ≥ 6 points

• A solution is to minimize | 𝑄𝑀 |2 subject to the constraint | 𝑀 |2 = 1.It can be solved through Singular Value Decomposition (SVD). The solution is the eigenvector corresponding to the smallest eigenvalue of the matrix 𝑄𝑇𝑄(because it is the unit vector 𝑥 that minimizes | 𝑄𝑥 |2 = 𝑥𝑇𝑄𝑇𝑄𝑥).

• Matlab instructions:

• [U,S,V] = svd(Q);

• M = V(:,12);

Camera calibration: Direct Linear Transform (DLT)

0MQ

22

Page 23: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Degenerate configurations

1. Points lying on a plane and/or along a single line passing through the projection center

2. Camera and points on a twisted cubic (i.e., smooth curve in 3D space of degree 3)

Camera calibration: Direct Linear Transform (DLT)

0MQ

𝐶

𝐶

23

Page 24: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

• Once we have the M matrix, we can recover the intrinsic and extrinsic parameters by remembering that

Camera calibration: Direct Linear Transform (DLT)

T)|K(RM

3

2

1

333231

232221

131211

0

0

34

24

14

333231

232221

131211

100

0

0

t

t

t

rrr

rrr

rrr

v

u

m

m

m

mmm

mmm

mmm

v

u

24

Page 25: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

• Once we have the M matrix, we can recover the intrinsic and extrinsic parameters by remembering that

• However, notice that we are not enforcing the constraint that 𝑅 is orthogonal, i.e., 𝑅 ∙ 𝑅𝑇= 𝐼

• To do this, we can use the so-called QR factorization of 𝑀, which decomposes 𝑀 into a 𝑅 (orthogonal), T, and an upper triangular matrix (i.e., 𝐾)

Camera calibration: Direct Linear Transform (DLT)

T)|K(RM

3333231

302330233202231021

301330133201231011

34

24

14

333231

232221

131211

trrr

tvtrvrrvrrvr

tutrurrurrur

m

m

m

mmm

mmm

mmm

25

Page 26: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Tsai’s (1987) Calibration example1. Edge detection

2. Straight line fitting to the detected edges

3. Intersecting the lines to obtain the image corners (corner accuracy < 0.1 pixels)

4. Use more than 6 points (ideally more than 20) and not all lying on a plane

What are the «skew» and «residuals»?

Why is this ratio not 1?

26

Page 27: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Tsai’s (1987) Calibration example• The original Tsai calibration (1987) used to consider two different focal lengths 𝛼𝑢, 𝛼𝑣

(which means that the pixels are not squared) and a skew factor (𝐾12 ≠ 0, which means the pixels are parallelograms instead of rectangles) to account for possible misalignments (small 𝑥, 𝑦 rotation) between image plane and lens

• Most today’s cameras are well manufactured, thus, we can assume 𝛼𝑢

𝛼𝑣= 1 and 𝐾12 = 0

• What is the residual? The residual is the average “reprojection error”. The reprojection error is computed as the distance (in pixels) between the observed pixel point and the camera-reprojected 3D point. The reprojection error gives as a quantitative measure of the accuracy of the calibration (ideally it should be zero).

27

Page 28: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Outline of this lecture

• (Geometric) Camera calibration

– Non-linear algorithms: P3P and PnP for calibrated cameras

• From general 3D objects

– Linear algorithms (DLT) for uncalibrated cameras

• From 3D objects

• From planar grids

• Non conventional camera models

• Photometric Calibration

29

Page 29: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera calibration from planar grids: homographies

• Tsai’s calibration is based on DLT algorithm, which requires points not to lie on the same plane

• An alternative method (today’s standard camera calibration method) consists of using a planar grid (e.g., a chessboard) and a few images of it shown at different orientations

• This method was invented by Zhang (1999) @Microsoft Research

30

Page 30: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

• Our goal is to compute K, R, and T, that satisfy the perspective projection equation (we neglect the radial distortion)

• Since the points lie on a plane, we have 𝑍𝑤 = 0

1

0

1~

~

~

~ w

w

Y

X

TRKv

u

w

v

u

p

1

0100

0

0

~

~

~

3333231

2232221

1131211

0

0

w

w

v

uY

X

trrr

trrr

trrr

v

u

w

v

u

Camera calibration from planar grids: homographies

1100

0

0

~

~

~

33231

22221

11211

0

0

w

w

v

u

Y

X

trr

trr

trr

v

u

w

v

u

31

Page 31: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

• Our goal is to compute K, R, and T, that satisfy the perspective projection equation (we neglect the radial distortion)

• Since the points lie on a plane, we have 𝑍𝑤 = 0

where is the i-th row of 𝐻

1~

~

~

333231

232221

131211

w

w

Y

X

hhh

hhh

hhh

w

v

u

1~

~

~

w

w

Y

X

H

w

v

u

1~

~

~

3

2

1

w

w

T

T

T

Y

X

h

h

h

w

v

u

T

ih

Camera calibration from planar grids: homographies

This matrix is called Homography

32

Page 32: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

~

~

~

~

3

2

3

1

Ph

Ph

w

vv

Ph

Ph

w

uu

T

T

T

T

Conversion back from homogeneous coordinates to pixel coordinates leads to:

where P = (𝑋𝑤, 𝑌𝑤 , 1)𝑇

0)(

0)(

32

31

i

T

i

T

i

T

i

T

Phvh

Phuh

Camera calibration from planar grids: homographies

1~

~

~

3

2

1

w

w

T

T

T

Y

X

h

h

h

w

v

u

33

Page 33: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

By re-arranging the terms, we obtain

For 𝑛 points, we can stack all these equations into a big matrix:

0

0

0

0

0

0

0

0

3

2

1111

111

h

h

h

PvP

PuP

PvP

PuP

T

nn

T

n

T

T

nn

TT

n

TTT

TTT

0)(

0)(

32

31

i

T

i

T

i

T

i

T

Phvh

Phuh

Camera calibration from planar grids: homographies

0HQ

H (this matrix is unknown)Q (this matrix is known)

0

0

0

0

3

2

1

1

1

h

h

h

PvP

PuP

T

i

T

i

T

T

i

TT

i

00

00

321

321

TT

ii

TT

i

T

TT

ii

TT

i

hPvhPh

hPuhhP

34

Page 34: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Minimal solution

• 𝑄(2𝑛×9) should have rank 8 to have a unique (up to a scale) non-trivial solution 𝐻

• Each point correspondence provides 2 independent equations

• Thus, a minimum of 4 non-collinear points is required

Over-determined solution

• n ≥ 4 points

• It can be solved through Singular Value Decomposition (SVD) (same considerations as the case before apply)

Solving for K, R and T• H can be decomposed by recalling that

0HQ

Camera calibration from planar grids: homographies

33231

22221

11211

0

0

333231

232221

131211

100

0

0

trr

trr

trr

v

u

hhh

hhh

hhh

v

u

35

Page 35: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

How to recover K, R, T from H?

1. Estimate the homography 𝐻𝑖 for each view, using the DLT algorithm.

2. Determine the intrinsics K of the camera from a set of homographies:

1. Each homography 𝐻𝑖 ∼ 𝐾 𝒓1, 𝒓2, 𝒕 provides two linear equations in the 6 entries of the matrix B ≔ 𝐾−⊤𝐾−1. Letting 𝒘1 ≔ 𝐾𝒓1, 𝒘2 ≔ 𝐾𝒓2, the rotation constraints 𝒓1⊤𝒓1 = 𝒓2

⊤𝒓2 = 1 and 𝒓1⊤𝒓2 = 0 become

𝒘1⊤𝐵𝒘1 −𝒘2

⊤𝐵𝒘2 = 0 and 𝒘1⊤𝐵𝒘2 = 0.

2. Stack 2N equations from N views, to yield a linear system 𝐴𝒃 = 𝟎. Solve for b (i.e., B) using the Singular Value Decomposition (SVD).

3. Use Cholesky decomposition to obtain K from B.

3. The extrinsic parameters for each view can be computed using K:𝒓1 ∼ 𝜆𝐾−1𝐻𝑖 : , 1 , 𝒓2 ∼ 𝜆𝐾−1𝐻𝑖 : , 2 , 𝒓3 = 𝒓1 × 𝒓2 and 𝑇𝑖 = 𝜆𝐾−1𝐻𝑖 : , 3 , with 𝜆 = 1/𝐾−1𝐻𝑖 : , 1 . Finally, build 𝑅𝑖 = (𝒓1, 𝒓2, 𝒓3) and enforce rotation matrix constraints.

Won’t be asked at the exam

36

Page 36: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Types of 2D Transformations

This transformation is called Homography

37

Page 37: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera calibration from planar grids: homographies

• Demo of Camera Calibration Toolbox for Matlab (world’s standard toolbox for

calibrating perspective cameras): http://www.vision.caltech.edu/bouguetj/calib_doc/

38

Page 38: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Application of calibration from planar grids• Today, there are thousands of application of this algorithm:

– Augmented reality

AR Tags: http://april.eecs.umich.edu/wiki/index.php/April_Tags 39

Page 39: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Application of calibration from planar grids

AR Tags: http://april.eecs.umich.edu/wiki/index.php/April_Tags

ETH, Pollefeys group, 2010RPG (us) 2013

• Today, there are thousands of application of this algorithm:

– Augmented reality

– Robotics (beacon-based localization)

• Do we need to know the metric size of the tag? – For Augmented Reality?

– For Robotics?

40

Page 40: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

If the camera is calibrated, only R and T need to be determined. In this case, should we use DLT (linear system of equations) or PnP (non linear)?

Lepetit, Moreno Noguer, Fua, EPnP: An Accurate O(n) Solution to the PnP Problem, IJCV’09

DLT vs PnP: Accuracy vs noise

41

Page 41: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

DLT vs PnP: Accuracy vs number of points

If the camera is calibrated, only R and T need to be determined. In this case, should we use DLT (linear system of equations) or PnP (non linear)?

Lepetit, Moreno Noguer, Fua, EPnP: An Accurate O(n) Solution to the PnP Problem, IJCV’0942

Page 42: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

DLT vs PnP: Timing

Lepetit, Moreno Noguer, Fua, EPnP: An Accurate O(n) Solution to the PnP Problem, IJCV’0943

Page 43: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

An Efficient Algebraic Solution to P3P

Similarly to Kneip (CVPR’11) and Maselli (ICPR’14), directly solve for the camera’s pose (not the distances).

1. Eliminate the camera’s position and the features’ distances to yield a system of 3 equations in the camera’s orientation alone.

2. Successively eliminate two of the unknown 3-DOFs (angles) algebraically and arrive at a quartic polynomial equation.

• Results: outperforms previous methods in terms of speed, accuracy, and robustness to close-to-singular cases.

• Available in OpenCV > 3.3. solvePnP() with SOLVEPNP_AP3P

3 points Pairwise subtraction and dot product

Ke and Roumeliotis (CVPR’17)

44

Page 44: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Outline of this lecture

• (Geometric) Camera calibration

– From 3D objects

– From planar grids

• Non conventional camera models

• Photometric Calibration

50

Page 45: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Omnidirectional Cameras

Rome, St. Peter’s square

51

Page 46: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Overview on Omnidirectional Cameras

Dioptric Catadioptric Polydioptric

~180º FOV

Wide FOV dioptric

cameras (e.g. fisheye)

>180º FOV

Catadioptric cameras (e.g.

cameras and mirror systems)

~360º FOV

Polydioptric cameras (e.g.

multiple overlapping cameras)

Omnidirectional sensors come in many varieties, but by definition must have a wide field-of-view.

52

Page 47: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Catadioptric Cameras

53

Page 48: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Nikon Coolpix

FC-E9 Lens

360º×183º

Canon EOS-1

Sigma Lens

360º×180º

Dioptric Cameras (fisheye)

54

Page 49: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Example:

http://rpg.ifi.uzh.ch/fov.htmlZ. Zhang et al. (RPG), Benefit of Large Field-of-View Cameras for Visual Odometry, ICRA 2016

Same scene viewed by three different camera models:

55

Page 50: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Applications

56

Page 51: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Applications

(Courtesy of Daimler)

• Daimler, Bosch: for car driving assistance systems

57

Page 52: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Applications

• Daimler, Bosch: for car driving assistance systems

• Meteorology: for sky observation

58

Page 53: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Applications

• Daimler, Bosch: for car driving assistance systems

• Meteorology: for sky observation

• Endoscopic Imagery: distortion removal (for the surgeon)

(Courtesy of Endo Tools Therapeutics, Brussels)

59

Page 54: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Applications

• Daimler, Bosch: for car driving assistance systems

• Meteorology: for sky observation

• Endoscopic Imagery: distortion removal (for the surgeon)

• RoboCup domain

60

Page 55: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Applications

• Daimler, Bosch: for car driving assistance systems

• Meteorology: for sky observation

• Endoscopic Imagery: distortion removal (for the surgeon)

• RoboCup domain

• Google Street View

61

Page 56: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

• mirror

• perspective camera

Catadioptric cameras

62

Page 57: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Camera Models

Central catadioptric cameras

• mirror

• camera

• single effective viewpoint

(surface of revolution of a conic)

Catadioptric cameras

63

Page 58: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

• hyperbola + perspective camera

• parabola + orthographic lens

Types of central catadioptric cameras

F1

F2

F1

Catadioptric cameras

64

Page 59: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

65

Why is it important that the camera be central (i.e., have a single effective viewpoint)?

• We can unwrap parts or all omnidirectional image into a perspective one

Page 60: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Why is it important that the camera be central (i.e., have a single effective viewpoint)?

66

• We can unwrap parts or all omnidirectional image into a perspective one

• We can transform image points into normalized vectors on the unit sphere

• We can apply standard algorithms valid for perspective geometry.

Page 61: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Omnidirectional camera calibration toolbox for Matlab (Scaramuzza, 2006)

• World’s standard toolbox for calibrating omnidirectional cameras (used at NASA, Daimler, IDS, Volkswagen, Audi, BOSCH, VW, Volvo, …)

• Main applications are in robotics, endoscopy, video-surveillance, sky observation, automotive (Audi, VW, Volvo, …)

• Since 2015, incorporated in the Matlab Computer Vision Toolbox: https://ch.mathworks.com/help/vision/ug/fisheye-calibration-basics.html

• Original url: https://sites.google.com/site/scarabotix/ocamcalib-toolbox

D. Scaramuzza, A. Martinelli, R. Siegwart, A toolbox for easily calibrating omnidirectional cameras, IEEE/RSJ International Conference on Intelligent Robots and Systems, 2006. PDF. 72

Page 62: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Equivalence between Perspective and Omnidirectional model

73

Page 63: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Equivalence between Perspective and Omnidirectional model

Measures the ray direction (angles).

74

Page 64: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Equivalence between Perspective and Omnidirectional model:the Spherical Model

Measures the ray direction (angles).

75

Page 65: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Representation of image points on the unit sphereAlways possible after the camera has been calibrated!

76

Page 66: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Outline of this lecture

• (Geometric) Camera calibration

– From 3D objects

– From planar grids

• Non conventional camera models

• Photometric Calibration

77

Page 67: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Photometric calibration

• Goal: Characterize how irradiance (light) is converted into pixel values.

• Photometric calibration involves:– Radiometric response function

– Vignetting

– Point spread function

Image acquisition pipeline

No vignetting Vignetting Vignetting Map

Debevec and Malik, SIGGRAPH '97

78

Page 68: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Radiometric Response Function

• Each camera has a different response function

CAVE Lab, Columbia University

Response function

Irradiance (E)In

ten

sity

(Z)

Irradiance (E)

Intensity(Z)

80

Page 69: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Summary (things to remember)

• P3P and PnP problems

• DLT algorithm

• Calibration from planar grid (Homography algorithm)

• Readings: Chapter 2.1 of Szeliski book

• Omnidirectional cameras

– Central and non central projection

– Dioptric

– Catadioptric (working principle of conic mirrors)

• Unified (spherical) model for perspective and omnidirectional cameras

• Reading: Chapter 4 of Autonomous Mobile Robots book

• Photometric calibration

83

Page 70: Lecture 03 Image Formation 2 - Davide Scaramuzzarpg.ifi.uzh.ch/docs/teaching/2018/03_image_formation_2.pdf · 2018-10-11 · Inscribed Angles are Equal q q q C C C A B 9. C A B C

Understanding Check

Are you able to:

• Describe the general PnP problem and derive the behavior of its solutions?

• Explain the working principle of the P3P algorithm?

• Explain and derive the DLT? What is the minimum number of point correspondences it requires?

• Define central and non central omnidirectional cameras?

• What kind of mirrors ensure central projection?

• What is photometric calibration?

84