69
Camera Models CS535 Fall 2021 Daniel G. Aliaga Department of Computer Science Purdue University

Sea of Images

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Sea of Images

Camera Models

CS535 Fall 2021

Daniel G. Aliaga Department of Computer Science

Purdue University

Page 2: Sea of Images

Our (3D) World…

Page 3: Sea of Images

What makes it 3D?

• Depth (…illusion)

Page 4: Sea of Images

Human Eye

Page 5: Sea of Images

Thin Lens System

Page 6: Sea of Images

Pinhole Camera Model

pinhole image plane

object

d f

Page 7: Sea of Images

Biology 101

• Not all animals have the same vision hardware… – e.g., certain insects, crustaceans (e.g., lobster)

• Diurnal Insect Vision

• Nocturnal Insect Vision

• Crustacean Vision

Page 8: Sea of Images

Optics: Terminology

• Dioptric

– All elements are refractive (lenses)

• Catoptric

– All elements are reflective (mirrors)

• Catadioptric

– Elements are refractive and reflective (mirrors + lenses)

Page 9: Sea of Images

Thin Lens Equation

f

do

di

object

plane

image

plane

focal point

fdd i

111

0

Page 10: Sea of Images

Thin Lens Equation

• What happens if image plane is not at the focal point (distance)?

Page 11: Sea of Images

Digression: Deblurring

Page 12: Sea of Images

Digression: Deblurring

[Chan et al., IEEE IP 2011]

Page 13: Sea of Images

Digression: Synthetic Focusing • Ray tracing:

• Lightfield:

– http://lightfield.stanford.edu/aperture.swf?lightfield=data/chess_lf/preview.zip&zoom=1

• Lytro Camera:

– http://lightfield.stanford.edu/aperture.swf?lightfield=data/chess_lf/preview.zip&zoom=1

Page 14: Sea of Images

Digression: Non-Pinhole Camera Models…

• Why restrict the camera to a pinhole camera model?

– Aperture is large: lightfields/lumigraphs

– Multi-perspective imaging

– Sample-based camera

– Tailored camera designs

• Occlusion-resistant cameras (kinda…)

• Graph cameras

• and more!

[switch to non-standard…]

Page 15: Sea of Images

Pinhole Camera Model

object

image

plane f

Z

(X, Y, Z)

(x, y)

x = f X

Z

y = f Y

Z

Page 16: Sea of Images

“Computer Graphics” Pinhole Camera Model

eye

image plane object

d f

Page 17: Sea of Images

f Z x = f X

Z

y = f Y

Z

3D Perspective Projection

(X, Y, Z) f

image plane eye/viewpoint

(x, y)

z

optical axis

Z

Y y?

y = Y &

Page 18: Sea of Images

Example OpenGL Rendering

• Perspective is “mathematically” accurate…

Page 19: Sea of Images

(3D) Perception

• There is lot more to it…

Page 20: Sea of Images

Perception

• Size-distance relationship

– Same size object at two distances…

Page 21: Sea of Images
Page 22: Sea of Images
Page 23: Sea of Images

Perception

• Importance of ground plane, shadows…

Page 24: Sea of Images

Perception

• Alto Relief

• Sunken Relief

Page 25: Sea of Images

(Relief Images)

• We will see this type of things later…

Page 26: Sea of Images

Perception: Bas-Relief

Page 27: Sea of Images

Perception: Bas-Relief

Page 28: Sea of Images

Perception: Bas Relief Ambiguity

𝑁𝐿𝑇 = 𝐶

or

𝑁𝑅𝑅𝑇𝐿𝑇 = 𝐶 𝑁𝐺𝐺−1𝐿𝑇 = 𝐶

??

Page 29: Sea of Images

Perception: Inconsistencies

• Escher

Page 30: Sea of Images

Perception: Nekker Cube

Page 31: Sea of Images

Perception: Nekker Cube

Page 32: Sea of Images

Perception: Muller-Lyer Illusion

Page 33: Sea of Images

Perception: Muller-Lyer Illusion

Page 34: Sea of Images

Perception: Muller-Lyer Illusion

Page 35: Sea of Images

35

Perspective Camera Parameters

• Intrinsic/Internal

– Focal length

– Principal point (center)

– Pixel size

– (Distortion coefficients)

• Extrinsic/External

– Rotation

– Translation

,,

f

yx pp ,

,...1k

yx ss ,

zyx ttt ,,

Page 36: Sea of Images

36

Perspective Camera Parameters

,,

f

zyx ttt ,,

(=middle of image)

(=1, irrelevant)

(=0, assuming no bugs )

• Intrinsic/Internal

– Focal length

– Principal point (center)

– Pixel size

– (Distortion coefficients)

• Extrinsic/External

– Rotation

– Translation

Page 37: Sea of Images

f Z x = f X

Z

y = f Y

Z

Recall: 3D Perspective Projection

(X, Y, Z) f

image plane eye/viewpoint

(x, y)

z

optical axis

Z

Y y?

y = Y &

Page 38: Sea of Images

Matrix Encoding

• How do we put the perspective divide process into the matrix pipeline?

Page 39: Sea of Images

Focal Length

10100

000

000

Z

Y

X

f

f

Z

fY

fX

ZfY

ZfX

/

/

y

x

Page 40: Sea of Images

Principal Point

10100

00

00

Z

Y

X

pf

pf

Z

ZpfY

ZpfX

y

x

y

x

0

0

y

x

Page 41: Sea of Images

CCD Camera: Pixel Size

0100

00

00

100

00

00

y

x

y

x

pf

pf

s

s

P

0100

00

00

yy

xx

p

p

P

Projection matrix

In graphics, often

1 yx ss0 yx pp

Page 42: Sea of Images

Translation & Rotation

1

10

tR~

Z

Y

X

xc

)~

(~ CXRxc

RCXRxc ~~

t

zyx RRRR

3x3 rotation matrices

Tzyx tttt

translation vector World-to-camera matrix M

Page 43: Sea of Images

Perspective Projection Process

• Given

…the perspective projection is

1

~

Z

Y

X

X

1

~

Z

Y

X

PMxp

zpyp

zpxp

xx

xx

y

x~/~

~/~

Page 44: Sea of Images

Projection Matrices

Page 45: Sea of Images

4x4 Matrices

• How do we encode into 4x4 matrix/vector multiplication pipeline?

Page 46: Sea of Images

Projection Matrices

0100

00

000

000

nffn

n

n

Page 47: Sea of Images

Projection Matrices

• To map [-1,+1] to viewing frustum (l,r,b,t,n,f):

1000

)/()()/(200

)/()(0)/(20

)/()(00)/(2

fnfnfnn

btbtbtn

lrlrlrn

Page 48: Sea of Images

Projection Transformations

void glFrustum(GLdouble left, GLdouble right, GLdouble

bottom, GLdouble top, GLdouble near, GLdouble far);

Page 49: Sea of Images

Projection Transformations

void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble

near, GLdouble far);

Page 50: Sea of Images

Projection Transformations

void glOrtho(GLdouble left, GLdouble right, GLdouble

bottom,

GLdouble top, GLdouble near, GLdouble far);

void gluOrtho2D(GLdouble left, GLdouble right,

GLdouble bottom, GLdouble top);

Page 51: Sea of Images

OpenGL Equivalent

glMatrixMode(GL_PROJECTION);

gluPerspective(60, 1.0, 0.1, 1000.0);

glMatrixMode(GL_MODELVIEW);

glTranslatef(tx,ty,tz);

glRotatef(rx,1,0,0);

glRotatef(ry,0,1,0);

glRotatef(rz,0,0,1);

/* or glLoadMatrixf(mat); */

Page 52: Sea of Images

OpenGL Note

• OpenGL is row major and left-multiplies

• This means from the previous (more intuitive explanation) the actual matrix is the transpose of what I wrote; e.g.

• Also, the order of multiplication is from most recent matrix command to least recent matrix command; e.g.

– “glRotate(rx,1,0,0); glRotate(ry,0,1,0)” rotates a vertex about the y-axis and then the x-axis

TOpenGL MM

Page 53: Sea of Images

Producing a 3D World

• Camera

– Zero lens model (i.e., no lens)

– Thin lens model

– Thick lens model

Page 54: Sea of Images

f Z x = f X

Z

y = f Y

Z

(Zero Lens) Perspective Projection

(X, Y, Z) f

image plane eye/viewpoint

(x, y)

z

optical axis

Z

Y y?

y = Y &

Page 55: Sea of Images

Producing a 3D World

• Camera

– Zero lens model (i.e., no lens)

– Thin lens model

– Thick lens model

Page 56: Sea of Images

Thin Lens Camera Model

f

do

di

object

plane

image

plane

focal point

fdd i

111

0

Page 57: Sea of Images

Lens Aberrations

• A “real” lens system does not produce a perfect image

• Aberrations are caused by imperfect manufacturing and by our approximate models

– Lenses typically have a spherical surface • Aspherical lenses would better compensate for refraction but are

more difficult to manufacture

– Typically 1st order approximations are used

• Remember sin = - 3/3! + 5/5! - …

• Thus, thin-lens equations only valid iff sin

Page 58: Sea of Images

Aberrations

• Most common aberrations:

– Spherical aberration

– Coma

– Astigmatism

– Curvature of field

– Chromatic aberration

– Distortion

Page 59: Sea of Images

• Deteriorates axial image

Spherical Aberration

Page 60: Sea of Images

Coma

• Deteriorates off-axial bundles of rays

Page 61: Sea of Images

• Produces multiple (two) images of a single object point

Astigmatism and Curvature of Field

Page 62: Sea of Images

Chromatic Aberration

• Caused by wavelength dependent refraction

– Apochromatic lenses (e.g., RGB) can help

Page 63: Sea of Images

Distortion

• Radial (and tangential) image distortions

Example radial distortions

Page 64: Sea of Images

Radial Distortion

• (x, y) pixel before distortion correction

• (x’, y’) pixel after distortion correction

• Let r = (x2 + y2) -1

• Then

– x’ = x(1 - r/r)

– y’ = y(1 - r/r)

– where r = k0r + k1r3 + k2r5 + …

• Finally, – x’ = x(1 – k0 – k1r2 – k2r4 - …)

– y’ = y(1 – k0 – k1r2 – k2r4 - …)

Page 65: Sea of Images

Radial Distortion

before after

Page 66: Sea of Images

Tsai Camera Model and Calibration

• A widely used camera model to calibrate conventional cameras based on a pinhole camera

• Reference

– “A Versatile Camera Calibration Technique for High-Accuracy 3D Machine Vision Metrology Using Off-the-Shelf TV Cameras and Lenses”, Roger Y. Tsai, IEEE Journal of Robotics and Automation, Vol. 3, No. 4, August 1987

Page 67: Sea of Images

Producing a 3D World

• Camera

– Zero lens model (i.e., no lens)

– Thin lens model

– Thick lens model

Page 68: Sea of Images

Thick Lens Camera Model

• http://www.cabrillo.edu/~jmccullough/Applets/optics.html

• Even more parameters…

Page 69: Sea of Images

Thick Lens Camera Model

• A simplification for 4x4 matrix usage

z P P’

z’

t

f’

[Kolb et al. 1995]