computational photography and image manipulation cmpt ...yagiz/cpim/2019-cpim-11-camera...slide...

186
Computational Photography and Image Manipulation CMPT 469 / 985, Fall 2019 Week 11 Geometric camera models and calibration 1

Upload: others

Post on 07-Oct-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Computational Photography and Image ManipulationCMPT 469 / 985, Fall 2019

Week 11

Geometric camera models and calibration

1

Page 2: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Slide credits

• Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along with their acknowledgements.

2

Page 3: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

P10 papers – presentations on Nov 26, Tuesday

• Bai et al., Selectively De-Animating Video, SIGGRAPH 2012• Presentation:

• Discussion:

• Oh et al., Personalized Cinemagraphs using Semantic Understanding and Collaborative Learning, ICCV 2017

• Presentation:

• Discussion:

3

Page 4: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along
Page 5: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along
Page 6: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along
Page 7: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Motion

Figures from L. Zhang http://www.brainconnection.com/teasers/?main=illusion/motion-shape

Page 8: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Two cameras, simultaneous views Single moving camera and static scene

Stereo vision

Page 9: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Stereo Vision

Not that important for humans, especially at longer

distances. Perhaps 10% of people are stereo blind.

Many animals don’t have much stereo overlap in their fields

of view

Page 10: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Public Library, Stereoscopic Looking Room, Chicago, by Phillips, 1923

Page 11: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Teesta suspension bridge-Darjeeling, India

Page 12: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Woman getting eye exam during immigration procedure at Ellis

Island, c. 1905 - 1920 , UCR Museum of Phography

Page 13: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Mark Twain at Pool Table", no date, UCR Museum of Photography

Page 14: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Yes, you can be stereoblind.

Page 15: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Random dot stereograms

Julesz 1960:

Do we identify local brightness patterns before fusion (monocular

process) or after (binocular)?

Think Pair Share – yes / no? how to test?

Page 16: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Random dot stereograms

Julesz 1960:

Do we identify local brightness patterns before fusion (monocular

process) or after (binocular)?

To test: pair of synthetic images obtained by randomly spraying black dots

on white objects

Page 17: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Random dot stereograms

Forsyth & Ponce

Page 18: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Random dot stereograms

Page 19: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

1. Create an image of suitable size. Fill it with random dots. Duplicate the image.

2. Select a region in one image.

CC BY-SA 3.0, https://en.wikipedia.org/wiki/Random_dot_stereogram

3. Shift this region horizontally by a small amount. The stereogram is complete.

Page 20: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Random dot stereograms

When viewed monocularly, they appear random; when viewed

stereoscopically, see 3d structure.

Human binocular fusion not directly associated with the physical retinas;

must involve the central nervous system (V2, for instance).

Imaginary “cyclopean retina” that combines the left and right image stimuli

as a single unit.

High level scene understanding not required for stereo…but, high level

scene understanding is arguably better than stereo.

Page 21: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Stereo attention is weird wrt. mind’s eye

[Li Zhaoping, Understanding Vision]

Page 22: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Autostereograms – ‘Magic Eye’

Images from magiceye.com

Exploit disparity as

depth cue using single

image.

(Single image random

dot stereogram, Single

image stereogram)

Page 23: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along
Page 24: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along
Page 25: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along
Page 26: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Pinhole and lens cameras

Page 27: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The lens camera

Page 28: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The pinhole camera

Page 29: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The pinhole camera

Central rays propagate in the same way for both models!

Page 30: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Describing both lens and pinhole cameras

We can derive properties and descriptions that hold for both camera models if:• We use only central rays.• We assume the lens camera is in focus.

Page 31: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Important difference: focal length

focal length f

In a pinhole camera, focal length is distance between aperture and sensor

Page 32: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Important difference: focal lengthIn a lens camera, focal length is distance where parallel rays intersect

focal length f

focus distance D’

object distance D

Page 33: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Describing both lens and pinhole cameras

We can derive properties and descriptions that hold for both camera models if:• We use only central rays.• We assume the lens camera is in focus.• We assume that the focus distance of

the lens camera is equal to the focal length of the pinhole camera.

Remember: focal length f refers to different things for lens and pinhole cameras.• In this lecture, we use it to refer to the

aperture-sensor distance, as in the pinhole camera case.

Page 34: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Camera matrix

Page 35: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The camera as a coordinate transformation

A camera is a mapping from:

the 3D world

to:

a 2D image

3D object

2D image2D image

2D to 2D transform(image warping)

3D to 2D transform(camera)

Page 36: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The camera as a coordinate transformation

cameramatrix

3D world point

2D image point

What are the dimensions of each variable?

A camera is a mapping from:

the 3D world

to:

a 2D image

homogeneous coordinates

Page 37: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The camera as a coordinate transformation

homogeneousworld coordinates

4 x 1

homogeneousimage coordinates

3 x 1

cameramatrix3 x 4

Page 38: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The pinhole camera

real-world object

camera center

image plane

focal length f

Page 39: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The (rearranged) pinhole camera

real-world object

image plane

focal length fcamera center

Page 40: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The (rearranged) pinhole camera

camera center

image plane

principal axis

What is the equation for image coordinate x in terms of X?

Page 41: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The 2D view of the (rearranged) pinhole camera

What is the equation for image coordinate x in terms of X?

image plane

Page 42: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The 2D view of the (rearranged) pinhole camera

image plane

Page 43: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The (rearranged) pinhole camera

camera center

image plane

principal axis

What is the camera matrix P for a pinhole camera?

Page 44: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The pinhole camera matrix

Relationship from similar triangles:

General camera model:

What does the pinhole camera projection look like?

Page 45: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The pinhole camera matrix

Relationship from similar triangles:

General camera model:

What does the pinhole camera projection look like?

Page 46: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

world point

In general, the camera and image have different coordinate systems.

image point

Generalizing the camera matrix

Page 47: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Generalizing the camera matrix

How does the camera matrix change?

In particular, the camera origin and image origin may be different:

camera coordinate system

image coordinate system

image plane

Page 48: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Generalizing the camera matrix

How does the camera matrix change?

camera coordinate system

image coordinate system

image plane

In particular, the camera origin and image origin may be different:

shift vector transforming

camera origin to image origin

Page 49: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Camera matrix decomposition

We can decompose the camera matrix like this:

What does each part of the matrix represent?

Page 50: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Camera matrix decomposition

We can decompose the camera matrix like this:

(homogeneous) projection from 3D to 2D, assuming image plane at z = 1 and shared camera/image origin

(homogeneous) transformation from 2D to 2D, accounting for not

unit focal length and origin shift

Also written as: where

Page 51: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

world point

image point

We need to know the transformations between them.

Generalizing the camera matrix

In general, there are three, generally different, coordinate systems.

Page 52: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

World-to-camera coordinate system transformation

World

coordinate

system

Camera

coordinate

system

෩𝑿𝒘tilde means

heterogeneouscoordinates

Page 53: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

World-to-camera coordinate system transformation

World

coordinate

system

Camera

coordinate

system

Coordinate of the

camera center in the

world coordinate frame

෩𝑿𝒘

෩𝑪

Page 54: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

World-to-camera coordinate system transformation

World

coordinate

system

Camera

coordinate

system

Coordinate of the

camera center in the

world coordinate frame

෩𝑿𝒘

෩𝑪

෩𝑿𝒘 − ෩𝑪

Why aren’t the points aligned?

translate

Page 55: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

World-to-camera coordinate system transformation

World

coordinate

system

Camera

coordinate

system

points now coincide෩𝑿𝒘

෩𝑪

translate

𝑹 ⋅ ෩𝑿𝒘 − ෩𝑪rotate

Page 56: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Modeling the coordinate system transformation

In heterogeneous coordinates, we have:

How do we write this transformation in homogeneous coordinates?

෩𝐗𝐜 = 𝐑 ⋅ ෩𝐗𝐰 − ෨𝐂

Page 57: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Modeling the coordinate system transformation

In heterogeneous coordinates, we have:

In homogeneous coordinates, we have:

෩𝐗𝐜 = 𝐑 ⋅ ෩𝐗𝐰 − ෨𝐂

𝐗𝐜 =𝐑 −𝐑 ෨𝐂𝟎 1

𝐗𝐰or

Page 58: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Incorporating the transform in the camera matrixThe previous camera matrix is for homogeneous 3D coordinates in camera coordinate system:

𝐱 = 𝐏𝐗𝐜 = 𝐊 𝐈|𝟎 𝐗𝐜

We also just derived:

𝐗𝐜 =𝐑 −𝐑 ෨𝐂𝟎 1

𝐗𝐰

Page 59: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Putting it all together

We can write everything into a single projection:

extrinsic parameters (3 x 4): correspond to camera externals

(world-to-camera transformation)

𝐱 = 𝐏𝐗𝐰

The camera matrix now looks like:

intrinsic parameters (3 x 3): correspond to camera internals

(sensor not at f = 1 and origin shift)

Page 60: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

General pinhole camera matrix

We can decompose the camera matrix like this:

Another way to write the mapping:

where

(translate first then rotate)

(rotate first then translate)

Page 61: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

General pinhole camera matrix

extrinsic parameters

intrinsic parameters

3D rotation 3D translation

Page 62: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Recap

What is the size and meaning of each term in the camera matrix?

? ? ? ?

Page 63: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Recap

What is the size and meaning of each term in the camera matrix?

3x3 intrinsics

? ? ?

Page 64: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Recap

What is the size and meaning of each term in the camera matrix?

3x3 intrinsics

3x3 3D rotation

? ?

Page 65: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Recap

What is the size and meaning of each term in the camera matrix?

3x3 intrinsics

3x3 3D rotation

3x3 identity

?

Page 66: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Recap

What is the size and meaning of each term in the camera matrix?

3x3 intrinsics

3x3 3D rotation

3x3 identity

3x1 3D translation

Page 67: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Quiz

The camera matrix relates what two quantities?

Page 68: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Quiz

The camera matrix relates what two quantities?

homogeneous 3D points to 2D image points

Page 69: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Quiz

The camera matrix relates what two quantities?

homogeneous 3D points to 2D image points

The camera matrix can be decomposed into?

Page 70: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Quiz

The camera matrix relates what two quantities?

homogeneous 3D points to 2D image points

The camera matrix can be decomposed into?

intrinsic and extrinsic parameters

Page 71: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

More general camera matrices

The following is the standard camera matrix we saw.

Page 72: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

More general camera matrices

CCD camera: pixels may not be square.

How many degrees of freedom?

Page 73: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

More general camera matrices

CCD camera: pixels may not be square.

How many degrees of freedom?

10 DOF

Page 74: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

More general camera matrices

Finite projective camera: sensor be skewed.

How many degrees of freedom?

Page 75: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

More general camera matrices

Finite projective camera: sensor be skewed.

How many degrees of freedom?

11 DOF

Page 76: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Perspective distortion

Page 77: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Finite projective camera

What does this matrix look like if the camera and world have the

same coordinate system?

Page 78: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Finite projective camera

Perspective projection from (homogeneous) 3D to 2D coordinates

The pinhole camera and all of the more general cameras we have seen so far have “perspective distortion”.

Page 79: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The (rearranged) pinhole camera

camera center

image plane

principal axis

Perspective projection in 3D

Page 80: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The 2D view of the (rearranged) pinhole camera

image plane

Perspective distortion:

magnification changes with

depth

Perspective projection in 2D

Page 81: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Forced perspective

Page 82: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Other camera models

Page 83: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

What if…

real-world object

depth Z focal length f

… we continue increasing Z and f while maintaining

same magnification?

𝑓 → ∞ and𝑓

𝑍= constant

Page 84: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

camera is closeto object and hassmall focal length

camera is far from object and has

large focal length

Page 85: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Different cameras

perspective camera weak perspective camera

Page 86: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Weak perspective vs perspective camera

image plane

magnification changes with depth

• magnification does not change with depth

• constant magnification depending on f and Zo

𝑍𝑜

Page 87: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Comparing camera matricesLet’s assume that the world and camera coordinate systems are the same.

• The perspective camera matrix can be written as:

• What would the matrix of the weak perspective camera look like?

Page 88: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Comparing camera matricesLet’s assume that the world and camera coordinate systems are the same.

• The perspective camera matrix can be written as:

• The weak perspective camera matrix can be written as:

Page 89: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Comparing camera matricesLet’s assume that the world and camera coordinate systems are the same.

• The finite projective camera matrix can be written as:

• The affine camera matrix can be written as:

where we now have the more general intrinsic matrix

In both cameras, we can incorporate extrinsic parameters same as we did before.

Page 90: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

When can we assume a weak perspective camera?

Page 91: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

When can we assume a weak perspective camera? 1. When the scene (or parts of it) is very far away.

Weak perspective projection applies to the mountains.

Page 92: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

When can we assume a weak perspective camera? 2. When we use a telecentric lens.

object distance D focal length f

sensor distance D’

Place a pinhole at focal length, so that only rays

parallel to primary ray pass through.

What is the magnification factor in this

case?

Page 93: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

When can we assume a weak perspective camera? 2. When we use a telecentric lens.

object distance D focal length f

sensor distance D’

Place a pinhole at focal length, so that only rays

parallel to primary ray pass through.

𝑚 =𝐷′ − 𝑓

𝑓

• magnification is constant with depth

• remember that focal length f refers to different things in pinhole and lens cameras

Page 94: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Orthographic cameraSpecial case of weak perspective camera where:• constant magnification is equal to 1.• there is no shift between camera and image origins.• the world and camera coordinate systems are the same.

image world

What is the camera matrix in this case?

Page 95: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Orthographic cameraSpecial case of weak perspective camera where:• constant magnification is equal to 1.• there is no shift between camera and image origins.• the world and camera coordinate systems are the same.

image world

Page 96: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Orthographic projection using a telecentric lensHow do we make the telecentric lens act as an orthographic camera?

object distance D focal length f

sensor distance D’

Page 97: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Orthographic projection using a telecentric lensHow do we make the telecentric lens act as an orthographic camera?

object distance D focal length f

sensor distance D’

𝐷′ = 2𝑓

We set the sensor distance as:

in order to achieve unit magnification.

Page 98: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Geometric camera calibration

Page 99: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Given a set of matched points

and camera model

Find the (pose) estimate of

parametersprojection model

point in 3D space

point in the image

Camera matrix

Geometric camera calibration

We’ll use a perspective camera model for pose estimation

Page 100: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Same setup as homography estimation(slightly different derivation here)

Page 101: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Mapping between 3D point and image points

What are the unknowns?

Page 102: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Heterogeneous coordinates

(non-linear relation between coordinates)

Mapping between 3D point and image points

How can we make these relations linear?

Page 103: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Make them linear with algebraic manipulation…

Now we can setup a system of linear equations with

multiple point correspondences

How can we make these relations linear?

Page 104: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

How do we proceed?

Page 105: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

In matrix form …

How do we proceed?

Page 106: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

In matrix form …

For N points …

How do we solve

this system?

Page 107: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Solve for camera matrix by

SVD!

Page 108: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Solve for camera matrix by

Solution x is the column of V

corresponding to smallest singular

value of

Page 109: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Solve for camera matrix by

Equivalently, solution x is the

Eigenvector corresponding to

smallest Eigenvalue of

Page 110: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Are we done?

Now we have:

Page 111: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

How do you get the intrinsic and extrinsic

parameters from the projection matrix?

Almost there …

Page 112: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Decomposition of the Camera Matrix

Page 113: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Decomposition of the Camera Matrix

Page 114: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Decomposition of the Camera Matrix

Page 115: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Decomposition of the Camera Matrix

Find the camera center C Find intrinsic K and rotation R

What is the projection of the

camera center?

Page 116: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Decomposition of the Camera Matrix

Find the camera center C Find intrinsic K and rotation R

How do we compute the

camera center from this?

Page 117: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

SVD of P!

c is the Eigenvector corresponding to

smallest Eigenvalue

Decomposition of the Camera Matrix

Find the camera center C Find intrinsic K and rotation R

Page 118: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

SVD of P!

c is the Eigenvector corresponding to

smallest Eigenvalue

Decomposition of the Camera Matrix

Find the camera center C Find intrinsic K and rotation R

Any useful properties of K

and R we can use?

Page 119: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

SVD of P!

c is the Eigenvector corresponding to

smallest Eigenvalue

Decomposition of the Camera Matrix

Find the camera center C Find intrinsic K and rotation R

right upper

triangleorthogonal

How do we find K

and R?

Page 120: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

QR decomposition

SVD of P!

c is the Eigenvector corresponding to

smallest Eigenvalue

Decomposition of the Camera Matrix

Find the camera center C Find intrinsic K and rotation R

Page 121: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Given a set of matched points

and camera model

Find the (pose) estimate of

parametersprojection

model

point in 3D

space

point in the

image

Camera

matrix

Geometric camera calibration

We’ll use a perspective camera

model for pose estimation

Where do we get these

matched points from?

Page 122: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Calibration using a reference object

Issues:

• must know geometry very accurately

• must know 3D->2D correspondence

Place a known object in the scene:

• identify correspondences between image and scene

• compute mapping from scene to image

Page 123: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

For these reasons, nonlinear methods are preferred

• Define error function E between projected 3D points and image positions

– E is nonlinear function of intrinsics, extrinsics, radial distortion

• Minimize E using nonlinear optimization techniques

Advantages:

• Very simple to formulate.

• Analytical solution.

Disadvantages:

• Doesn’t model radial distortion.

• Hard to impose constraints (e.g., known f).

• Doesn’t minimize the correct error function.

Geometric camera calibration

Page 124: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

P1

Pi

(ui,vi)

(u1,v1)

MPi

2

3

2

2

3

1

−+

i

ii

i

ii

Pm

Pmv

Pm

Pmu

Minimizing reprojection error

Page 125: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Radial distortion

no distortion barrel distortion pincushion distortion

What causes this distortion?

Page 126: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Radial distortion model

Page 127: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

P1

Pi

(ui,vi)

(u1,v1)

MPi

Minimizing reprojection error with radial distortion

Add distortions to reprojection error:

𝑢𝑖 −1

λ

𝑚1 ⋅ 𝑃𝑖𝑚3 ⋅ 𝑃𝑖

2

+ 𝑣𝑖 −1

λ

𝑚2 ⋅ 𝑃𝑖𝑚3 ⋅ 𝑃𝑖

2

Page 128: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Correcting radial distortion

before after

Page 129: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Advantages:

• Only requires a plane

• Don’t have to know positions/orientations

• Great code available online!

– Matlab version: http://www.vision.caltech.edu/bouguetj/calib_doc/index.html

– Also available on OpenCV.

Disadvantage: Need to solve non-linear optimization problem.

Alternative: Multi-plane calibration

Page 130: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Step-by-step demonstration

Page 131: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Step-by-step demonstration

Page 132: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Step-by-step demonstration

Page 133: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Step-by-step demonstration

Page 134: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Step-by-step demonstration

Page 135: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

What does it mean to “calibrate a camera”?

Page 136: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

What does it mean to “calibrate a camera”?

Many different ways to calibrate a camera:

• Radiometric calibration.

• Color calibration.

• Geometric calibration.

• Noise calibration.

• Lens (or aberration) calibration.

Page 137: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

References

Basic reading:• Szeliski textbook, Section 2.1.5, 6.2.• Bouguet, “Camera calibration toolbox for Matlab,” available at

http://www.vision.caltech.edu/bouguetj/calib_doc/The main resource for camera calibration in Matlab, where the screenshots in this lecture were taken from. It also has a detailed of the camera calibration algorithm and an extensive reference section.

Additional reading:• Hartley and Zisserman, “Multiple View Geometry in Computer Vision,” Cambridge University Press 2004.

Chapter 6 of this book has a very thorough treatment of camera models.• Gortler, “Foundations of 3D Computer Graphics,” MIT Press 2012.

Chapter 10 of this book has a nice discussion of pinhole cameras from a graphics point of view.• Zhang, “A flexible new technique for camera calibration,” PAMI 2000.

The paper that introduced camera calibration from multiple views of a planar target.

Page 138: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

16.11.2019

139

Motion and perceptual organization

[‘Gestalt’ Laws of PerceptionWertheimer 1923Koffka 1935]

Page 139: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

140

Optical Flow: Where do pixels move to?

Page 140: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Motion is a basic cue

Motion can be the only cue for segmentation

141Some slides from Luc Van Gool

Page 141: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Motion is a basic cue

Even “impoverished” motion data can evoke a strong perception

G. Johansson, “Visual Perception of Biological Motion and a Model For Its Analysis", Perception

and Psychophysics 14, 201-211, 1973.

Page 142: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Motion is a basic cue

Even impoverished motion data can elicit a strong percept

143G. Johansson, “Visual Perception of Biological Motion and a Model For Its Analysis", Perception and Psychophysics

14, 201-211, 1973.

Page 143: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

144

Applications

• tracking

• structure from motion

• motion segmentation

• stabilization

• compression

• Mosaicing

• …

Page 144: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

145

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 145: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Definition of Optical Flow

146

OPTICAL FLOW = apparent motion of

brightness patterns

Ideally, the optical flow is the projection of the three-

dimensional velocity vectors on the image

Page 146: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

16.11.2019

147

Optical Flow – What is it anyways?

𝑣1

𝑣2𝑣3

𝑣4

𝑝1

𝑝2𝑝3

𝑝4

𝐼 𝑡 , {𝑝𝑖}

𝐼 𝑡 + 1𝐼 𝑡 + 1

Velocity vectors {𝑣𝑖}

Page 147: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

• Projection of the 3D scene motion into the image

Motion field

16.11.2019

148

Page 148: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

• 𝑿(𝑡) is a moving 3D point

• Velocity of scene point: 𝑽 =𝑑𝑿

𝑑𝑡

• 𝒙(𝑡) = (𝑥(𝑡), 𝑦(𝑡)) is the projection of 𝑿 in the image

• Apparent velocity 𝒗 in the image: given by 𝑣𝑥 =𝑑𝑥

𝑑𝑡and 𝑣𝑦 =

𝑑𝑦

𝑑𝑡

• These components are known as the motion field and flow field of the image

Motion field and optical flow

𝑥(𝑡)

𝑥(𝑡 + 𝑑𝑡)

𝑋(𝑡)𝑋(𝑡 + 𝑑𝑡)

𝑉

𝑣

16.11.2019

149

Page 149: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

• Image motion is a function of both the 3D motion (V) and thedepth of the 3D point (Z)

• Objects closer to the camera appear to move faster than objects further away

16.11.2019

150

Motion field and parallax

𝑥(𝑡)

𝑥(𝑡 + 𝑑𝑡)

𝑋(𝑡)𝑋(𝑡 + 𝑑𝑡)

𝑉

𝑣

Y(𝑡)Y(𝑡 + 𝑑𝑡)

𝑉

y(𝑡)

y(𝑡 + 𝑑𝑡)

Page 150: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Caution required

151

Two examples :

1. Uniform, rotating sphere

O.F. = 0

2. No motion, but changing lighting

O.F. 0

Page 151: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Caution required

152

Page 152: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Estimating optical flow

• Given two subsequent frames, estimate the apparent motion field u and v between them

153

I(x,y,t–1) I(x,y,t)

• Key assumptions• Brightness constancy: projection of the same point looks the same in

every frame

• Small motion: points do not move very far

• Spatial coherence: points move like their neighbors

Page 153: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The brightness constancy constraint

Brightness Constancy Equation (Optical Flow Equation):

154

I(x,y,t–1) I(x,y,t)

𝐼 𝑥, 𝑦, 𝑡 − 1 = 𝐼(𝑥 + 𝑢, 𝑦 + 𝑣, 𝑡)

Page 154: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The optical flow constraint

155

• Smoothness assumptions allows to linearize the right side using

Taylor series expansion:

𝐼 𝑥, 𝑦, 𝑡 − 1 ≈ 𝐼 𝑥, 𝑦, 𝑡 − 1 +𝜕𝐼

𝜕𝑥𝛿𝑥 +

𝜕𝐼

𝜕𝑦𝛿𝑦 +

𝜕𝐼

𝜕𝑡𝛿𝑡 + 𝑒

• With very small 𝛿𝑡:𝜕𝐼

𝜕𝑥

𝑑𝑥

𝑑𝑡+𝜕𝐼

𝜕𝑦

𝑑𝑦

𝑑𝑡+𝜕𝐼

𝜕𝑡≈ 0

0++ tyx IvIuI

Shorthand: 𝐼𝑥 =𝜕𝐼

𝜕𝑥, 𝐼𝑦 =

𝜕𝐼

𝜕𝑦, 𝐼𝑡 =

𝜕𝐼

𝜕𝑡= 0 and 𝑢 =

𝑑𝑥

𝑑𝑡, 𝑣 =

𝑑𝑦

𝑑𝑡

𝐼 𝑥, 𝑦, 𝑡 − 1 = 𝐼(𝑥 + 𝑢, 𝑦 + 𝑣, 𝑡)

Page 155: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

156

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 156: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The aperture problem

157

0 =++ tyx IvIuI

1 equation in 2 unknowns

=dt

dxu

dt

dyv =

=

y

II x

=

y

II y

t

II t

=

Page 157: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

158

The aperture problem

0

Page 158: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Aperture problem and Normal Flow

159

Page 159: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

The aperture problem

160

Page 160: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Remarks

161

Page 161: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

162

What is Optic Flow, anyway?

• Estimate of observed projected motion field• Not always well defined!• Compare:

• Motion Field (or Scene Flow)projection of 3-D motion field

• Normal Flowobserved tangent motion

• Optic Flowapparent motion of the brightness pattern(hopefully equal to motion field)

• Consider Barber pole illusion

Page 162: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

16.11.2019

163

Barber pole illusion

http://en.wikipedia.org/wiki/Barberpole_illusion

Page 163: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

16.11.2019

164

Barber pole illusion – aperture shape

Page 164: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

16.11.2019

165

Barber Pole Illusion – Aperture Shape – Cont’d

Page 165: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

166

Page 166: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

167

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• Direct depth

• SSD tracking

• Robust flow

• Bayesian flow

Page 167: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Horn & Schunck algorithm

168

Additional smoothness constraint :

,))()(( 2222 dxdyvvuue yxyxs +++=

besides OF constraint equation term

,)( 2dxdyIvIuIe tyxc ++=

minimize es+ec

Page 168: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Horn & Schunck

169

The Euler-Lagrange equations :

0

0

=

=

yx

yx

vvv

uuu

Fy

Fx

F

Fy

Fx

F

In our case ,

,)()()( 22222

tyxyxyx IvIuIvvuuF ++++++=

so the Euler-Lagrange equations are

,)(

,)(

ytyx

xtyx

IIvIuIv

IIvIuIu

++=

++=

2

2

2

2

yx

+

= is the Laplacian operator

Page 169: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Horn & Schunk

170

Remarks :

1. Coupled PDEs solved using iterative

methods and finite differences

2. More than two frames allow a better

estimation of It

3. Information spreads from corner-type

patterns

,)(

,)(

ytyx

xtyx

IIvIuIvt

v

IIvIuIut

u

++−=

++−=

Page 170: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Horn & Schunk, remarks

171

1. Errors at boundaries

2. Example of regularisation

(selection principle for the solution of

illposed problems)

Page 171: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

172

Results of an enhanced system

Page 172: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

173

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• SSD tracking

• Bayesian flow

Page 173: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

• How to get more equations for a pixel?

• Spatial coherence constraint: assume the pixel’s neighbors have the same displacement vector (u,v)

• If we use a 5x5 window, that gives us 25 equations per pixel

Solving the aperture problem

B. Lucas and T. Kanade. An iterative image registration technique with an application to

stereo vision. In Proceedings of the International Joint Conference on Artificial

Intelligence, pp. 674–679, 1981.

16.11.2019

174

Page 174: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

• Least squares problem:

Solving the aperture problem

• When is this system solvable?

• What if the window contains just a single straight edge?

16.11.2019

175

Page 175: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

• Linear least squares problem

Lucas-Kanade flow

The summations are over all pixels in the window

Solution given by

16.11.2019

176

Page 176: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Lucas-Kanade flow

16.11.2019

177

When is this solvable?• ATA should be invertible

• ATA should not be too small

– eigenvalues 1 and 2 of ATA should not be too small

• ATA should be well-conditioned

– 1/ 2 should not be too large (1 = larger eigenvalue)

Page 177: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Uniform region

– gradients have small magnitude

– small 1, small 2

– system is ill-conditioned

16.11.2019

178

Page 178: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Edge

– gradients have one dominant direction

– large 1, small 2

– system is ill-conditioned

16.11.2019

179

Page 179: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

High-texture or corner region

– gradients have different directions, large magnitudes

– large 1, large 2

– system is well-conditioned

16.11.2019

180

Page 180: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

• The motion is large (larger than a pixel)• Iterative refinement

• Coarse-to-fine estimation

• Exhaustive neighborhood search (feature matching)

• A point does not move like its neighbors• Motion segmentation

• Brightness constancy does not hold• Exhaustive neighborhood search with normalized correlation

Errors in Lucas-Kanade

16.11.2019

181

Page 181: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Lucas-Kanade flow

16.11.2019

182

When is this solvable?• ATA should be invertible

• ATA should not be too small

– eigenvalues 1 and 2 of ATA should not be too small

• ATA should be well-conditioned

– 1/ 2 should not be too large (1 = larger eigenvalue)

Corners and textured areas are OK:

KLT feature tracker:see “Good Features to Track”, Shi and Tomasi, CVPR'94, 1994, pp. 593 - 600.

Page 182: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along
Page 183: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

184

Optical Flow

• Brightness Constancy

• The Aperture problem

• Regularization

• Lucas-Kanade

• Coarse-to-fine

• Parametric motion models

• SSD tracking

• Bayesian flow

Page 184: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

185

Page 185: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along

Reduce Resolution

186

Page 186: Computational Photography and Image Manipulation CMPT ...yagiz/cpim/2019-CPIM-11-Camera...Slide credits •Slides thanks to Ioannis Gkioulekas, James Tompkin, and Marc Pollefeys along