Title: CS 39549526: Spring 2003
1CS 395/495-26 Spring 2003
- IBMR Week 3 A 2D Projective GeometryConics
Measure Angles - Jack Tumblin
- jet_at_cs.northwestern.edu
2Recall Projective Transform H
2D image (x,y) ?? Homog. coords x,y,1T x
- Apply the 3x3 matrix H x Hx
Homog. coords x x,y,1T ?? 2D image
(x,y)
x
x
x2
(x,y)
y
x
y
y
y
x3
x
x
x
y
(x,y)
x1
x
3Recall Projective Transform H
Goal Find H for Image Rectification
2D image (x,y) ?? Homog. coords x,y,1T x
- Apply the 3x3 matrix H x Hx
Homog. coords x x,y,1T ?? 2D image
(x,y)
x
x
x2
(x,y)
y
x
y
y
y
x3
x
x
x
y
(x,y)
x1
x
World Plane
View Plane
4 Recall The bits and pieces of H
- H has 8 independent variables (DOF)
- Computer Vision Jargon (2D projective)
- Isometry --3DOF(2D translate tx,ty 2D rotate
?z ) - Similarity --4DOF (add uniform scale s)
- Affine --6DOF (add orientable scale s?,/s,
s??/s) - Projective--8DOF (changes x3 3D-rotation-like)
- Rectification up to a Similarity remove
5Recall Rectification Undo parts of H
- x H x where H HS HA HP
- GOAL Put world plane x into view plane x
- Affine Rect. (find only HP (2DOF))
- Metric Rect. (find HA and HP (6DOF))
- Full Rect. (find all HSHAHP (8DOF))
-
- METHODS
- Affine Vanishing Point, Horizon line methods
- Metric Conics Circular Points
- Full 4-point correspondence
6Intuition for Conics 2D Ellipses
- Cartesian Circle/Ellipse a x2 b y2
r2 0 - P2 Circle/Ellipse a x12 b x22 r2
x32 0 - 5 parameters (deg. of freedom)
- center point (cx, cy)
- major, minor axes (1/a, 1/b)
- orientation ?
?
7Intuition for Conics 2D Ellipses
- Still a circle/ellipse after P2 projective
transform
H1
H2
H3
8Conics Key Ideas
- Conic method Clever math, but NOT intuitive!
- (and book gives ugly, scattered description)
- P2 Conics are the family of ALL quadratics of
(x1, x2, x3) - Includes simpler degenerate forms point,
line, line-pair, parabolas, hyperbolae. - Closed ANY Conic transformed by H Another
Conic
(imaginary)
9Conics Key Ideas
- Transformed conics tell you how H changes angles
- one strange, degenerate conic C? measures angle
- Angles between line pairs yield transformed C?
- We can compute HA and HP from transformed C?
?
?
?
C?
C?
?
?
?
? ?
?
L
m
HS HA HP
2D image space
2D world space
10Conic Review
- Review conics first (pg.8)
- Conics intersection of cone plane
- Many possible shapes circles, ellipses,
parabola, hyperbola, degenerate lines points - Dual Forms
- Point Conics defined by points on the curve
- Line Conics defined by lines tangent to curve
11Point Conics C
- All points on any conic solve a 2D quadratic
ax2 bxy cy2 dx ey f
0 - In homogeneous coordinates (mpy. all by x32)
- ax12 bx1x2 cx22 dx1x3 ex2x3 fx32
0 - xTCx 0
- C is symmetric, 5DOF (not 6 ignores x3 scaling)
- Can find any C from 5 homog. point pairs...
(SVD solves for
null spacesee book pg 9)
x1 x2 x3
a b/2 d/2 b/2 c e/2 d/2 e/2
f
x1 x2 x3
0
(but not very useful for finding H...)
12Familiar Conics Circles, Ellipses...
x1 x2 x3
a b/2 d/2 b/2 c e/2 d/2 e/2
f
- xT C x 0 or
- General form of point conic
- ax2 bxy cy2 dx ey f
0 (or) - ax12 bx1x2 cx22 dx1x3 ex2x3 fx32 0
- Circle at d with radius r
- 1x12 bx1x2 1x22 dx1x3 ex2x3 r2x32 0
- Cr
- Degenerate Cases (ranklt3) lines, parabolas,
hyperbolae... Example - 1x12 bx1x2 0x22 dx1 ex2 fx32 0
x1 x2 x3
0
1 0 0 0 1 0 0 0 -r2
a 0 0 0 0 0 0 0 f
13Point Conics C
- Matrix C makes conic curves from points x
xTCx 0 C is a point conic - The tangent line L for point x is L C x
- P2 conic transformed by H
- C H-T C H-1
- (messy! requires invertible H !)
x
L
14Dual or Line Conics C
- Matrix C makes conic curves from lines L
LT C L 0 C is a line conic - The tangent point x for line L is x C L
- Projective transform by H is
- C H C HT (better -- no H inversion
required) - If C is non-singular (rank 3), then C C-1
x
L
15Degenerate Conics
x1 x2 x3
a b/2 d/2 b/2 c e/2 d/2 e/2
f
- xT C x 0 or
- General form of point conic
- ax2 bxy cy2 dx ey f
0 (or) - ax12 bx1x2 cx22 dx1x3 ex2x3 fx32 0
- Very special degenerate case infinite
radius circle as x3?0, aka C? - 1x12 bx1x2 1x22 dx1x3 ex2x3 0x32 0
-
- C? only solutions to xT C?x 0
are 2 complex x vectors and
x1 x2 x3
0
16Conic Weirdness I
- Circular Points I , J or C?
- Ideal points 2 points at infinity / horizon,
but - Complex real part on x axis, imag. on y
- Where infinite circle hits infinity line L?
0,0,1 - Where? imaginary! (infinite x,y axes, maybe?)
- I,J are not affected by HS . ( only by HA, HP)
- ?WHY BOTHER?
- To measure angles in projective space
- To use angle correspondences to find HA,HP
17Conic Weirdness 2
- Circular Points I , J and C?
- C? is a point conic, affected by HAHP only.
- C? is line conic, but the same matrix (!?!?!)
- Is same as this outer product IJT JIT
- Includes L?, the infinity line (L?C?L?0)
- Affected by HP and HA only, ( HS does nothing)
- ALL transforms of C? have only 4DOF (pg 33 )
18Conics Angle Measuring
- Matrix H transforms C? to another space
- C? H C? HT
- Angles
- define world space C? as
- (for any two world-space homogeneous lines) L
and m are perpendicular iff LT C? m 0 - Also true for transformed L, m and C?, so
- C? in image space?angle ? in world space
(simpler to transform a line conic)
(LT C? m) (LT C? L)(mT C? m)
cos(?)
19Undoing H Metric Rectification
- C? has only 4DOF (before,after ANY H)
- All C? DOF are contained in (HA HP)
- SVD can convert C? to (HA HP) matrix!
- Task is then find C?, then use it to find H
?
?
?
C?
C?
?
?
?
?
?
0
L
m
HS HA HP
2D image space
2D world space
20? But how do we find C? ?
- One Answer use perpendicular lines
- (Recall) we defined world space C? as
- Then 2 world-space lines L and m are
perpendicular iff LT C? m 0 - Also true for transformed L, m and C?
- H transforms C? to image space C? by C? H
C? HT - Now split up H and try it H HSHAHP, so
1 0 0 0 1 0 0 0 0
21Undoing H Metric Rect. 1
- H HS HA HP
- Book shows how to write transformed C? as
(simple, tedious) - C?
- where K is 2x2 symmetric (affine part 2DOF)
- v is 2x1 vector, (projective part 2DOF)
?
?
?
sR t 0T 1
I 0 vT v
K 0 0T 1
?
?
?
?
?
?
?
?
?
?
?
KKT ? Kv ? ? ? vTK ? 0
22Undoing H Metric Rect. 1
- H HS HA HP
- Book shows how to write transformed C? as
(simple, tedious) - C?
- where K is 2x2 symmetric (affine part 2DOF)
- v is 2x1 vector, (projective part 2DOF)
?
?
?
sR t 0T 1
I 0 vT v
K 0 0T 1
?
?
?
?
?
?
?
?
?
?
?
!!!BUT DERIVATION RESULT IS WRONG!!! SKIP
Metric Rectification I pg 35,36!
KKT ? Kv ? ? ? vTK ? 0
23END
24Undoing H Metric Rect. 1
- C? ?
- First, ignore projective part set v0.
- Choose two pairs of perpendicular lines L,m
- Second, Use LT C? m 0 to solve for K
KKT ? Kv ? ? ? vTK ? s
KKT ? 0 ? ? ? 0 ? s
aka Weak Perspective
L
m
HS HA HP
2D image space
2D world space
25Matrix Math SVDs
- Matrix multiply is a change of coordinates
- Rows of A coordinate axis vectors
- Ax a dot product for each axis
- input space?output space
- SVD factors matrix A into 3 parts
- U orthonormal basis
-
svd(A) U S VT
26Matrix Math SVDs
- Matrix multiply is a change of coordinates
- Rows of A coordinate axis vectors
- Ax a dot product for each axis
- input space?output space
- SVD factors matrix A into 3 parts
- U orthonormal basis
-
svd(A) U S V
27Recall Projective Transform Hx x
Finding H from point pairs (correspondences)
x1 x2 x3
h11 h12 h13 h21 h22 h21 h31 h32 h33
x1 x2 x3
x y 1
Input (or output) image is on central plane
x1 x2 x3
x y
Write R2 expressions(for each x,x pair)
x (h31 x h32 y h33) (h11 x h12 y h13)
Rearrange, solve as a matrix problem
y (h31 x h32 y h33) (h11 x h12 y h13)
28DLT Four-Point Correspondence
- 4 point correspondence
- Book shows
- Rearrange known vector (dot) unknown vector
- stack, solve for null space
- Hint Files
- Added max commands, examples
- Make, test your own H matrices!
x (h31 x h32 y h33) (h11 x h12 y h13)
y (h31 x h32 y h33) (h11 x h12 y h13)
x y 1 0 0 0 -xx -xy -x
0 0 0 0 x y 1 -yx -yy -y
h11 h12 h13 h21 h22 h23 h31 h32 h33
29Direct Linear Tranform (DLT)
- Project 2 method Solve Hx x 0
- Requires constant scale (x31 in measurement)
- compare
- DLT method Solve Hx ? x 0
- Accepts any scale (x3w?1 OK, xx3)
h11 h12 h13 h21 h22 h23 h31 h32 h33
0 0 0 x y 1
-yx -yy -y x y
1 0 0 0 -xx -xy
-x
0 0 0 -wx -wy -ww yx
yy yw 0 wx wy ww
0 0 0 -xx -xy -xw
30Direct Linear Tranform (DLT)
- Project 2 method Solve Hx x 0
- Requires constant scale (x31 always)
- compare
- DLT method Solve Hx ? x 0
- Accepts any scale (x3w?1, x3w?1)
h1 h2 h3
0 0 0 x y 1
-yx -yy -y x y
1 0 0 0 -xx -xy
-x
0 0 0 -wx -wy -ww yx
yy yw 0 wx wy ww
0 0 0 -xx -xy -xw
0T -wi xiT yI xiT wi
xiT 0T -xi xiT
31Direct Linear Tranform (DLT)
- DLT method Solve H ? x 0
- Accepts any scale, any point (x3w?1 is OK)
- Pure, Compatible -- P2 terms only
- Much better suited to error measurements.
- Subtlety
- Wont divide-by-zero if w0 or h330 (it
happens!) - has a 3rd row it is not degenerate if w0
- OK to use it(Solve 8x12)
0T -wi xiT yI xiT wi
xiT 0T -xi xiT 0 -yi xiT
-xi xiT 0T
h1 h2 h3
32Deceptive Robustness
- Suppose we have 4 pt-correspondences
- Use DLT to write 8x9 (or 12x9) matrix A Ah0
- Solve for h null space. ALWAYS gives H matrix
- But what if points are bad / fictional?
- 3 collinear input pts, crooked out IMPOSSIBLE!
- Yet we get an H solution! Why?
- A matrix rank is 7 or 6? rank 1 H result(s)
- Null Space of A may contain gt1 H solution!
- Degenerate H solution of form aH1 bH2
- Answer SVD ranks A reject bad point sets.
33Actual Robustness
- Vectorizing (Flatten, Stack, Null Space method)
works for almost ANY input! (Points, lines,
planes, , ?, conics, quadrics, cross-ratios,
vanishing points, twisted cubics - Use DLT formulation (Hx ? x) 0
- Rearrange as dot product (known)(unknown) 0
- Be careful to have ENOUGH constraints
- tricky when you mix types points, lines, (pg
75)
0
measured output
measured inputtransformed
?