32
Introduct Introduct ion ion to to Homograph Homograph y y 2010.01.19

Introduction to homography

Embed Size (px)

Citation preview

Page 1: Introduction to homography

IntroductioIntroductionntoto

HomographHomographyy

2010.01.19

Page 2: Introduction to homography

Coordinate System

view coordinatesystem

object coordinatesystemx y

z

world coordinate system

Page 3: Introduction to homography

History

P->G: 以 E 為眼點從平面G 到平面 W 的透視對應

Page 4: Introduction to homography

Outline

•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm

•OpenCV Implementation

Page 5: Introduction to homography

Homo. representation (1)

• Lines

• This equivalence relationship is known as a homogeneous vector

0ax by c ( , , )Ta b c

( ) ( ) ( ) 0ka x kb y kc ( , , )Tk a b c

representative

Page 6: Introduction to homography

Homo. representation (2)

• Points

0ax by c ( , )Tx y on

( , ,1)( , , ) 1 0T

a

x y a b c x y b

c

1 2 3( , , )Tx x x 21 3 2 3( / , / ,1) inTx x x x R

Homo. representation

Page 7: Introduction to homography

Degree of freedom (DoF)

• Point

• Line

( , ) : 2Tx y DoF

( , , ) : : : 2Ta b c a b c DoF

Page 8: Introduction to homography

• 2 lines

• Assume

Intersection of lines (1)

( , , ) ( , , )T Tl a b c l a b c

0 0

x l l

l l l l l l l x l x

The intersection of two lines and ' is the pointl l x

Page 9: Introduction to homography

Intersection of lines (2)

• Ex: determining the intersection of the lines x = 1 and y = 1

: 1 1 0 1,0,1

: 1 1 0 0, 1,1

0 1 1 1 1 01 0 1

1 1 0 1 0 10 1 1

1,1,1

T

T

T

l x x

l y y

i j k

x l l i j k

y = 1

x = 1

Page 10: Introduction to homography

Line joining points

• The line passing through two points x and x’

• Assume

The line through two points and ' is 'x x l x x

0 0

l x x

x x x x x x x l x l

Page 11: Introduction to homography

Line at infinity (1)

• Consider 2 lines

• Intersection

: 0 : 0

( , , ) ( , , )T T

l ax by c l ax by c

l a b c l a b c

, ,0T

b c c a c c

i j kb c a c a b

x l l a b c i j kb c a c a b

a b c

i j c c b a

Page 12: Introduction to homography

Line at infinity (2)

• Inhomogeneous representation

• No sense! Suggest the point has infinitely large coordinates

, ,0 ,0 0

TT b a

c c b a

Homogeneous coordinates (x, y, 0)T do not correspond to any finite point in R2

Page 13: Introduction to homography

Line at infinity (3)

• Ex: intersection point of 2 lines x=1 and x=2

1 0 1 0,1,0

1 0 2

T

i j k

x l l

The point at infinity in the direction of the y-axis

Page 14: Introduction to homography

Line at infinity (4)

• Projective Space P2 : augment R2 by adding points with last coordinate x3 = 0 to all homogeneous 3-vectors• The points with last coordinate x3 = 0 are

known as ideal points, or points at infinity• The set of all ideal points may be written

(x1,x2, 0)T. The set lies on a single line, the line at infinity, denoted by the vector (0,0,1)T => (x1,x2,0)(0,0,1)T=0

Page 15: Introduction to homography

Concept of points at infinity• Simplify the intersection properties of

points and lines

• In P2, one may state without qualification (not true in the R2)• 2 distinct lines meet in a single point• 2 distinct points lie on a single line

Page 16: Introduction to homography

A model for the projective plane

Points and Lines of P2 are represented by Rays and Planes, respectively, through the origin in R3

Lines lying in the x1x2-plane represent ideal points, and the x1x2-plane represents l∞

Page 17: Introduction to homography

Outline

•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm

•OpenCV Implementation

Page 18: Introduction to homography

Mapping between planes

Page 19: Introduction to homography

Definition (1)

• A projectivity is an invertible mapping h from P2 to itself such that 3 points x1 , x2 and x3 lie on the same line if and only if h(x1), h(x2) and h(x3) do

• Synonymous• Collineation • Homography

Page 20: Introduction to homography

Definition (2)

• A mapping h from P2 to P2

• There exists a non-singular 3 x 3 matrix H such that for any point in P2 represented by a vector x it is true that

1 11 12 13 1

2 21 22 23 2

3 31 32 33 3

x h h h x

x h h h x

x h h h x

( )x H x

Page 21: Introduction to homography

Definition (3)

• H is a homogeneous matrix, since as in the homogeneous representation of a point, only the ratio of the matrix elements is significant (Dof = 8)

Page 22: Introduction to homography

A hierarchy of transformations (1)

Page 23: Introduction to homography

A hierarchy of transformations (2)

0 0

0 1 0 1

T

s A P T T T T

sR t K I sRK tv tH H H H

v v v v

Page 24: Introduction to homography

Outline

•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm

•OpenCV Implementation

Page 25: Introduction to homography

Document Distortion

Page 26: Introduction to homography

Correction

Page 27: Introduction to homography

2D Homography

• xi in P2 xj in P2

• In a practical situation, the points xi and xj are points in 2 images (or the same image), each image being considered as a projective plane P2

Page 28: Introduction to homography

DLT Algorithm (1)

1 2 3

4 5 6

7 8 9

,

1 1

u x h h h

cx Hx x v x y H h h h

h h h

1 2 3

4 5 6

7 8 91 1

u h h h x

c v h h h y

h h h

1 2 3

4 5 6

7 8 9

cu h x h y h

cv h x h y h

c h h h

1 2 3 7 8 9

4 5 6 7 8 9

0

0

h x h y h h h h u

h x h y h h h h v

Page 29: Introduction to homography

DLT Algorithm (2)

• Since each point correspondence provides 2 equations, 4 correspondences are sufficient to solve for the 8 degrees of freedom of H• Use more than 4 correspondences to

ensure a more robust solution (The problem then becomes to solve for a vector h that minimizes a suitable cost function)

Page 30: Introduction to homography

Outline

•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm

•OpenCV Implementation

Page 31: Introduction to homography

OpenCV Implementation• Mat findHomography(

const Mat& srcPoints,

const Mat& dstPoints,

int method=0,

double ransacReprojThreshold=3);

• void warpPerspective(

const Mat& src,

CV_OUT Mat& dst,

const Mat& M,

Size dsize,

int flags=INTER_LINEAR,

int borderMode=BORDER_CONSTANT,

const Scalar& borderValue=Scalar());

Homography Estimation

Projective Transform

Page 32: Introduction to homography

Reference

• Multiple View Geometry in Computer Vision, Cambridge University Press, 2000.

• Projective geometry and homogeneous coordinates [Video] - http://www.youtube.com/watch?v=q3turHmOWq4