computer vision cmput 428/615 basic 2d and 3d geometry and camera models martin jagersand

75
Computer Vision cmput 428/615 Basic 2D and 3D Basic 2D and 3D geometry and Camera geometry and Camera models models Martin Jagersand Martin Jagersand

Upload: sabrina-richardson

Post on 13-Jan-2016

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Computer Visioncmput 428/615

Basic 2D and 3D geometry Basic 2D and 3D geometry and Camera modelsand Camera models

Martin JagersandMartin Jagersand

Page 2: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

The equation of projection

Mathematically:Mathematically:• Cartesian coordinates:Cartesian coordinates:

• Projectively: x = PXProjectively: x = PX(x, y, z) ( fx

z, f

y

z)

How do we develop a consistent mathematical framework for projection calculations?

Intuitively:Intuitively:

Page 3: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Challenges in Computer Vision:What images don’t provide

lengths

depth

Page 4: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Distant objects are smaller

Page 5: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Visual ambiguity

•Will the scissors cut the paper in the Will the scissors cut the paper in the middle?middle?

Page 6: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Ambiguity

•Will the scissors cut the paper in the middle? Will the scissors cut the paper in the middle? NO!NO!

Page 7: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Visual ambiguity

• Is the probe contacting the wire?Is the probe contacting the wire?

Page 8: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Ambiguity

• Is the probe contacting the wire? Is the probe contacting the wire? NO!NO!

Page 9: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Visual ambiguity

• Is the probe contacting the wire?Is the probe contacting the wire?

Page 10: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Ambiguity

• Is the probe contacting the wire? Is the probe contacting the wire? NO!NO!

Page 11: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

History of Perspective

RomanRomanPrehistoric:Prehistoric:

Page 12: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Perspective: Da Vinci

Page 13: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Visualizing perspective: Dürer

Perspectograph

1500’s

Page 14: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Parallel lines meet

common to draw image planein front of the focal point

Centre of projection

Image plane

3D world

Page 15: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Perspective Imaging Properties

90

Challenges with measurements in multiple images:

• Distances/angles change

• Ratios of dist/angles change

• Parallel lines intersect

Page 16: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

What is preserved?

horizon

Invariants:

• Points map to points• Intersections are preserved• Lines map to lines• Collinearity preserved• Ratios of ratios (cross ratio)• Horizon

What is a good way to represent imaged geometry?

Page 17: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Vanishing points

• each set of parallel lines (=direction) meets each set of parallel lines (=direction) meets at a different pointat a different point– The The vanishing pointvanishing point for this direction for this direction

– How would you show this?How would you show this?

• Sets of parallel lines on the same plane lead Sets of parallel lines on the same plane lead to to collinear collinear vanishing points. vanishing points. – The line is called theThe line is called the horizon horizon for that plane for that plane

Page 18: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Geometric properties of projection

• Points go to pointsPoints go to points• Lines go to linesLines go to lines• Planes go to whole imagePlanes go to whole image• Polygons go to polygonsPolygons go to polygons

• Degenerate casesDegenerate cases– line through focal point to line through focal point to

pointpoint

– plane through focal point plane through focal point to lineto line

Page 19: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Polyhedra project to polygons

• (because lines project to (because lines project to lines)lines)

Page 20: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Junctions are constrained

• This leads to a This leads to a process called “line process called “line labelling”labelling”– one looks for consistent one looks for consistent

sets of labels, bounding sets of labels, bounding polyhedrapolyhedra

– disadv - can’t get the lines disadv - can’t get the lines and junctions to label and junctions to label from real imagesfrom real images

Page 21: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Back to projection

• Cartesian coordinates:Cartesian coordinates: (x, y, z) ( fx

z, f

y

z)

We will develop a framework to express projection as x=PX, where x is 2D image projection, P a projection matrix and X is 3D world point.

Page 22: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Basic geometric transformations:Translation

• A translation is a straight line movement of an A translation is a straight line movement of an object from one postion to another.object from one postion to another.

A point A point (x,y)(x,y) is transformed to the point is transformed to the point (x’,y’)(x’,y’) by adding the by adding the translation distances translation distances TTxx and and TTyy::

x’ = x + Tx’ = x + Txx

y’ = y + Ty’ = y + Tyy

z’ = z + Tz’ = z + Tzz

Page 23: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Coordinate rotation

•Example: Around y-axisExample: Around y-axis

p0=x0

y0

z0

" #

=cos÷ 0 sin÷

0 1 0à sin÷ 0 cos÷

2

4

3

5xyz

" #

= R yp

X’

Z’

X

P

Page 24: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Euler angles

•Note: Successive rotations. Order matters.Note: Successive rotations. Order matters.

R = R zR yR x

=cos' à sin' 0sin' cos' 0

0 0 1

" # cos÷ 0 sin÷0 1 0

à sin÷ 0 cos÷

2

4

3

51 0 00 cos à sin 0 sin cos

2

4

3

5

Page 25: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Rotation and translation

•Translation Translation t’ t’ in new in new o’o’ coordinates coordinates

p0=cos÷ 0 sin÷

0 1 0à sin÷ 0 cos÷

2

4

3

5 p + t0

X’

Z’

X

P

Page 26: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Basic transformations Scaling

• A scaling transformation alters the scale of an object. A scaling transformation alters the scale of an object. Suppose a point (x,y) is transformed to the point (x',y') by Suppose a point (x,y) is transformed to the point (x',y') by a scaling with scaling factors Sa scaling with scaling factors Sxx and S and Syy, then:, then:

x' = x S x' = x Sxx

y' = y S y' = y Syy

z' = z Sz' = z Szz

• A uniform scaling is produced if SA uniform scaling is produced if Sxx = S = Sy y = S= Szz . .

Page 27: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Basic transformations Scaling

The previous scaling transformation leaves the origin The previous scaling transformation leaves the origin unaltered. If the point (xunaltered. If the point (xff,y,yff) is to be the fixed point, the ) is to be the fixed point, the

transformation is:transformation is: x' = x x' = xff + (x - x + (x - xff) S) Sxx

y' = y y' = yff + (y - y + (y - yff) S) Syy

This can be rearranged to give:This can be rearranged to give: x' = x S x' = x Sxx + (1 - S + (1 - Sxx) x) xff

y' = y S y' = y Syy + (1 - S + (1 - Syy) y) yff

Page 28: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Affine Geometric Transforms

In general, a point in n-D space transforms by

P’ = rotate(point) + translate(point)

In 2-D space, this can be written as a matrix equation:

ty

tx

y

x

CosSin

SinCos

y

x

)()(

)()(

'

'

In 3-D space (or n-D), this can generalized as a matrix equation:

p’ = R p + T or p = Rt (p’ – T)

Page 29: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

A Simple 2-D Example

p = (1,0)’

Suppose we rotate the coordinatesystem through 45 degrees (notethat this is measured relative to therotated system!

)4/(

)4/(

'

'

0

1

)4/()4/(

)4/()4/(

'

'

Sin

Cos

y

x

CosSin

SinCos

y

x p = (0,1)’

)4/(

)4/(

'

'

1

0

)4/()4/(

)4/()4/(

'

'

Cos

Sin

y

x

CosSin

SinCos

y

x

Page 30: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Matrix representation and Homogeneous coordinates

• Often need to combine several transformations to build Often need to combine several transformations to build the total transformation. the total transformation.

• So far using affine transforms need both add and multiplySo far using affine transforms need both add and multiply• Good if all transformations could be represented as matrix Good if all transformations could be represented as matrix

multiplications then the combination of transformations multiplications then the combination of transformations simply involves the multiplication of the respective simply involves the multiplication of the respective matricesmatrices

• As translations do not have a 2 x 2 matrix representation, As translations do not have a 2 x 2 matrix representation, we introduce homogeneous coordinates to allow a 3 x 3 we introduce homogeneous coordinates to allow a 3 x 3 matrix representation.matrix representation.

Page 31: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

How to translate a 2D point:

•Old way:Old way:

•New way:New way:

Page 32: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Relationship between 3D homogeneous and inhomogeneous

• The Homogeneous coordinate corresponding to the point The Homogeneous coordinate corresponding to the point (x,y,z) is the triple (x(x,y,z) is the triple (xhh, y, yhh, z, zhh, w) where:, w) where:

x xhh = wx = wx y yhh = wy = wy

z zhh = wz = wz

We can (initially) set w = 1.We can (initially) set w = 1.• Suppose a point P = (x,y,z,1) in the homogeneous Suppose a point P = (x,y,z,1) in the homogeneous

coordinate system is mapped to a point coordinate system is mapped to a point P' = (x',y',z’,1) by a transformations, then the P' = (x',y',z’,1) by a transformations, then the transformation can be expressed in matrix form.transformation can be expressed in matrix form.

Page 33: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

• For the basic transformations we have:For the basic transformations we have:– TranslationTranslation

– ScalingScaling

P0=

x0

y0

z0

w

2

64

3

75 =

1 0 0 Tx

0 1 0 Ty

0 0 1 Tz

0 0 0 1

2

64

3

75

xyzw

2

64

3

75

P0=

x0

y0

z0

w

2

64

3

75 =

sx 0 0 00 sy 0 00 0 sz 00 0 0 1

2

64

3

75

xyzw

2

64

3

75

Matrix representation and Homogeneous coordinates

Page 34: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Geometric Transforms

Using the idea of homogeneous transforms, we can write:

pTR

p

1000'

R and T both require 3 parameters.

=cos' à sin' 0sin' cos' 0

0 0 1

" # cos÷ 0 sin÷0 1 0

à sin÷ 0 cos÷

2

4

3

51 0 00 cos à sin 0 sin cos

2

4

3

5R

Page 35: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Geometric Transforms

If we compute the matrix inverse, we find that

'1000

''

pTRR

p

R and T both require 3 parameters. These correspond to the 6 extrinsic parameters needed for camera calibration

Page 36: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Rotation about a Specified AxisRotation about a Specified Axis

• It is useful to be able to rotate about any axis in It is useful to be able to rotate about any axis in 3D space3D space

•This is achieved by composing 7 elementary This is achieved by composing 7 elementary transformations (next slide)transformations (next slide)

Page 37: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Rotation through about Specified Axis

Rotation through about Specified Axis

x

y

z

x

y

z rotate throughrequ’d angle,

x

y

z

x

y

z

P2

P1x

y

z

P2

P1x

y

z

initial positiontranslate P1to origin

rotate so that P2 lies on z-axis(2 rotations)

rotate axisto orig orientation

translate back

Page 38: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Comparison:

•Homogeneous coordinatesHomogeneous coordinates– Rotations and translations are represented in a uniform wayRotations and translations are represented in a uniform way

– Successive transforms are composed using matrix products: Successive transforms are composed using matrix products: y = y = Pn*..*P2*P1*xPn*..*P2*P1*x

•Affine coordinatesAffine coordinates– Non-uniform representations: Non-uniform representations: y = Ax + by = Ax + b

– Difficult to keep track of separate elementsDifficult to keep track of separate elements

Page 39: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Camera models and projectionsGeometry part 2.

•Using geometry and homogeneous Using geometry and homogeneous transforms to describe:transforms to describe:– Perspective projectionPerspective projection

– Weak perspective projectionWeak perspective projection

– Orthographic projectionOrthographic projection

x

y

z

x

y

z

x

y

Page 40: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

The equation of projection

• Cartesian coordinates:Cartesian coordinates:– We have, by similar triangles, that (x, y, z) -> We have, by similar triangles, that (x, y, z) ->

(f x/z, f y/z, -f)(f x/z, f y/z, -f)

– Ignore the third coordinate, and getIgnore the third coordinate, and get

(x, y, z) ( fx

z, f

y

z)

Page 41: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

The camera matrix

• Homogenous coordinates for 3DHomogenous coordinates for 3D– four coordinates for 3D pointfour coordinates for 3D point– equivalence relation (X,Y,Z,T) is the same as (k X, k Y, k Z,k T) equivalence relation (X,Y,Z,T) is the same as (k X, k Y, k Z,k T)

• Turn previous expression into HC’sTurn previous expression into HC’s– HC’s for 3D point are (X,Y,Z,T)HC’s for 3D point are (X,Y,Z,T)– HC’s for point in image are (U,V,W)HC’s for point in image are (U,V,W)

U

V

W

1 0 0 0

0 1 0 0

0 0 1f 0

X

Y

Z

T

),(),(),,( vuW

V

W

UWVU

Page 42: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

• IssueIssue– camera may not be at the origin, looking down the z-axiscamera may not be at the origin, looking down the z-axis

– extrinsic parametersextrinsic parameters– one unit in camera coordinates may not be the same as one one unit in camera coordinates may not be the same as one

unit in world coordinatesunit in world coordinates– intrinsic parameters - focal length, principal point, intrinsic parameters - focal length, principal point,

aspect ratio, angle between axes, etc.aspect ratio, angle between axes, etc.

Camera parameters

T

Z

Y

X

W

V

U

parameters extrinsic

ngrepresenti

tionTransforma

model projection

ngrepresenti

tionTransforma

parameters intrinsic

ngrepresenti

tionTransforma

Note: f moved from proj to intrinsics!

Page 43: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Intrinsic Parameters

Intrinsic Parameters describe the conversion frommetric to pixel coordinates (and the reverse)

xmm = - (xpix – ox) sx

ymm = - (ypix – oy) sy

pM

w

y

x

osf

osf

w

y

x

mm

yy

xx

pix

int

100

/0

0/

or

Note: Focal length is a property of the camera and can be incorporated as above

Page 44: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Example:A real camera

• Laser range finderLaser range finder • CameraCamera

Page 45: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Relative locationCamera-Laser

• CameraCamera • LaserLaser

R=10deg

T=(16,6,-9)’

Page 46: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

In homogeneous coordinates

• Rotation:Rotation: • TranslationTranslation

T =

1 0 0 160 1 0 60 0 1 à 90 0 0 1

0

B@

1

CAR =

cosà 10 0 sinà 100 1 0

à sinà 10 0 cosà 10

2

4

3

5

Page 47: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Full projection model

• Camera internal Camera internal parametersparameters

• Camera Camera projectionprojection

0:985 0 à 0:174 00 1 0 0

0:174 0 0:985 00 0 0 1

0

B@

1

CA

1 0 0 160 1 0 60 0 1 à 90 0 0 1

0

B@

1

CA

0:6612à 10:55108:0

1

0

B@

1

CA =

222621675597:47

!

pcamera =1278:6657 0 256

0 1659:5688 2400 0 1

!1 0 0 00 1 0 00 0 1 0

!

Extrinsic rot and translation

Page 48: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

• IssueIssue– camera may not be at the origin, looking down the z-axiscamera may not be at the origin, looking down the z-axis

– extrinsic parametersextrinsic parameters– one unit in camera coordinates may not be the same as one one unit in camera coordinates may not be the same as one

unit in world coordinatesunit in world coordinates– intrinsic parameters - focal length, principal point, intrinsic parameters - focal length, principal point,

aspect ratio, angle between axes, etc.aspect ratio, angle between axes, etc.

Camera parameters

T

Z

Y

X

W

V

U

parameters extrinsic

ngrepresenti

tionTransforma

model projection

ngrepresenti

tionTransforma

parameters intrinsic

ngrepresenti

tionTransforma

Note: f moved from proj to intrinsics!

Page 49: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Result

• Camera imageCamera image • Laser measured 3D Laser measured 3D structurestructure

Page 50: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Hierarchy of different camera models

Camera center

Image plane Object plane

X0(origin)xpersp

Perspective: non-linear

xparap

Para-perspective: lin

xorth

Orthographic: lin, no scaling

Weak perspective: linear approx

xwp

Page 51: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Orthographic projection

yv

xu

Page 52: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

The fundamental model for orthographic projection

U

V

W

1 0 0 0

0 1 0 0

0 0 0 1

X

Y

Z

T

Page 53: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Perspective and Orthographic Projection

perspective Orthographic (parallel)

Page 54: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Weak perspective

ZfT

Tyv

Txu

/

• IssueIssue– perspective effects, but not perspective effects, but not

over the scale of individual over the scale of individual objectsobjects

– collect points into a group at collect points into a group at about the same depth, then about the same depth, then divide each point by the depth divide each point by the depth of its groupof its group

– Adv: easyAdv: easy

– Disadv: wrongDisadv: wrong

Page 55: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

The fundamental model for weak perspective projection

T

Z

Y

X

ZfW

V

U

*/000

0010

0001

Note Z* is a fixed value, usually mean distance to scene

Page 56: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Weak perspective projection

k

t

t

y

x

/10

r

r

1

α

α

P 22T

11T

(7dof)

Weak perspective projection for an arbitrary camera pose R,t

Page 57: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

1. Affine camera=camera with principal plane coinciding with ∞

2. Affine camera maps parallel lines to parallel lines

3. No center of projection, but direction of projection PAD=0(point on ∞)

Affine camera

k

t

ts

y

x

A

/10

r

r

1

α

α

P 22T

11T

(8dof)

1000P 2232221

1131211

tmmmtmmm

A

affine 44100000100001

affine 33P

A

Full Affine linear camera

Page 58: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Hierarchy of camera models

Camera center

Image plane Object plane

X0(origin)xpersp

Perspective:

xparap

Para-perspective:

First order approximation of perspective

z

y

x

persp

t

t

t

f

f

P

k

j

i

1

xorth

Orthographic:

1Ty

x

orth t

t

P

0

j

i

Weak perspective:

xwp

11 Ty

x

wp t

t

k

k

P

0

j

i

Page 59: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Camera Models

Caff

C inj

Cproj

C sim

reconstruction up to a bijection of task space

up to a projective transformation of task space

up to an affine transformation of task space

up to a similarity (scaled Euclidean transformation)

• Internal calibration:Internal calibration:• Weak calibration: Weak calibration: • Affine calibration: Affine calibration: • Stratification of stereo vision: Stratification of stereo vision: - - characterizes the reconstructive certainty of characterizes the reconstructive certainty of

weakly, affinely, and internally calibrated stereo rigsweakly, affinely, and internally calibrated stereo rigs

Page 60: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Visual Invariance

inj injinjinj

proj

sim

aff aff

proj proj

Page 61: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Perspective Camera Model StructureAssume R and T express camera in world coordinates, then

pTRR

p wc

1000

''

Combining with a perspective model (and neglecting internal parameters) yields

p

f

TRTR

TR

f

RR

R

pMu w

z

y

x

z

y

x

wc

'

'

'

'

Note the M is defined only up to a scale factor at this point! If M is viewed as a 3x4 matrix defined up to scale, it is called the projection matrix.

Page 62: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Perspective Camera Model Structure

Assume R and T express camera in world coordinates, then

pTRR

p wc

1000

''

Combining with a weak perspective model (and neglecting internal parameters) yields

p

f

TPRTR

TR

R

R

pMu w

z

y

x

y

x

wc

)('

'

0

'

'

Where is the nominal distance to the viewed object P

Page 63: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Other Models

• The The affine cameraaffine camera is a generalization of weak is a generalization of weak perspective.perspective.

• The The projective cameraprojective camera is a generalization of the is a generalization of the perspective camera.perspective camera.

• Both have the advantage of being linear models on real Both have the advantage of being linear models on real and projective spaces, respectively.and projective spaces, respectively.

• But in general will recover structure up to an affine or But in general will recover structure up to an affine or projective transform only. (ie distorted structure)projective transform only. (ie distorted structure)

Page 64: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Camera Internal CalibrationRecall: Intrinsic Parameters

Intrinsic Parameters describe the conversion frommetric to pixel coordinates (and the reverse)

xmm = - (xpix – ox) sx

ymm = - (ypix – oy) sy

pM

w

y

x

os

os

w

y

x

mm

yy

xx

pix

int

100

/10

0/1

or

Page 65: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

CAMERA INTERNAL CALIBRATION

Knowndistanced

known regular offset r

xii

xxii

sxxd

r

soxd

rk

)(

)(

1

A simple way to get scale parameters; we can compute the optical center as the numerical centerand therefore have the intrinsic parameters

Compute Sx

Focal length = 1/ Sx

Page 66: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Camera calibration

• Issues:Issues:– what are intrinsic parameters of what are intrinsic parameters of

the camera?the camera?

– what is the camera matrix? what is the camera matrix? (intrinsic+extrinsic)(intrinsic+extrinsic)

• General strategy:General strategy:– view calibration objectview calibration object

– identify image pointsidentify image points

– obtain camera matrix by obtain camera matrix by minimizing errorminimizing error

– obtain intrinsic parameters from obtain intrinsic parameters from camera matrixcamera matrix

• Error minimization:Error minimization:– Linear least squaresLinear least squares

– easy problem numericallyeasy problem numerically

– solution can be rather badsolution can be rather bad

– Minimize image distanceMinimize image distance

– more difficult numerical more difficult numerical problemproblem

– solution usually rather good, solution usually rather good, but can be hard to findbut can be hard to find

– start with linear least start with linear least squaressquares

– Numerical scaling is an issueNumerical scaling is an issue

Page 67: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Stereo Vision

• GOAL:GOAL: Passive 2- Passive 2-camera system for camera system for triangulating 3D triangulating 3D position of points in position of points in space to generate a space to generate a depth map of a depth map of a world scene.world scene.

• Humans use stereo Humans use stereo vision to obtain vision to obtain depthdepth

Page 68: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Stereo depth calculation:Simple case, aligned cameras

Z

X(0,0) (d,0)

fXL XR

Z = (f/XL) XZ= (f/XR) (X-d)

(f/XL) X = (f/XR) (X-d)X = (XL d) / (XL - XR)

Z = d*f

(XL - XR)

DISPARITY= DISPARITY= (XL - XR)(XL - XR)

Similar triangles:

Solve for X:

Solve for Z:

Page 69: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Epipolar constraint

Special case: parallel cameras – epipolar lines are parallel and aligned with rows

Page 70: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Stereo measurement example:

• Left imageLeft imageResolution = 1280 x 1024 Resolution = 1280 x 1024

pixelspixelsf = 1360 pixelsf = 1360 pixels

• Right imageRight imageBaseline d = 1.2mBaseline d = 1.2mQ: How wide is the hallwayQ: How wide is the hallway

Page 71: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

How wide is the hallway?General strategy

•Similar triangles:Similar triangles:

•Need depth Need depth ZZ

•Then solve for Then solve for WW

f

v

Z

W W

Z

f

v

Page 72: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

How wide is the hallway?Steps in solution:

1.1. Compute focal length f in meters from pixelsCompute focal length f in meters from pixels

2.2. Compute depth Z using stereo formula (aligned Compute depth Z using stereo formula (aligned camera planes)camera planes)

3.3. Compute width:Compute width:

Z = d*f

(XL - XR)

f

vZW

Page 73: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

Focal length:

0.224m is 1280 pixels

0.238m224.0*1280

1360f

f = 1360 pixels

Here screen projection is metric image plane.

Page 74: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

How wide…Depth calculation

Disparity: Disparity: XL – XR = 0.07mXL – XR = 0.07m(Note in the disparity calculation the choice of (Note in the disparity calculation the choice of

reference (here the edge) doesn’t matter. But in the reference (here the edge) doesn’t matter. But in the case of say X-coordinate calculation it should be case of say X-coordinate calculation it should be w.r.t. the center of the image as in the stereo w.r.t. the center of the image as in the stereo formula derivationformula derivation

• DepthDepth

XR = 0.074mXL = 0.144m

mZ 1.407.0

238.0*2.1

Page 75: Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

How wide…?Answer:

• Similar triangles:Similar triangles:

• The width of the hallway is: The width of the hallway is: W

Z

f

v

mW 3.2238.0

135.0*1.4

f

vZW

V = 0.135m