67
Computer Vision I - Geometry of Two Cameras Carsten Rother Computer Vision I: Image Formation Process 22/12/2014

Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Computer Vision I -Geometry of Two Cameras

Carsten Rother

Computer Vision I: Image Formation Process

22/12/2014

Page 2: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

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)

22/12/2014 2Computer Vision I: Image Formation Process

Page 3: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Camera intrinsic parameters - Summary

• Intrinsic parameters

• Principal point coordinates (𝑝𝑥, 𝑝𝑦)

• Focal length 𝑓

• Pixel y-direction magnification factors 𝑚

• Skew (non-rectangular pixels) 𝑠

22/12/2014Computer Vision I: Image Formation Process 3

𝑥𝑦1

= 𝑓 𝑠 𝑝𝑥0 𝑚𝑓 𝑝𝑦0 0 1

𝑋𝑌𝑍

calibration matrix 𝑲

The Mapping: 𝒙 = 𝑲 𝑿 (here 𝑿 means inhomogeneous coordinates)~ ~

Image 3D world point

𝑓

Page 4: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Putting the camera into the world

22/12/2014Computer Vision I: Image Formation Process 4

Given a 3D homogenous point 𝑿𝒘in world coordinate system

1) Translate from world to camera coordinate system:𝑿𝒄′ = 𝑿𝒘 − 𝑪𝑿𝒄′ = (𝑰𝟑×𝟑 | − 𝑪) 𝑿𝒘 where 𝑰𝟑×𝟑 is 3x3 identity matrix

2) Rotate world coordinate system into camera coordinate system𝑿𝒄 = 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿𝒘

3) Apply camera matrix𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿

World coordinate system

camera coordinate system

~

~

~~

~

~

~~

𝑿𝒘

𝟑 × 𝟒 matrix

Page 5: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Camera matrix

• Camera matrix 𝑷 is defined as:

𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿

• In short we write: 𝒙 = 𝑷 𝑿

• The camera center is the (right) nullspace of 𝑷

𝑷 𝑪 = 𝑲𝑹 (𝑪 − 𝑪) = 0

22/12/2014Computer Vision I: Image Formation Process 5

~

𝑷 𝟑 × 𝟒 camera matrix has 11 DoF

~~

Comment: The right nullspace is the vector 𝑿 that satisfies: 𝟎 = 𝑷 𝑿

Page 6: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Camera parameters - Summary

• Camera matrix P has 11 DoF

• Intrinsic parameters

• Principal point coordinates (𝑝𝑥, 𝑝𝑦)

• Focal length 𝑓

• Pixel y-direction magnification factors 𝑚

• Skew (non-rectangular pixels) 𝑠

• Extrinsic parameters

• Rotation 𝑹 (3DoF) and translation 𝐂 (3DoF) relative to world coordinate system

22/12/2014Computer Vision I: Image Formation Process 6

𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿~

~

𝑲 =𝑓 𝑠 𝑝𝑥0 𝑚𝑓 𝑝𝑦0 0 1

𝒙 = 𝑷 𝑿

Page 7: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Orthographic Projection

• Distance from center of projection to image plane is infinite(infinite focal length)

• Also called “parallel projection”

• Most simple from of projection

22/12/2014Computer Vision I: Image Formation Process 7

𝑥𝑦1

= 1 0 0 00 1 0 00 0 0 1

𝑋𝑌𝑍1

(very large focal length)

(normal focal length)

Page 8: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Affine cameras• Most general camera that does parallel projection is:

• Parallel lines map to parallel lines (since points at infinity stay)

• Affine cameras simplify 3D reconstruction task, hence good to get an approximate solution

• See more details in: HZ (Hartley, Zissermann) chapter 6.3

22/12/2014Computer Vision I: Image Formation Process 8

𝑥𝑦1

= 𝑎 𝑏 𝑐 𝑑𝑒 𝑓 𝑔 ℎ0 0 0 1

𝑋𝑌𝑍𝑤

𝑥𝑦0

= 𝑎 𝑏 𝑐 𝑑𝑒 𝑓 𝑔 ℎ0 0 0 1

𝑋𝑌𝑍0

Page 9: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

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)

22/12/2014 9Computer Vision I: Image Formation Process

Page 10: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Home-made pinhole camera

22/12/2014Computer Vision I: Image Formation Process 10

http://www.debevec.org/Pinhole/

Why so blurry?

Page 11: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Shrinking the aperture

22/12/2014Computer Vision I: Image Formation Process 11

Why not make the aperture as small as possible?• Less light gets through• Diffraction effects…

Page 12: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Shrinking the aperture

22/12/2014Computer Vision I: Image Formation Process 12

Diffraction effects. Noise due to long exposure

Page 13: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Adding a lens

• A lens focuses light onto the film

• Lets enough ligh through

• Rays passing through the center are not deviated

22/12/2014Computer Vision I: Image Formation Process 13

Page 14: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

In Focus

22/12/2014Computer Vision I: Image Formation Process 14

• There is a specific distance at which objects are “in focus”

• other points project to a “circle of confusion” in the image

• By moving the distance between film and lens we control

what is in focus (this distance is related to the focal length)

Page 15: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Depth of Field

22/12/2014Computer Vision I: Image Formation Process 15

Page 16: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Focal point in real camera

• All parallel rays converge to one point on a plane located at the focal length f

22/12/2014Computer Vision I: Image Formation Process 16

Page 17: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Control the depth of field

Changing the aperture size affects depth of field

• A smaller aperture increases the range in which the object is approximately in focus (but longer exposure needed)

22/12/2014Computer Vision I: Image Formation Process 17

Page 18: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Field of View

22/12/2014Computer Vision I: Image Formation Process 18

Page 19: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Field of View / Focal Length

22/12/2014Computer Vision I: Image Formation Process 19

Close to affine camera (look at front light)

Page 20: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Same effect for faces

22/12/2014Computer Vision I: Image Formation Process 20

Small 𝑓 Large 𝑓

Page 21: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Lens Flaws: Chromatic Aberration

22/12/2014Computer Vision I: Image Formation Process 21

High quality lens (top)

low quality lens (bottom)blur + green edges

Purple fringing

Lens has different refractive indices for differentwavelengths: causes color fringing

Page 22: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Lens flaws: Vignetting

22/12/2014Computer Vision I: Image Formation Process 22

Page 23: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Lens distortion

• Caused by imperfect lenses

• Deviations are most noticeable for rays that pass through the edge of the lens

22/12/2014Computer Vision I: Image Formation Process 23

Page 24: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

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)

22/12/2014 24Computer Vision I: Image Formation Process

Page 25: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

The up-coming 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)

22/12/2014Computer Vision I: Two-View Geometry 25

Page 26: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Singular Value Decomposition (SVD)

• Reminder: separable filters

22/12/2014Computer Vision I: Two-View Geometry 26

Apply SVD to the kernel matrix:

If all 𝜎𝑖 are 0 (apart from 𝜎0) then it is separable.

Note:ℎ𝑥 ∗ ℎ𝑦

ℎ𝑥ℎ𝑥ℎ𝑦

ℎ𝑦

[page 585ff in Hartley Zisserman]

p-1

Page 27: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Properties of SVD

22/12/2014Computer Vision I: Two-View Geometry 27

• In short: 𝐴 = 𝑈𝐷𝑉𝑇

• If 𝐴 = 𝑚 × 𝑛 with 𝑚 ≥ 𝑛 then 𝑈 = 𝑚 × 𝑛 , D = n × 𝑛, 𝑉 = 𝑛 × 𝑛

• If 𝐴 = 𝑚 × 𝑛 with 𝑚 < 𝑛 then add zero-valued rows to A to make it 𝑛 × 𝑛

• 𝑈 and 𝑉 form an orthogonal basis: 𝑈𝑇𝑈 = 𝑉𝑇𝑉 = 𝑈𝑈𝑇 = 𝑉𝑉𝑇 = 𝐼𝑛×𝑛

• It is: 𝑈𝑥 = 𝑉𝑇𝑥 = 𝑥 (an example U is a rotation matrix)

• Implementation: 𝐴 = 𝑚 × 𝑛 needs: 4𝑚2𝑛 + 8𝑚𝑛2 + 9𝑛3 [Golub-89]

• It is: 𝐴𝑇𝐴 = 𝑉𝐷𝑈𝑇𝑈𝐷𝑉𝑇 = 𝑉𝐷2𝑉𝑇

then the entries of 𝐷2are eigenvalues of 𝐴𝑇𝐴 and eigenvectors are columns of 𝑉

Singular values; sorted: 𝜎𝑖 ≥ 𝜎𝑖+1

Page 28: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

SVD and Null space• Right null space: 𝐴 𝒙 = 𝟎 where 𝐴 = 𝑚 × 𝑛 with 𝑚 < 𝑛

this is given by the (n-m) last row vectors in 𝑉𝑇

22/12/2014Computer Vision I: Robust Two-View Geometry 28

• Example:

A =

1

2

1

2

−1

2−1

2

1

2

1

2

Then SVD is:

1

2

1

√2

−1

2−1

2

1

√2

1

2

0 0 0

=

1

√2

1

√20

−1

√2

1

√20

0 0 1

1 0 00 1 00 0 0

1

√20

−1

√2

0 1 0−1

√20

−1

√2

1

√20

−1

√20 1 00 0 0

𝒙 = 𝜆

−1

√2

0

−1

√2

= 𝜆

1

0

1

Nullspace

and 𝐴𝑥 = 0

• Left null space: 𝒙𝐴 = 𝟎 where 𝐴 = 𝑚 × 𝑛 with 𝑚 < 𝑛 this is given by the (n-m) last column vectors in 𝑈

Page 29: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Least Square Problem (homogenous linear system)

22/12/2014Computer Vision I: Two-View Geometry 29

• Find a solution to 𝐴𝒙 = 0 where 𝐴 = 𝑚 × 𝑛 with 𝑚 ≥ 𝑛

• Solution 𝒙 = 0 is not interesting

• If 𝒙 is solution then any 𝑘𝒙. So we look for 𝒙 = 1

• 𝐴𝒙 = 0 is never exactly zero (due to noise in measurements).

Hence, solve in least square sense:

𝒙∗ = 𝑎𝑟𝑔𝑚𝑖𝑛𝒙 𝐴𝒙 subject to 𝒙 = 𝟏

• 𝒙∗ is the last row of 𝑉𝑇, where 𝐴 = 𝑈𝐷𝑉𝑇

Page 30: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Proof

22/12/2014Computer Vision I: Two-View Geometry 30

Page 31: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Topic 1: Homography 𝐻

• 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 𝐻 ?

22/12/2014Computer Vision I: Two-View Geometry 31

Page 32: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Definition Homography

22/12/2014Computer Vision I: Two-View Geometry 32

• Definition: A projectivity (or homography) ℎ is an invertible mapping ℎ from 𝑃2 to 𝑃2 such that three points 𝑥1, 𝑥2, 𝑥3 lie on the same line if an only if ℎ(𝑥1), ℎ(𝑥2), ℎ(𝑥3) do.

• Theorem: A mapping ℎ from 𝑃2 to 𝑃2 is a homography if and only if there exists a non-singular 3 × 3 matrix H with ℎ(𝑥) = 𝐻𝑥

• In equations: x′ = 𝐻𝑥

• 𝐻 has 8 DoF

𝑥𝑦1

Transformation matrix 𝐻

ℎ11 ℎ12 ℎ13ℎ21 ℎ22 ℎ23ℎ31 ℎ32 ℎ33

𝑥′𝑦′1

=

Page 33: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Geometric Derivation: Homography

22/12/2014Computer Vision I: Two-View Geometry 33

𝑥𝑦1

Transformation matrix 𝐻

ℎ11 ℎ12 ℎ13ℎ21 ℎ22 ℎ23ℎ31 ℎ32 ℎ33

𝑥′𝑦′1

=

Cast shadowRotating camera

Mapping via a plane

Page 34: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Notation: x (homogenous 2D), x (inhomogenous 2D), 𝑿 (homogenous 3D), 𝑿(inhomogenous 3D)

Homography from a rotating camera

22/12/2014Computer Vision I: Image Formation Process 34

Put it toghter: 𝒙𝟏 = 𝑲𝟏𝑹𝑲𝟎−𝟏𝒙𝟎

Hence 𝑯 = 𝑲𝟏𝑹𝑲𝟎−𝟏 is a homography (general 3x3 matrix) with 8 DoF

~

𝑲 =𝑓 𝑠 𝑝𝑥0 𝑚𝑓 𝑝𝑦0 0 1

𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿

Camera 0: 𝒙𝟎 = 𝑲𝟎 𝑿 (in 3D ∶ 𝑲𝟎−𝟏𝒙𝟎 = 𝑿)

Camera 1: 𝒙𝟏 = 𝑲𝟏 𝑹 𝑿

~

~

~

~

~

Page 35: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Homography of a projection via a plane

22/12/2014Computer Vision I: Two-View Geometry 35

(See geometric derivation on page 49)

Definition: A projectivity (or homography) ℎ is an invertible mapping ℎ from 𝑃2 to 𝑃2 such that three points 𝑥1, 𝑥2, 𝑥3 lie on the same line if an only if ℎ(𝑥1), ℎ(𝑥2), ℎ(𝑥3) do so.

We know (see Theorem): All Homographies can be written as ℎ(𝑥) = 𝐻𝑥

We see visually that lines map to lines

So we can write: 𝑥2 = 𝐻𝑥1

Page 36: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

How to compute/calibrate 𝐻

• We have 𝜆𝑥′ = 𝐻𝑥

• H has 8 DoF

• We get for each pair of matching points (𝑥′, 𝑥) the 3 equations:

1) ℎ11𝑥1 + ℎ12𝑥2 + ℎ13𝑥3 = 𝜆𝑥1′

2) ℎ21𝑥1 + ℎ22𝑥2 + ℎ23𝑥3 = 𝜆𝑥2′

• Eliminate 𝜆. This gives 2 linear independent equations be taking the ratios.

Here 1) divide by 2) gives:

22/12/2014Computer Vision I: Two-View Geometry 36

3) ℎ31𝑥1 + ℎ32𝑥2 + ℎ33𝑥3 = 𝜆𝑥3′

𝑥1𝑥2′ , 𝑥2𝑥2

′ , 𝑥3𝑥2′ , −𝑥1𝑥1

′ , −𝑥2𝑥1′ , −𝑥3𝑥1

′ ℎ11, ℎ12, ℎ13, ℎ21, ℎ22, ℎ23𝑇 = 0

Page 37: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

How to compute/calibrate 𝐻

22/12/2014Computer Vision I: Two-View Geometry 37

ℎ11ℎ12ℎ13ℎ21ℎ22ℎ23ℎ31ℎ32ℎ33

= 0

• Put it together:

• We need a minimum of 4 points to get 𝐴ℎ = 0 with 𝐴 𝑖𝑠 8 × 9 matrix, and ℎ 𝑖𝑠 9 × 1 vector

• Solution for ℎ is the right null space of 𝐴

𝑥1𝑥2′ 𝑥2𝑥2

′ 𝑥3𝑥2′ −𝑥1𝑥1

′ −𝑥2𝑥1′ −𝑥3𝑥1

′ 0 0 0

0 0 0 𝑥1𝑥3′ 𝑥2𝑥3

′ 𝑥3𝑥3′ −𝑥1𝑥2

′ −𝑥2𝑥2′ −𝑥3𝑥2

.

.

.

Page 38: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Often we have many, slightly wrong point-matches

22/12/2014Computer Vision I: Two-View Geometry 38

image

Algorithm: 1) Take 𝑚 ≥ 4 point matches (𝑥, 𝑥’)2) Assemble A with Ah = 03) compute 𝒉∗ = 𝑎𝑟𝑔𝑚𝑖𝑛ℎ 𝐴𝒉 subject to 𝒉 = 𝟏,

use SVD to do this.

We know how to do: 𝒙∗ = 𝑎𝑟𝑔𝑚𝑖𝑛𝒙 𝐴𝒙 subject to 𝒙 = 𝟏

Page 39: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

A more numerically stable solution

22/12/2014Computer Vision I: Two-View Geometry 39

• Coefficients of an equation system should be in the same order ofmagnitude so as not to lose significant digits

• In pixels: 𝑥𝑎𝑥𝑏 ’ ~ 1𝑒6

• Conditioning: scale and shift points to be in [-1..1] (or +/- √2 )

• A general rule, not only for homography computation

• How to do it:

Page 40: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

A more numerically stable solution

22/12/2014Computer Vision I: Two-View Geometry 40

Algorithm: 1) Take 𝑚 ≥ 4 point matches (𝑥, 𝑥’)2) Compute 𝑇, and condition points: 𝑥𝑛 = 𝑇𝑥; 𝑥𝑛’ = 𝑇’𝑥’3) Assemble 𝐴 with 𝐴𝒉 = 04) compute 𝒉∗ = 𝑎𝑟𝑔𝑚𝑖𝑛ℎ 𝐴𝒉 subject to 𝒉 = 𝟏,

use SVD to do this. 4) Get 𝐻 of unconditioned points: 𝑇′−1𝐻𝑇 (Note: 𝑇′𝑥′ = 𝐻𝑇𝑥)

[See HZ page 109]

Page 41: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Motivation for next lecture

22/12/2014Computer Vision I: Two-View Geometry 41

Question 1: If a match is completly wrong then is a bad idea

Question 2: If a match is slighly wrong then might not be perfect.Better might be a geometric error:

𝑎𝑟𝑔𝑚𝑖𝑛ℎ 𝐴𝒉

𝑎𝑟𝑔𝑚𝑖𝑛ℎ 𝐴𝒉𝑎𝑟𝑔𝑚𝑖𝑛ℎ 𝑯𝑥 − 𝑥′

Page 42: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Can we get 𝐾’𝑠 and 𝑅 from 𝐻?

• Assume we have 𝐻 = 𝐾1𝑅𝐾0−1of a rotating camera,

can we get out 𝐾1, 𝑅, 𝐾0 ?

• 𝐻 has 8 DoF

• 𝐾1, 𝑅, 𝐾0 have together 13 DoF

• Not directly possible, only with assumptions on K. (No application needs such a decomposition)

• For other transfromations such decompositions are possible

22/12/2014Computer Vision I: Two-View Geometry 42

Page 43: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

What can we do with 𝐻?

• Panoramic stitching with rotating camera (exercise later)

22/12/2014Computer Vision I: Two-View Geometry 43

Warp images into a canonical view: 𝑥′ = 𝐻𝑥

Page 44: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

What can we do with 𝐻?

22/12/2014Computer Vision I: Two-View Geometry 44

Page 45: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

What can we do with 𝐻?

• Plane-based augmented realty

22/12/2014Computer Vision I: Two-View Geometry 45

[Graz University]

The figure appears to stand on the board. For this the mapping between the board and the image plane is needed.

Page 46: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

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

22/12/2014Computer Vision I: Two-View Geometry 46

Page 47: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Halfway

3 Minutes Break

Question?

22/12/2014Computer Vision I: Image Formation Process 47

Page 48: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Topic 2: Camera Matrix P

• 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 𝑃?

22/12/2014Computer Vision I: Two-View Geometry 48

Page 49: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Geometric Derivation: Camera Matrix (Reminder)

22/12/2014Computer Vision I: Image Formation Process 49

• Camera matrix P has 11 DoF

• Intrinsic parameters

• Principal point coordinates (𝑝𝑥, 𝑝𝑦)

• Focal length 𝑓

• Pixel magnification factors 𝑚

• Skew (non-rectangular pixels) 𝑠

• Extrinsic parameters

• Rotation 𝑹 (3DoF) and translation 𝐂 (3DoF) relative to world coordinate system

𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿~

~

𝑲 =𝑓 𝑠 𝑝𝑥0 𝑚𝑓 𝑝𝑦0 0 1

𝒙 = 𝑷 𝑿

Page 50: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

How can we compute/calibrate 𝑃?

22/12/2014Computer Vision I: Two-View Geometry 50

𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿

𝒙 = 𝑷 𝑿

Important move in all directions: 𝑥, 𝑦, 𝑧

Calibration pattern

~

Page 51: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

How can we compute/calibrate 𝑃?

• We have 𝜆𝑥′ = 𝑃𝑋

• 𝑃 has 11 DoF

• We get for each point pair (𝑥′, 𝑋) 3 equations, but only 2 linear independent once, by taking ration (to get rid of 𝜆)

• We need a minimum of 6 Points to get 12 equations

22/12/2014Computer Vision I: Two-View Geometry 51

Algorithm (DLT - Direct Linear Transform): 1) Take 𝑚 ≥ 6 points. 2) Condition points 𝑋, 𝑥′ using 𝑇, 𝑇′3) Assemble 𝐴 with 𝐴𝑝 = 0 (𝐴 𝑖𝑠 𝑚 × 12 and 𝑝 is vectorized 𝑃) 4) compute 𝑝∗ = 𝑎𝑟𝑔𝑚𝑖𝑛𝑝 𝐴𝑝 subject to 𝑝 = 1

use SVD to do this. 5) Get out unconditioned 𝑃 = 𝑇′−1𝑃𝑇 (note 𝑇’𝑥’ = 𝑃 𝑇𝑋)

[See extended version: HZ page 181]

Note: a version with minimal number of points (6) is same as with many points

Page 52: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

• Assume 𝑃 is known, can we get out 𝐾, 𝑅, 𝐶?

• P has 11 DoF

• 𝐾, 𝑅, 𝐶 have together 5+3+3=11 DoF(so it is possible)

• How to do it:

1) The camera center 𝐶 is the right nullspace of P

𝑃𝐶 = 𝐾 𝑅 (𝐶 − 𝐶) = 0

2) 𝑃 = [𝐾𝑅| − 𝐾𝑅𝐶];

𝐴 = 𝐾𝑅can be done with unique 𝑅𝑄 decomposition, where 𝑅 is upper-triangular matrix and 𝑄 a rotation matrix (see HZ page 579)

How can we get K,R,C from P

22/12/2014Computer Vision I: Two-View Geometry 52

𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿~𝒙 = 𝑷 𝑿

~

~

~

~

~

~

~

Page 53: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

What can we do with 𝑃?

• Many things can be done with an externally and internally calibrated camera

• Robot navigation, augmented reality, photogrammetry …

22/12/2014Computer Vision I: Two-View Geometry 53

camera

Manipulator

Page 54: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

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, …)

22/12/2014Computer Vision I: Two-View Geometry 54

𝒙 = 𝑲 𝑹 (𝑰𝟑×𝟑 | − 𝑪) 𝑿~𝒙 = 𝑷 𝑿

Page 55: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

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 𝐹/𝐸?

22/12/2014Computer Vision I: Two-View Geometry 55

Page 56: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Reminder: Matching two Images

22/12/2014Computer Vision I: Image Formation Process 56

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 defines how other 3D points match between 2 views!

Page 57: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

3D Geometry

22/12/2014Computer Vision I: Two-View Geometry 57

Non-moving scene

𝑃’

Rigidly (6D) moving scene

Both cases are equivalent for the following derivations

Page 58: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Epipolar Geometry

22/12/2014Computer Vision I: Two-View Geometry 58

Page 59: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Epipolar Geometry

22/12/2014Computer Vision I: Two-View Geometry 59

Page 60: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Epipolar Geometry

22/12/2014Computer Vision I: Two-View Geometry 60

Page 61: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Epipolar Geometry

22/12/2014Computer Vision I: Two-View Geometry 61

• Epipole: Image location of the optical center of the other camera.

(Can be outside of the visible area)

Page 62: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Epipolar Geometry

22/12/2014Computer Vision I: Two-View Geometry 62

Epipolar plane: Plane through both camera centers and world point.

Page 63: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Epipolar Geometry

22/12/2014Computer Vision I: Two-View Geometry 63

• Epipolar line: Constrains the location where a particular point (here 𝑝1) from

one view can be found in the other.

Page 64: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Epipolar Geometry

22/12/2014Computer Vision I: Two-View Geometry 64

• Epipolar lines:• Intersect at the epipoles

• In general not parallel

Page 65: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Example: Converging Cameras

22/12/2014Computer Vision I: Two-View Geometry 65

Page 66: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Example: Motion Parallel to Camera

22/12/2014Computer Vision I: Two-View Geometry 66

• We will use this idea when it comes to stereo matching

Page 67: Computer Vision I - Geometry of Two Camerasds24/lehre/cv1_ws_2014/... · 2020-01-24 · Putting the camera into the world Computer Vision I: Image Formation Process 22/12/2014 4 Given

Example: Forward Motion

22/12/2014Computer Vision I: Two-View Geometry 67

• Epipoles have same coordinate in both images

• Points move along lines radiating from epipole“focus of expansion”