Computer Vision Projective Geometry and Calibration: Professor Hager
Computer Vision Projective Geometry and Calibration: Professor Hager
Projective Geometry
and Calibration
Professor Hager
http://www.cs.jhu.edu/~hager
Jason Corso
http://www.cs.jhu.edu/~jcorso
.
05/09/20 CS 441, Copyright G.D. Hager
Pinhole cameras
• Abstract camera model - box • Pinhole cameras work in practice
with a small hole in it
Generally, pinhole
cameras are dark, because
a very small set of rays
from a particular point
hits the screen.
1 1 1
− = Note that, if the image plane is very
z' z f small and/or z >> z’, then z’ is about f
• The effective diameter and the focal length determine the field of view:
tan w = d /(2 f )
• w is the half the total angular “view” of a lens system.
• The “depth of field” is the range of distances that produce acceptably focused
images. Depth of field varies inversely with focal length and lens diameter.
Spherical Aberration
vignetting
• Note this corresponds with indexing an image from the upper left to the
lower right, where the X coordinate is the column index and the Y
coordinate is the row index.
• In P2,
– given two points p1 and p2, l = p1 £ p2 is the line containing them
– given two lines, l1, and l2, p = l1 £ l2 is point of intersection
– A point p lies on a line l if p ¢ l = 0 (note this is a consequence of the triple
product rule)
– l = (0,0,1) is the “line at infinity”
– it follows that, for any point p at infinity, l¢ p = 0, which implies that points at
infinity lie on the line at infinity.
• In P3,
– A point p lies on a plane l if p ¢ l = 0 (note this is a consequence of the triple
product rule; there is an equivalent expression in determinants)
– l = (0,0,0,1) is the “plane at infinity”
– it follows that, for any point p at infinity, l¢ p = 0, which implies that points at
infinity lie on the line at infinity.
• Plucker coordinates
– In general, a representation for a line through points p 1 and p2 is given by all possible 2x2
determinants of [p1 p2] (an n by 2 matrix)
• u = (l4,1,l4,1, l4,3,l2,3,l3,1,l1,2) are the Plűcker coordinates of the line passing through the two points.
• if the points are not at infinity, then this is also the same as (p2 - p1, p1 x p2)
– The first 3 coordinates are the direction of the line
– The second 3 are the normal to the plane (in R 3) containing the origin and the points
– In general, a representation for a plane passing through three points p 1, p2 and p3 are the
determinants of all 3 by 3 submatrices [p1 p2 p3]
• let li,j mean the determinant of the matrix of matrix formed by the rows i and j
• P = (l234,l134,l142,l123)
• Note the three points are colinear if all four of these values are zero (hence the original 3x4 matrix
has rank 2, as we would expect).
– Two lines are colinear if we create the 4x4 matrix [p 1,p2,p’1,p’2] where the p’s come from
one line, and the p’s come from another.
• Second, consider lines that have the same direction (are parallel)
⎛ X⎞
⎛U ⎞ ⎛1 0 0 0⎞
⎜Y ⎟ U V
⎜ V ⎟ =⎜0 1 ⎟
0 0⎜ (U ,V ,W ) → ( , ) = (u, v )
⎜ ⎟ ⎜ Z ⎟ W W
⎝W⎠ ⎝0 0 ⎟
1 0⎜ ⎟
f ⎠⎝ T ⎠
u=x
Suppose I let f go to infinity; then
v=y
05/09/20 CS 441, Copyright G.D. Hager
The model for orthographic
projection
⎛X⎞
⎛U ⎞ ⎛1 0 0 0⎞
⎜Y ⎟
⎜ V ⎟ =⎜0 1 0 0⎟
⎜ ⎟ ⎜ ⎟⎜ Z⎟
⎝W⎠ ⎝0 0 0 1⎠⎜ ⎟
⎝T ⎠
⎛X ⎞
⎛U ⎞ ⎛1 0 0 0 ⎞⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ Y ⎟
⎜V ⎟ = ⎜0 1 0 0 ⎟⎜ ⎟
⎜W ⎟ ⎜0 0 0 Z * / f ⎟⎜ Z ⎟
⎝ ⎠ ⎝ ⎠⎜ T ⎟
⎝ ⎠
• gathering up
alternatively:
• A = [a1 0 a2; 0 a3 a4]
⎛X ⎞
• d = [d1; d2] ⎛U ⎞ ⎛a1 0 a2 d1 ⎞⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ Y ⎟
⎜V ⎟ = ⎜ 0 a3 a4 d 2 ⎟⎜ ⎟
• u=AP+d ⎜W ⎟ ⎜ 0 ⎟ Z
⎝ ⎠ ⎝ 0 0 1 / f ⎠⎜ ⎟⎟
⎜
⎝T ⎠
P’ = rotate(point) + translate(point)
p’ = R p + T or p = Rt (p’ – T)
⎛ R T⎞
p'= ⎜
⎜0 0 0 1 ⎟
⎟p
⎝ ⎠
or
⎛x ⎞ ⎛−1 / s x 0 ox ⎞⎛ x ⎞
⎜ ⎟ ⎜ ⎟⎜ ⎟
⎜y⎟ =⎜ 0 −1 / s y o y ⎟⎜ y ⎟ = K int p
⎜w ⎟ ⎜ 0 0 1 ⎟⎠⎜⎝w ⎟⎠mm
⎝ ⎠pix ⎝
It is common to combine scale and focal length together
as the are both scaling factors; note projection is unitless in this case!
05/09/20 CS 441, Copyright G.D. Hager
Camera parameters
• Summary:
– points expressed in external frame
– points are converted to canonical camera coordinates
– points are projected
– points are converted to pixel units
⎛X ⎞
⎛U ⎞ ⎛Transforma tion ⎞⎛Transforma tion ⎞⎛Transforma tion ⎞⎜ ⎟
⎜ ⎟ ⎜ ⎟⎜ ⎟⎜ ⎟⎜ Y ⎟
⎜V ⎟ = ⎜representing ⎟⎜representing ⎟⎜representing ⎟⎜ ⎟
⎜W ⎟ ⎜intrinsic parameters ⎟⎜projection model ⎟⎜extrinsic parameters ⎟⎜ Z ⎟
⎝ ⎠ ⎝ ⎠⎝ ⎠⎝ ⎠⎜ T ⎟
⎝ ⎠
point in pixel point in metric point in cam.
point in
coords. image coords. coords.
05/09/20 CS 441, Copyright G.D. Hager world coords.
Lens Distortion
• In general, lens introduce minor irregularities into images, typically
radial distortions:
• Both have the advantage of being linear models on real and projective spaces,
respectively.
– Projection Becomes
• The problem is that X will not be full rank (why?). So we’ll have
to work a little harder ...
.4 rad
.6 rad
05/09/20 CS 441, Copyright G.D. Hager
Camera calibration
• Issues: • Error minimization:
– what are intrinsic parameters of – Linear least squares
the camera? • easy problem numerically
– what is the camera matrix? • solution can be rather bad
(intrinsic+extrinsic)
– Minimize image distance
• General strategy: • more difficult numerical problem
– view calibration object
• solution usually rather good, but
– identify image points can be hard to find
– obtain camera matrix by – start with linear least squares
minimizing error – Numerical scaling is an issue
– obtain intrinsic parameters from
camera matrix
• Most modern systems employ
the multi-plane method
– avoids knowing absolute
coordinates of calibration poitns
rki
= ( xi −ox ) sx
d
Known r
distance = ( xi +1 −xi ) s x
d d
• U = A P U P’ (P P’)-1 = A
• d is now mean of ui – A pi
• Putting all this together, we see that A must have rank 7 (in this
particular case) and thus x must be a vector in this subspace.
Ry = (q2 – oy Rz)/fy ox = q1 . q3
Rx = R y x Rz oy = q2 . q3
Tx = -(q4,1 – ox Tz)/fx fx = (q1 . q1 – ox2)1/2
Ty = -(q4,2 – oy Tz)/fy fy = (q2 . q2 – oy2)1/2
• Projection is