Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu...

13
2. Camera Geometry 2. Camera Geometry Computer Vision Computer Vision Zoltan Zoltan Kato Kato http://www.inf.u http://www.inf.u http://www.inf.u - - - szeged.hu/~kato szeged.hu/~kato szeged.hu/~kato / / / Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - - CSC I6716 CSC I6716 2 Zoltan Zoltan Kato: Computer Vision Kato: Computer Vision Light (Energy) Source Surface Pinhole Lens Imaging Plane World Optics Sensor Signal Camera: Spec & Pose 3D Scene 2D Image Image Formation Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - - CSC I6716 CSC I6716 3 Zoltan Zoltan Kato: Computer Vision Kato: Computer Vision Pinhole Camera Model Pin-hole is the basis for most graphics and vision Derived from physical construction of early cameras Mathematics is very straightforward 3D World projected to 2D Image Image inverted, size reduced Image is a 2D plane: No direct depth information Perspective projection f called the focal length of the lens Pinhole lens Optical Axis f Image Plane Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - - CSC I6716 CSC I6716 4 Zoltan Zoltan Kato: Computer Vision Kato: Computer Vision Focal Length, Field Of View Consider case with object on the optical axis: Optical axis: the direction of imaging Image plane: a plane perpendicular to the optical axis Center of Projection (pinhole), focal point, viewpoint, nodal point Focal length: distance from focal point to the image plane FOV : Field of View – viewing angles in horizontal and vertical directions Increasing f will enlarge figures, but decrease FOV f z viewpoint Image plane f z Out of view

Transcript of Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu...

Page 1: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

2. Camera Geometry2. Camera Geometry

Computer VisionComputer Vision

ZoltanZoltan KatoKatohttp://www.inf.uhttp://www.inf.uhttp://www.inf.u---szeged.hu/~katoszeged.hu/~katoszeged.hu/~kato///

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 2

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Light (Energy) Source

Surface

Pinhole Lens

Imaging Plane

World Optics Sensor Signal

Camera: Spec & Pose

3D Scene

2D Image

Image Formation

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 3

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Pinhole Camera Model

• Pin-hole is the basis for most graphics and vision• Derived from physical construction of early cameras• Mathematics is very straightforward

• 3D World projected to 2D Image• Image inverted, size reduced• Image is a 2D plane: No direct depth information

• Perspective projection • f called the focal length of the lens

Pinhole lens

Optical Axis

f

Image Plane

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 4

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Focal Length, Field Of View• Consider case with object on the optical axis:

• Optical axis: the direction of imaging• Image plane: a plane perpendicular to the optical axis• Center of Projection (pinhole), focal point, viewpoint, nodal point• Focal length: distance from focal point to the image plane• FOV : Field of View – viewing angles in horizontal and vertical directions• Increasing f will enlarge figures, but decrease FOV

fzviewpoint

Image plane

fz

Out of view

Page 2: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 5

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Equivalent Geometry• Consider case with object on the optical axis:

fz

• More convenient with upright image:

fz

Projection plane z = f

• Equivalent mathematicallySlide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 6

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Perspective Projection• Compute the image coordinates of p in terms of the camera

coordinates of P.

• Origin of camera at center of projection• Z axis along optical axis• Image Plane at Z = f; x || X and y||Y

x

y

Z

P( X,Y,Z )p(x, y)

Z = f

C

Y

X

7

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

ZYfZXf

ZYX

a

=

10100

1ZYX

ff

ZfYfX

ZYX

a

Pinhole camera model

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 8

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Reverse Projection• Given a center of projection and image coordinates of a

point, it is not possible to recover the 3D depth of the point from a single image.

In general, at least two images of the same point taken from two different locations are required to recover depth.

All points on this linehave image coordi-nates (x,y).

p(x,y)

P(X,Y,Z) can be any-where along this line

Page 3: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 9

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Stereo Geometry

• Depth obtained by triangulation• Correspondence problem: pl and pr must

correspond to the left and right projections of P, respectively.

Object point

CentralProjection

Rays

Vergence Angle

pl pr

P(X,Y,Z)

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 10

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Amsterdam : what do you see in this picture?

●straight line

●size

●parallelism/angle

●shape

●shape of planes

●depth

Pinhole camera image

Phot

o by

Rob

ert

Phot

o by

Rob

ert K

osar

aKo

sara

, , rob

ert@

kosa

ra.n

etro

bert@

kosa

ra.n

etht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

lht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

l

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 11

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Pinhole camera imageAmsterdam

straight line

●size

●parallelism/angle

●shape

●shape of planes

●depth

Phot

o by

Rob

ert

Phot

o by

Rob

ert K

osar

aKo

sara

, , rob

ert@

kosa

ra.n

etro

bert@

kosa

ra.n

etht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

lht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

l

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 12

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Pinhole camera imageAmsterdam

straight line

×size

●parallelism/angle

●shape

●shape of planes

●depth

Phot

o by

Rob

ert

Phot

o by

Rob

ert K

osar

aKo

sara

, , rob

ert@

kosa

ra.n

etro

bert@

kosa

ra.n

etht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

lht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

l

Page 4: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 13

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Pinhole camera imageAmsterdam

straight line

×size

×parallelism/angle

●shape

●shape of planes

●depth

Phot

o by

Rob

ert

Phot

o by

Rob

ert K

osar

aKo

sara

, , rob

ert@

kosa

ra.n

etro

bert@

kosa

ra.n

etht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

lht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

l

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 14

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Pinhole camera imageAmsterdam

straight line

×size

×parallelism/angle

×shape

●shape of planes

●depth

Phot

o by

Rob

ert

Phot

o by

Rob

ert K

osar

aKo

sara

, , rob

ert@

kosa

ra.n

etro

bert@

kosa

ra.n

etht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

lht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

l

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 15

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Pinhole camera imageAmsterdam

straight line

×size

×parallelism/angle

×shape

●shape of planes

parallel to image

●depth

Phot

o by

Rob

ert

Phot

o by

Rob

ert K

osar

aKo

sara

, , rob

ert@

kosa

ra.n

etro

bert@

kosa

ra.n

etht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

lht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

l

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 16

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Pinhole camera image

- We see spatial shapes rather than individual pixels- Knowledge: top-down vision belongs to human- Stereo &Motion most successful in 3D CV & application- You can see it but you don't know how…

Amsterdam: what do you see?

straight line

×size

×parallelism/angle

×shape

●shape of planes

parallel to image

●Depth ? ●stereo ●motion●size●structure …

Phot

o by

Rob

ert

Phot

o by

Rob

ert K

osar

aKo

sara

, , rob

ert@

kosa

ra.n

etro

bert@

kosa

ra.n

etht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

lht

tp://

ww

w.k

osar

a.ne

t/gal

lery

/pin

hole

amst

erda

m/p

ic01

.htm

l

Page 5: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 17

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Camera Parameters

• Coordinate Systems• Frame coordinates (xim, yim) pixels• Image coordinates (x,y)• Camera coordinates (X,Y,Z)• World coordinates (Xw,Yw,Zw)

• Camera Parameters• Intrinsic Parameters (of the camera and the frame grabber):

link the frame coordinates of an image point with its corresponding camera coordinates

• Extrinsic parameters: define the location and orientation of the camera coordinate system with respect to the world coordinate system

Zw

Xw

Yw

Y

X

Zx

yC

Pw

P

p

xim

yim

(xim,yim)

Pose / Camera

Object / World

Image frame CCD

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 18

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

=

++

10100

1ZYX

ofsofs

ZZofYZofX

ZYX

yy

xx

y

x

a

Intrinsic Parameters (1)

• From frame to image • Image center • Directions of axes• Pixel size

• Intrinsic Parameters• (ox,oy): principal point (image center)• (sx,sy): effective size of the pixel• f: focal length

xim

yim

Pixel(xim,yim)Y

Z

X

x

y

C

p (x,y,f)

ox

oy

(0,0)Size:(sx,sy)

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 19

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Intrinsic Parameters (2)

• Lens Distortions • Modeled as simple radial distortions

• r2 = xd2+yd2

• (xd , yd) distorted points• k1 , k2: distortion coefficients

• A model with k2 =0 is still accurate for a CCD sensor of 500x500 with ~5 pixels distortion on the outer boundary

)1(

)1(4

22

1

42

21

rkrkyy

rkrkxx

d

d

++=

++=

(xd, yd)(x, y)k1 , k2

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 20

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Camera rotation and translation

• From World to Camera

• Extrinsic Parameters• A 3D translation vector, T, describing the relative locations of

the origins of the two coordinate systems • A 3x3 rotation matrix, R, an orthogonal matrix that brings the

corresponding axes of the two systems onto each other

Zw

Xw

Yw

Y

X

Zx

yC

PwP

p

xim

yim

(xim,yim)

TPRP w += T

IRRRRRR ===− TTT ei ..,1

Page 6: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

21

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

X10RCR

110

C~RRXcam

−=

−=

ZYX

( )[ ][ ]XC~|IKRx

X0|IKxC~-X~RX~

cam

cam

−==

=

[ ]T|RKP = C~RT −=PXx =

Extrinsic Parameters: [R|T]

C~ Projection center in world coordinate frame.

22

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

=

1yy

xx

pfpsf

K

[ ]C~-|IKRP =

non-singular

11 degree of freedom (5+3+3)

decompose P in K,R,C?

[ ]4p|MP = 41pMC~ −−=[ ] ( )MRK, RQ=

Projection center in world coordinate frame.{finite cameras}={P4x3 | det M≠0}If rank P=3, but rank M<3, then camera is at infinity

Finite projective camera

1 γ

arctan(1/s)

s skewfor CCD/CMOS, always s=0

C~

23

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Finding the camera center0PC = (use SVD to find null-space)

[ ]( )432 p,p,pdet=X [ ]( )431 p,p,pdet−=Y

[ ]( )421 p,p,pdet=Z [ ]( )321 p,p,pdet−=W

Finding the camera orientation and internal parameters

KRM = (use RQ decomposition ~QR)

Q R=( )-1= -1 -1QR

(if only QR, invert)

Camera matrix decomposition

Algebraically, C may be obtained as:

24

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

[ ] [ ]

=

0010

ppppp 43212

Image points corresponding to X,Y,Zdirections and origin (p4)

Column vectors

Page 7: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

25

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

=

1ppp

0 3

2

1

ZYX

yx

T

T

T

=

1ppp0

3

2

1

ZYX

wy

T

T

T

note: p1,p2 dependent on image reparametrization

Row vectors

26

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Affine cameras

Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision -- CSC I6716CSC I6716 27

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

Weak Perspective Projection• Average depth Z is much larger than the relative distance

between any two scene points measured along the optical axis

• A sequence of two transformations• Orthographic projection : parallel rays• Isotropic scaling : f/Z

• Linear Model• Preserve angles and shapes

YZfy

XZfx

=

=

x

y

Z

P(X,Y,Z)p(x, y)

Z = f

0

YX

28

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

=∞

ktt

y

x

/10rr

αP 2

2T1

1T (7 degrees of freedom)

Weak perspective projection

Page 8: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

29

ZoltanZoltan Kato: Computer VisionKato: Computer Vision

1. Affine camera=camera with principal plane coinciding with the plan at infinity Π∞

2. Affine camera maps parallel lines to parallel lines3. No center of projection, but direction of projection PAD=0

(point on Π∞ )

=

ktts

y

x

A/10

rr

αP 2

1T1

1T

(8dof)

=

1000P 2232221

1131211tmmmtmmm

A

[ ] [ ]affine 44100000100001

affine 33P ×

×=A

Affine camera

CS 395/495CS 395/495--25: Spring 200425: Spring 2004

IBMR: IBMR: RR33 RR22 and and PP33 PP22::

The Projective Camera MatrixThe Projective Camera Matrix

Jack TumblinJack [email protected]@cs.northwestern.edu

Slides adopted from:

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal Distance fFocal Distance f•• Camera Center CCamera Center C•• Principal PointPrincipal Point•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords (xCamera Coords (xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

yycc

zzcc

xxcc

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal Distance Focal Distance ff•• Camera Center CCamera Center C•• Principal PointPrincipal Point•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords (xCamera Coords (xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

ff

yycc

zzcc

xxcc

Page 9: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal Distance Focal Distance ff•• Camera Center Camera Center CC•• Principal PointPrincipal Point•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords (xCamera Coords (xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

ffCC

yycc

zzcc

xxcc

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal DistanceFocal Distance ff•• Camera Center Camera Center CC•• Principal Point Principal Point pp•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords (xCamera Coords (xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

ffCC

yycc

zzcc

xxcc

pp

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal Distance Focal Distance ff•• Camera Center Camera Center CC•• Principal PointPrincipal Point pp•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords (xCamera Coords (xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

ffCC

yycc

zzcc

xxcc

pp

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal DistanceFocal Distance ff•• Camera Center Camera Center CC•• Principal PointPrincipal Point pp•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords (xCamera Coords (xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

ffCC

yycc

zzcc

xxcc

pp

Page 10: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal DistanceFocal Distance ff•• Camera Center Camera Center CC•• Principal PointPrincipal Point pp•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords Camera Coords (x(xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

ffC =[0,0,0]C =[0,0,0]

yycc

zzcc

xxcc

pp

Cameras RevisitedCameras RevisitedPlenty of Terminology:Plenty of Terminology:•• Image Plane or Focal PlaneImage Plane or Focal Plane•• Focal DistanceFocal Distance ff•• Camera Center Camera Center CC•• Principal PointPrincipal Point pp•• Principal AxisPrincipal Axis•• Principal PlanePrincipal Plane•• Camera Coords (xCamera Coords (xcc,y,ycc,z,zcc))•• Image Coords (xImage Coords (x’’,y,y’’))

ffCC

yycc

zzcc

xxcc

pp

Cameras RevisitedCameras Revisited•• Goal: Formalize projective 3DGoal: Formalize projective 3D 2D mapping 2D mapping •• Homogeneous coords handles infinities well:Homogeneous coords handles infinities well:

–– Projective cameras ( convergent ‘eye’ rays)Projective cameras ( convergent ‘eye’ rays)–– Affine cameras (parallel ‘eye’ rays)Affine cameras (parallel ‘eye’ rays)–– Composed, controlled as matrix productComposed, controlled as matrix product

•• Recall Euclidian Recall Euclidian RR33 RR2 2 : : x’ = fx’ = f x / zx / zy’ = fy’ = f y / zy / z

(Much Better: P(Much Better: P33 PP22))

yyy’y’

ffzzCC

Basic Camera PBasic Camera P00: P: P33 PP22 ((oror camera camera RR33))•• Basic Camera PBasic Camera P0 0 is a 3x4 matrix:is a 3x4 matrix:

•• NonNon--square pixels? change scaling square pixels? change scaling ((ααxx, , ααyy))

•• Parallelogram pixels? set nonzero skew Parallelogram pixels? set nonzero skew ssK matrixK matrix: “(internal) camera : “(internal) camera calibcalib. matrix”. matrix”

xxyyzz

xxccyycczzcc11

==

PP00 X = xX = x

yyy’y’

ffzzCC

yycc

xxcc

zzcc

pp

ααxxff ss ppxx 000 0 ααyyff ppyy 000 0 0 0 11 00

KK(3x3 (3x3 submatrixsubmatrix))

[K 0] = P[K 0] = P00

Page 11: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

Complete Camera Matrix PComplete Camera Matrix P•• K matrixK matrix: “: “internalinternal camera camera calibcalib. matrix”. matrix”•• RR··T matrixT matrix: “: “externalexternal camera camera calibcalib. matrix” . matrix”

–– T matrix: Translate world to cam. originT matrix: Translate world to cam. origin–– R matrix: 3D rotate world to fit cam. axesR matrix: 3D rotate world to fit cam. axes

Combine: writeCombine: write(P(P00··RR··T)T)··X = xX = x

asasPP··X = xX = x

Output: Output: xx2D Camera Image 2D Camera Image

Input:Input: XX3D World Space 3D World Space

zz

yy

xx

XX(world space)(world space)

zz cc

yy cc

xx cc

CC

xx(c

amer

a sp

ace)

(cam

era

spac

e)

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

ColumnsColumns of P matrix = image of worldof P matrix = image of world--space axes: space axes:

•• pp11,p,p22,p,p33 == image of x,y,z axis vanishing points == image of x,y,z axis vanishing points –– Direction D = [1 0 0 0]Direction D = [1 0 0 0]TT = point on P= point on P33’’s xs x11 axis, at axis, at inifinityinifinity–– PD = 1PD = 1stst column of P = Pcolumn of P = P11. Repeat for y and z axes. . Repeat for y and z axes.

•• pp44 == image of the world== image of the world--space origin pt.space origin pt.–– Proof: let Proof: let DD = [0 0 0 1]T = direction to world origin= [0 0 0 1]T = direction to world origin–– PDPD = 4= 4thth column of column of PP = image of origin pt. = image of origin pt.

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

pp11 pp22 pp33 pp44

ff CC

yycc

zzcc

xxcc

pp

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

RowsRows of P matrix: camera planes in world spaceof P matrix: camera planes in world space•• row 1 = row 1 = PP1T1T = image x= image x--axis planeaxis plane•• row 2 = row 2 = PP2T2T = image y= image y--axis planeaxis plane•• row 1 = row 1 = PP3T3T = camera= camera’’s principal planes principal plane

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

PP1T1T

PP2T2T

PP3T3T

ff CC

yycc

zzcc

xxcc

pp

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

RowsRows of P matrix: planes in world spaceof P matrix: planes in world space•• row 1 = row 1 = PP11 = world plane whose image is x=0= world plane whose image is x=0•• row 2 = row 2 = PP22 = world plane whose image is y=0= world plane whose image is y=0•• row 3 = row 3 = PP33 = camera= camera’’s principal planes principal plane

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

PP1T1T

PP2T2T

PP3T3T

Why?Why? Recall that inRecall that in PP33, , point point XX is on plane is on plane ππif and only ifif and only if ππTT··X = 0X = 0, so, so……

ff CC

yycc

zzcc

xxcc

pp

Page 12: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

RowsRows of P matrix: planes in world spaceof P matrix: planes in world space•• row 1 = row 1 = PP11 == world plane whose image is x=0world plane whose image is x=0•• row 2 = row 2 = PP22 = world plane whose image is y=0= world plane whose image is y=0•• row 3 = row 3 = PP33 = camera= camera’’s principal planes principal plane

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

PP1T1T

PP2T2T

PP3T3T

ff CC

yycc

zzcc

xxcc

pp

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

RowsRows of P matrix: planes in world spaceof P matrix: planes in world space•• row 1 = row 1 = PP11 = image= image’’s x=0 planes x=0 plane•• row 2 = row 2 = PP22 = image= image’’s y=0 planes y=0 plane•• Careful!Careful! Shifting theShifting the

image origin by image origin by ppxx, , ppyyshifts the x=0,y=0 planes!shifts the x=0,y=0 planes!

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

ffCC

yycc

zzcc

xxcc

pp

PP1T1T

PP2T2T

PP3T3T

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

RowsRows of P matrix: planes in world spaceof P matrix: planes in world space•• row 1 = row 1 = PP11 = image= image’’s x=0 planes x=0 plane•• row 2 = row 2 = PP22 = image= image’’s y=0 planes y=0 plane•• row 3 = row 3 = PP33 = camera= camera’’s principal planes principal plane

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

ff CC

yycc

zzcc

xxcc

pp

PP1T1T

PP2T2T

PP3T3T

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

RowsRows of P matrix: planes in world spaceof P matrix: planes in world space•• row 1 = row 1 = PP11 = image x= image x--axis planeaxis plane•• row 2 = row 2 = PP22 = image y= image y--axis planeaxis plane•• row 3 = row 3 = PP33 = camera= camera’’s principal planes principal plane

–– principprincip. plane . plane PP33= = [p[p3131 pp3232 pp3333 pp3434]]TT

–– its normal direction: its normal direction: [p[p3131 pp3232 pp33 33 0 ]0 ]TT

–– Why is it normal? ItWhy is it normal? It’’s the worlds the world--space space PP33 direction of the direction of the zzcc axisaxis

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

ff CC

yycc

zzcc

xxcc

pp

Principal Principal plane Pplane P33

PP1T1T

PP2T2T

PP3T3T

Page 13: Pinhole Lens Computer Vision Zoltan Katokato/teaching/... · Slide adopted from Zhigang Zhu Computer Vision Slide adopted from Zhigang Zhu Computer Vision - CSC I6716 3 Zoltan Kato:

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

•• Principal Axis Vector (Principal Axis Vector (zzcc)) in in worldworld space:space:–– Normal of principal plane: = Normal of principal plane: = mm33 = = [p[p3131 pp3232 pp33 33 ]]TT

–– PP33 Scaling Scaling Ambiguous direction!! +/Ambiguous direction!! +/-- mm3 3 ? ? –– Solution: use Solution: use det(M)det(M)··mm33 as front of cameraas front of camera

•• Principal Point Principal Point p p in in imageimage space:space:–– image of (infinity point on image of (infinity point on zzcc axis = maxis = m33))

MM··mm33 = = pp = x= x0 0 ((ZissermanZisserman book renames p as xbook renames p as x00))CC

yycc

zzcc

xxcc

pp

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or PP ==•• •• •• •••• •• •• •••• •• •• ••

pp44

MM

mm11TT

mm22TT

mm33TT

xx00 ff••••••11

The Pieces of Camera Matrix The Pieces of Camera Matrix PP

Where is camera in Where is camera in worldworld space? at space? at C:C:•• Camera center Camera center CC is at is at cameracamera originorigin(x(xcc,y,ycc,z,zcc)=0=C)=0=C•• Camera Camera P P transforms worldtransforms world--space point space point CC to to C=0C=0•• But how do we find But how do we find C C ?? It is the Null Space of It is the Null Space of P :P :

P C = C = 0 P C = C = 0 (solve for C. SVD works, but here(solve for C. SVD works, but here’’s an easier way:)s an easier way:)

CameraCamera’’s Position in the World: s Position in the World: C = C =

xxccyycczzcc

xxwwyywwzzwwttww

==•• •• •• •••• •• •• •••• •• •• ••

PPPP··X = xX = x, or, or

~~ --MM--11··pp44

~~

~~

PP ==•• •• •• •••• •• •• •••• •• •• ••

MM

mm11TT

mm22TT

mm33TT

ff CC

yycc

zzcc

xxcc

pp

pp44

~~

~~

~~