11.1 Camera matrix - Carnegie Mellon School of Computer...

38
Camera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University

Transcript of 11.1 Camera matrix - Carnegie Mellon School of Computer...

Page 1: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Camera Matrix16-385 Computer Vision (Kris Kitani)

Carnegie Mellon University

Page 2: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

2D to 2D Transform (last session)

Page 3: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

3D object

2D to 2D Transform (last session)

3D to 2D Transform (today)

Page 4: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

A camera is a mapping between

the 3D world

and

a 2D image

Page 5: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

x = PXcamera matrix

3D world point

2D image point

What do you think the dimensions are?

A camera is a mapping between the 3D world and a 2D image

Page 6: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

x = PX2

4XYZ

3

5 =

2

4p1 p2 p3 p4p5 p6 p7 p8p9 p10 p11 p12

3

5

2

664

XYZ1

3

775

homogeneous world point

4 x 1

homogeneous image 3 x 1

Camera matrix 3 x 4

Page 7: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

camera center

Ximage plane

x

principal axis

The pinhole camera

x

y

z

z = f

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

principal point

Page 8: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

f

y

z

XY

Z

image plane

?

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

Page 9: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

f

y

z

XfY

ZY

Z

image plane

[X Y Z]> 7! [fX/Z fY/Z]>

Page 10: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

camera center

Ximage plane

x

principal axis

Pinhole camera geometry

x

y

z

z = f

x = PX

What is the camera matrix P for a pinhole camera model?

principal point

Page 11: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

2

4XYZ

3

5 =

2

4p1 p2 p3 p4p5 p6 p7 p8p9 p10 p11 p12

3

5

2

664

XYZ1

3

775

[X Y Z]> 7! [fX/Z fY/Z]>Relationship from similar triangles…

P =

2

4? ? ? ?? ? ? ?? ? ? ?

3

5

generic camera model

What does the pinhole camera model look like?

Page 12: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

P =

2

4f 0 0 00 f 0 00 0 1 0

3

5

What does the pinhole camera model look like?

2

4XYZ

3

5 =

2

4p1 p2 p3 p4p5 p6 p7 p8p9 p10 p11 p12

3

5

2

664

XYZ1

3

775

[X Y Z]> 7! [fX/Z fY/Z]>Relationship from similar triangles…

generic camera model

Page 13: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

P =

2

4f 0 0 00 f 0 00 0 1 0

3

5

Camera origin and image origin might be different

camera coordinate system

image coordinate system

CCD array

p

Page 14: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

P =

2

4f 0 p

x

00 f p

y

00 0 1 0

3

5

Accounts for different origins

camera coordinate system

image coordinate system

CCD array

p

Page 15: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

X world point

Ocamera

Oimage

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

x

image point

Page 16: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

X world point

Ocamera

Oimage

Oworld

In general, there are three different coordinate systems…

x

image point

so you need the know the transformations between them

Page 17: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

P =

2

4f 0 p

x

0 f py

0 0 1

3

5

2

41 0 0 00 1 0 00 0 1 0

3

5

P = K[I|0]

Can be decomposed into two matrices

K =

2

4f 0 p

x

0 f py

0 0 1

3

5 calibration matrix

(3 x 3) (3 x 4)

Page 18: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

P =

2

4f 0 p

x

0 f py

0 0 1

3

5

2

41 0 0 00 1 0 00 0 1 0

3

5

Assumes that the camera and world share the same coordinate system

What if they are different? How do we align them?

xc

yc

zc

zw

xw

yw

World coordinate system

Camera coordinate

system

Page 19: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

P =

2

4f 0 p

x

0 f py

0 0 1

3

5

2

41 0 0 00 1 0 00 0 1 0

3

5

Assumes that the camera and world share the same coordinate system

xc

yc

zc

zw

xw

yw

R tWorld coordinate system

Camera coordinate

system

3R rotation and translation to align axis

What if they are different? How do we align them?

Page 20: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

xc

yc

zc

zw

xw

yw

World coordinate system

Camera coordinate

system

Xw

Page 21: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

xc

yc

zc

zw

xw

yw

World coordinate system

Camera coordinate

system

Xw

C

Coordinate of the camera center in the

world coordinate frame

Page 22: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

xc

yc

zc

zw

xw

yw

World coordinate system

Camera coordinate

system

Xw

C

Coordinate of the camera center in the

world coordinate frame(Xw �C)

(Xw �C)Translate

Xc

Page 23: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

xc

yc

zc

zw

xw

yw

World coordinate system

Camera coordinate

system

Xw

Why aren’t the points aligned?

C

(Xw �C)Translate

Xc

Page 24: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

R(Xw �C)

What happens to points after alignment?

xc

yc

zc

zw

xw

yw

World coordinate system

Camera coordinate

system

Xw

C

R

XcRotate

TranslateRotate

Page 25: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Xc = R(Xw �C)

Optionally in homogeneous coordinates:

In inhomogeneous coordinates:

2

664

Xc

Yc

Zc

1

3

775 =

R �RC0 1

�2

664

Xw

Yw

Zw

1

3

775

General mapping of a pinhole camera

P = KR[I|�C]

(4⇥ 4)

Page 26: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

What is the meaning of each matrix of the camera matrix decomposition?

P = KR[I|�C]

3x3 intrinsics

Page 27: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

What is the meaning of each matrix of the camera matrix decomposition?

P = KR[I|�C]

3x3 intrinsics

3x3 3D rotation

Page 28: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

What is the meaning of each matrix of the camera matrix decomposition?

P = KR[I|�C]

3x3 intrinsics

3x3 3D rotation

3x3 identity

Page 29: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

What is the meaning of each matrix of the camera matrix decomposition?

P = KR[I|�C]

3x3 intrinsics

3x3 3D rotation

3x3 identity

3x1 3D translation

Page 30: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

General mapping of a pinhole camera

P = KR[I|�C]

Another way to write the mapping

t = �RCwhere

(translate first then rotate)

(rotate first then translate)

P = K[R|t]

Page 31: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

The camera matrix relates what two quantities?

Page 32: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

The camera matrix relates what two quantities?

x = PX

Page 33: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

The camera matrix relates what two quantities?

x = PX3D points to 2D image points

Page 34: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

The camera matrix relates what two quantities?

x = PX3D points to 2D image points

The camera matrix can be decomposed into?

Page 35: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

The camera matrix relates what two quantities?

x = PX3D points to 2D image points

The camera matrix can be decomposed into?

P = K[R|t]

Page 36: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Quiz

The camera matrix relates what two quantities?

x = PX3D points to 2D image points

The camera matrix can be decomposed into?

P = K[R|t]intrinsic and extrinsic parameters

Page 37: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

P =

2

4f 0 p

x

0 f py

0 0 1

3

5

2

4r1 r2 r3 t1r4 r5 r6 t2r7 r8 r9 t3

3

5

Generalized pinhole camera model

P = K[R|t]

R =

2

4r1 r2 r3r4 r5 r6r7 r8 r9

3

5 t =

2

4t1t2t3

3

5

extrinsic parametersintrinsic parameters

3D rotation 3D translation

Page 38: 11.1 Camera matrix - Carnegie Mellon School of Computer ...16385/s17/Slides/11.1_Camera_matrix.pdfCamera Matrix 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University. 2D

Why do we need P?

to properly relate world points to image points (by taking into account different coordinate systems)