View
15.659
Download
4
Category
Preview:
Citation preview
IntroductioIntroductionntoto
HomographHomographyy
2010.01.19
Coordinate System
view coordinatesystem
object coordinatesystemx y
z
world coordinate system
History
P->G: 以 E 為眼點從平面G 到平面 W 的透視對應
Outline
•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm
•OpenCV Implementation
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
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
Degree of freedom (DoF)
• Point
• Line
( , ) : 2Tx y DoF
( , , ) : : : 2Ta b c a b c DoF
• 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
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
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
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
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
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
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
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
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∞
Outline
•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm
•OpenCV Implementation
Mapping between planes
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
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
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)
A hierarchy of transformations (1)
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
Outline
•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm
•OpenCV Implementation
Document Distortion
Correction
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
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
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)
Outline
•Projective Geometry•Projective Transformation• Estimation• Document Perspective Distortion• Direct Linear Transform (DLT) Algorithm
•OpenCV Implementation
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
Reference
• Multiple View Geometry in Computer Vision, Cambridge University Press, 2000.
• Projective geometry and homogeneous coordinates [Video] - http://www.youtube.com/watch?v=q3turHmOWq4
Recommended