Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

34
Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra

Transcript of Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Page 1: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Projective Geometry and Camera Models

ENEE 731 Image Understanding Kaushik Mitra

Page 2: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Camera

– 3D to 2D mapping

– 2D to 3D mapping

Page 3: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Preliminaries

• Projective geometry– Projective spaces (P2)– Homogenous coordinates– Projective transformations (Homography)

Page 4: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Why Projective Geometry?• Parallel lines converge to a point

• 2D -2D transformation– Projective transformation (Homography)

Page 5: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Projective space P2

• Projective space: set of points– Each point is a line in R3 passing through origin

• Motivated from camera geometry

• Alternative way– P=(x,y,z) and P’=(x’,y’,z’) equivalent if and only if P=λP’

• λ ≠ 0

Page 6: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

P2=R2 U P1

• (x, y, z) ≈ (λx, λy, λz)• P2 can be divided into two subsets

– Points with z ≠ 0– Points with z= 0

• If z ≠ 0, (x, y, z) ≈ (x/z, y/z, 1) – one-to-one mapping with R2

• If z=0 (x, y, 0) – points at infinity– line at infinity– P1

• P2 = R2 U P1

• Homogenous coordinates P = (x, y, z) (up to a scale)

Page 7: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Projective Transformation (Homography)

• Homography– Invertible mapping h from P2 to P2– Lines maps to lines• x1, x2, x3 lie on a line h(x1), h(x2), h(x3) lie on a line

Page 8: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Homography matrix

• Theorem– h:P2->P2 is homography h(x)=Hx, H non-

singular

• x’=Hx– H, a homogenous matrix (up to scale)– 8 dof

Page 9: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Hierarchy of Transformations

• Euclidean < Similarity < Affine < Projective• Invariants– Quantities that are preseved

• Euclidean: rotation and translation– x’ = HEx = [R t; 0T 1]

– Invariants: length, angle, area

Page 10: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Hierarchy of Transformations• Similarity: isotropic scale + (Euclidean)

– x’ = HSx = [sR t; 0T 1]– Invariants: angle, ratios of length and area

• Affine: non-isotropic scales and skew– x’ = HAx = [A t; 0T 1]; A non-singular– Invariants: Parallel lines, ratio of areas

• Projective: – x’ = HPx = [A t; vT u]x– Note: parallel lines not preserved– Invariants: Colinearity, cross-ratio

Page 11: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Generalization: Pn

• P3 = R3 + P2

– P2: plane at infinity

• Homogenous coordinates: X= (X1, X2, X3, X4)

• Projective transformation– X’ = HX

Page 12: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Camera Models

Page 13: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Camera Models

• Mapping 3D to 2D: Camera Matrices• Central projection– Pin-hole camera– Finite projective camera

• Parallel projection– Orthographic camera– Affine camera

Page 14: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Pinhole Camera Geometry

• Camera– Camera center, C– Image plane– Principle axis– Principle point

• Camera coordinate system– C as origin– Image plane at Z=f

• (X, Y, Z)T -> (fX/Z, fY/Z)T

Page 15: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Camera Matrix

• (X, Y, Z)T -> (fX/Z, fY/Z)T

• Homogenous coordinates– (X, Y, Z, 1)T -> (fX, fY, Z)T

• Transformation: diag(f f 1)[I | 0]• Camera projection matrix: x= PX– P = diag(f, f, 1)[I | 0 ], a 3×4 matrix

Page 16: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Principle Point Offset

• (px, py): principle point– (X, Y, Z) -> (fX/Z+px, fY/Z+py)

• x = K[I | 0]X• Camera matrix: K[I | 0]– K: Internal parameter matrix

Page 17: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Camera Rotation and Translation

• World coordinate system– , in inhomogenous coordinates

• P = K[R | t]– K: Internal parameters– R,t: External parameters

)(~~~

CXRX cam

XCRRKx ]|[~

Page 18: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Finite Projective Camera

• Finite projective camera– Generalize K• αx, αy: unequal scale factors

• s: skew parameter

– P = [KR | Kt] = [M | p4]• M = KR non-singular, rank 3

• General projective cameras– Homogenous 3×4 matrix of rank 3

Page 19: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

General Projective Camera

• Given P, what can we say about the camera?– Camera center?– P is a 3×4 matrix• PC=0

– Consider the line joining C and A: • X(λ) = λA + (1-λ)C • x = PX(λ) = λPA

– C is the camera center

Page 20: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

From 2D to 3D

• Given a point x, find the ray

• Two points on ray– Camera center– Another point• P+x, where P+ is the pseudo-inverse

• X(λ) = λP+x + (1-λ)C

Page 21: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Parallel Projection

• Central Projection: P=[I | 0]

• Parallel Projection:

– Projection along Z-axis

1000

0010

0001

P

Page 22: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Hierarchy of Parallel Projection

• Orthographic projection• Scaled orthographic projection• Weak perspective projection• Affine projection

Page 23: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Orthographic Projection

• Projection along Z-axis

• Dof: 5

Page 24: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Generalization of Orthographic Projection (O.P.)

• Scaled orthographic projection– O. P. followed by isotropic scaling– Dof : 6

• Weak perspective projection– O.P. with non-isotropi c scaling– Dof: 7

• Affine camera (projection)– Plus skew – Dof: 8

Page 25: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Properties of Affine Camera

• Last row is (0 0 0 1)– Parallel world line maps to parallel image lines

• Camera center at infinity

Page 26: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

How to get an Affine Camera?

Page 27: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Computation of Camera Matrix P

Page 28: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Approach for Computing P

• x = PX• Estimate P from 3D-2D correspondences– Xi ↔ xi

• Compute K, R, t from P

Page 29: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Basic Equations for Computing P

• Each Xi ↔ xi satisfy– xi = PXi (upto a scale)

– xi × PXi = 0

• Linear in P– Aip = 0, where p = vec(P)

– 2 linearly independent eqns. per corrs.

• P is a 3×4 homogenous matrix => 11 dofs• # of correspondences ≥ 6

Page 30: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Computing P

• Want to solve: Ap = 0, with p≠0• In presence of noise,– – Eigen-value solution– Algebraic cost

• Geometric cost:– ML estimate of P– Non-linear optimization: use Newton’s method

1||||||||min ptosubjectApp

i

iip

PXxd 2),(min

Page 31: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Summary for Computing P

• Form A from 3D-2D correspondences• Normalization step (see reference 1)• Solve algebraic cost• Solve geometric cost starting from algebraic

soln.• Denormalization step (see reference 1)

Page 32: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Computing K from P

• P = [M | p4]

• We know P = K[R | t] = [KR | Kt] • Decompose M using QR decomposition– Get K and R– Obtain t as K-1p4

Page 33: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

Summary

• Projective geometry: P2 and P3

• Camera models– Central projection (Pin hole camera)– Parallel projection (affine camera)

• Estimation of Camera Model P– Estimation of internal parameter K

Page 34: Projective Geometry and Camera Models ENEE 731 Image Understanding Kaushik Mitra.

References

• 1) Multi-view Geometry (Ch 2, 6, 7)– Hartley and Zisserman

• 2) Computer Vision: Algorithms and Applications– Richard Szeliski