Unit I
Unit I
Overview
https://software.intel.com/en-us/articles/photogrammetry-and-volumetric-capture
https://youtu.be/hnP7G7ahuus
https://youtu.be/bLtgTbzWmls
http://matthewalunbrown.com/autostitch/autostitch.html
https://youtu.be/bsA6RKUUA3M
Mason 2017
x = F
( r1 x + r2 y + r3 F ) Z + Tx F
( r7 x + r8 y + r9 F ) Z + Tz F
( r4 x + r5 y + r6 F ) Z + Ty F
y = F
( r7 x + r8 y + r9 F ) Z + Tz F
• Homogeneous coordinates
• Duality
• Ideal points or points at infinity
• Conics and points at infinity
• The projective space
• Homographies
Basic transforms
• 2D Euclidean transforms.
• 3D Euclidean transforms.
• Projection.
• Projection + 3D Euclidean transform
21
r31
0T 1 M or MC R t M
c r32 r33 tz Z
1 c 0 0 0 1 1
x x f 0 0 c
0
mC = y y
0
f 0 0 c
= MC = R t M
0 0
1 t 0 0
1 0 c
c
u u ku −ku cos u0 x
m = v v
0
kv sin v0 y = A 0 mC
1 t 0 0 1 1
f ku − f ku cos u0 0
A = 0 f kv sin v0 0
0 p11 p12 p13 p14
0 1 0
A R t = p21 p24
5 p22 p23
p31 p32 p33 p34
R t 11
R t = T
0 1
6
• Depending on the type of problem, the matrix can present the 5 parameters
(general case), 4 (+ = 2 ), 3 (+square pixels) or 1 (+known principal point).
• For the most general case of matrix A , taking into account that the projection
matrix can be decomposed into = P p , where, if the previous point is
fulfilled, P = A R , the following relation results:
P PT = A R ( A R ) = A R RT AT = A AT
T
• Projection between a plane of the world and the image plane: homography.
• Affine interpretation of a projection: real points and points at infinity.
• The absolute conic and the matrix of intrinsic parameters.
• The techniques seen are based on the pin-hole projection model, which
establishes collinearity between a point, its image and the optical center. The
distortion effect of the lenses, mainly of radial type, introduces non-linearities.
• The distortion occurs prior to the affine transformation in the image plane (given
by the internal parameter matrix A ).
Study of the relationship between two projections of the same scene. The main
objective is the location of points of the 3D scene from their 2D projections.
• Displacement effect derived from the projection of a scene from two points of
view with a different optical center: allows to estimate 3D info, makes it difficult to
establish correspondences between single points of both projections, and does
not result in a biunivocal global transform between both image planes.
• Epipolar geometry is the basic restriction that appears when relating the
projections of a scene captured from two points of view. This happens in two
situations:
• Applications:
• If only pairs of homologous points are known ( mi , mi ) one can aspire to
a projective reconstruction, that is, information of the world that is invariant
to projective transformations (what is in front of or behind a plane, and little
more ...).
A x
−x X X
= x = −F P = X =X Z
T
Y
F Z Z p = x = x = −F X
−y Y y Z Y
Y C = 0 0 0
T
= y = −F
F Z Z
A x
x X X
= x=F
F Z Z p = x = x = F X
y Z Y
y Y
= y=F
Y
F Z Z
x F X − Cx
COp= = Y − C
y Z − Cz y
x F X − Cx
A 0 0 1 p = = T
T
y A ( P − C) Y − Cy
A 0 0 1
T
x F HT ( P − C )
H 1 0 0 p = = T
T
T
y A ( P − C) V ( P − C)
V 0 1 0
T
Z Z Z
=
( r1 x + r2 y + r3 F ) Z + Tx F
3D scene-point change: x F
F x = r1 F x + r2 F y + r3 Z + Tx ( r7 x + r8 y + r9 F ) Z + Tz F
X r1 r2 r3 X Tx
Y = r r5 r6 Y + Ty
Z Z Z
y = r4 x + r5 y + r6 Z + Ty y = F ( r4 x + r5 y + r6 F ) Z + Ty F
4
Z r7 r8 r9 Z Tz F F F
( r7 x + r8 y + r9 F ) Z + Tz F
Z Z
Perspective projection: Z = r7 F x + r8 F y + r9 Z + Tz
x F X x F X
y = Z Y , y = Z Y
Observations:
• Invariance against change in a T ⎯⎯
→ k T
x ⎯⎯
→ x
same line of sight. Z ⎯⎯
→ kZ y ⎯⎯
→ y
k
Tz ⎯⎯
→ kTz Z ⎯⎯
→ Z + kTz = kZ Z = Tz
k −1
• The 2D mapping function depends on Z, i.e., the estimation of this 2D transformation does not
allow to obtain an unrestricted 3D transformation.
x F X x F X
y = Z Y , y = Z Y
Fc
Z =
Planar Surface: F − ax − by
Z = aX + bY + c
= 9
r c + Tz 9r c + Tz 9r c + Tz
( r7 c − Tz a ) x + ( r8c − Tzb ) y + ( r9c + Tz ) F r c − Tz a r8c − Tz b
1+ 7 x+ y
F ( r9 c + T )
z F ( r9 c + T )
z
r6 c + Ty r4c − Ty a r5c − Tyb
+ +
y =
( r4 Fc − Ty Fa ) x + ( r5 Fc − Ty Fb ) y + ( r6c + Ty ) F 2
=
r9 c + Tz
F
r9c + Tz
x
r9c + Tz
y
In charge of studying constructions in a real affine plane using ruler and compass, that is, through the synthetic
method, introducing the five postulates of Euclid collected in 'The Elements' (300-BC). Subsequently, and given
that any construction is a repetition of these five basic operations on the same elements (lines and points), they
began to be treated as operations with algebraic symbols (analytic method) and these two approaches began
to diverge.
Felix Klein (1872) gave a formal definition of what is meant by Geometry : he proposed to classify geometric
properties according to their invariance with respect to different groups of transformations.
Klein introduces in the Geometry the algebraic concept of group: associative with respect to an operation or
transformation, with neutral element and with symmetrical element. Each geometry is the study of certain
properties that do not change (invariant) when a type of transformations are applied on a set of elements, which
must have a group structure. Observe that instead of defining a structure (elements + transformation) and to
see what is invariant to that transformation (translation, rotation, similarity, etc.), what is done is to define the
transformation and see over which elements (real points, points at infinity, absolute conic) has to be defined to
make certain properties invariant.
This contribution allows us to classify the geometries, understanding which is a "subgeometry" of which (without
more than identifying a subgroup of a given group of transformations), and confirms that the synthetic and
algebraic methods do not generate different geometries, but actually study the same geometry in each case.
incidence, cross
center of mass
Straightness,
Parallelism,
Connection
Convexity
Geometry Considered transform
Direction
Distance
Angles
ratio
Translation Y Y Y Y Y Y Y
Reflections NO Y Y Y Y Y Y
Homeomorphism
Included by
Homothetic
Conformal Y* NO Y Y Y Y Y
transform
Given the equation of a line in the plane, ax + by + c = 0 , the ( a, b, c ) vector represents it (not its
direction). Any other proportional vector, ( a, b, c ) , also represents it. This class of vectors is known
to be homogeneous. The homogeneous coordinates of a line, r , in the plane are those of any vector of
this class, i.e., are proportional to ( a, b, c ) : r ( a, b, c )
X Y
( X , Y , T ) ( X , Y , T ) ( x, y,1) P2 = 3
− 0 , ( x, y ) 2
, x= ,y=
T T
X ( X , Y , T ) P2
, so that to every point X P2 corresponds a single point x = ( X T , Y T ) , and to this point x
2
Example: equation of a 2
line in homogeneous coordinates, instead of affine coordinates:
X Y
ax + by + c = 0 a + b + c = 0 aX + bY + cT = 0 X Y T a b c = 0
T
T T
T =1 2
T =1
X Y T a b c = 0
T
If we fix the X Y T vector (a point in P 2 ) and vary the a b c vector, we obtain lines that
contain the point.
In conclusión, everything you can demonstrate for the X , Y , T coordinates (i.e., starting from points), is
equally aplicable to the a, b, c coordinates (i.e., starting from lines).
If two parallel lines are expressed in affine coordinates, there is no point that verifies both equations.
However, if they are expressed in homogeneous coordinates, there is a solution:
X Y T
aX + bY + cT = 0
X Y T r1 r2 = det a b c b −a 0
aX + bY + cT = 0
a b c
, which is the direction vector of both lines, or of any line parallel to them. This point (in homogeneous
coordinates), which represents a ray or direction in T = 0 is the point where all these parallel lines cut,
so it is called the infinity point of the line.
, which can be written in matrix form as: XT CX = 0 , for X being a column vector and with the conic
coefficient matrix C given by:
a b 2 d 2
C = b 2 c e 2
d 2 e 2 f
Note that C is symmetric and, as it is an homogeneous representation of the conic (any proportional
matrix fulfils the conic equation), it only presents five degrees of freedom.
In 2 , two conics that cut, may cut in two or four points, except for circles. In P 2 , all conics cut in four
points (circles are not special conics as parallel ar not especial lines): circles might cut in two real points,
but always also cut in two complex points located at infinity: the circular points.
In 3 , two quadric surfaces that intersect, intersect in a fourth-degree curve, except for spheres. In P 3
, spheres always intersect the plane at infinity in a complex conic: the absolute conic.
This is to remark that, the same as parallels, circles are not special elements in Projective Geometry.
Projective space P n : space of dimension n formed by all the elements of the Euclidean space n+1
except the null element Pn = n +1 − 0 , in which given two points X, Y Pn with components
X = ( X1 ,..., X n +1 ) , Y = (Y1 ,..., Yn +1 ) , it is verified that X = Y 0 / X = Y
P1 P2
H Y
X
X
H
Y
X
X
In an affine space this transformation would not be bijective, due to the special treatment of the infinity.
Taking as an example a homography in P 2 :
• The points that verify the relation a31 a32 a33 X Y T = 0 yield tuples of form:
T
y x
ty
tx x'
cos ( ) − sin ( ) t x
R t = sin
In homogeneous coordinates: 0T 1 ( ) cos ( ) t
y
0
0 1
x '
, or, making the proportionality factor R t
y ' = T
explicit:
1
0 1
y
t
Y'
x
X' X
x ' x
y ' = R y + t
In affine coordinates: R RT = I
z ' z
x ' x
y ' t y t
In homogeneous coordinates : R , or R
0T
z ' 1 z 0T
1
1 1
In affine coordinates:
X Y
x= f ,y= f
Z Z
In homogeneous coordinates :
X
x f 0 0 0 Y x fX
y 0 0 0 = yields y = fY x = f X , y = f Y
f , which for
Z Z Z
t 0 0 1 0 t Z
1
In homogeneous coordinates :
x p11 p12 p13 p14
y p p22 p23 p24
21
t p31 p32 p33 p34
m
c
m M m = M
r r12 r13 tx
u u f ku − f ku cos 0 11
t y
u0
m = v v 0 0 21
r r22 r23
f kv sin v0
r r32 r33 tz
1 t 0 0 1 0 31
0 0 0 1
For a pair of corresponding points, m = ( u, v ) and M = ( X , Y , Z ,1) , the following linear relationships
are established from the projection matrix: :
X
u p11 p12 p13 p14 UT M
Y T uW M − U M = 0
T T
v = p21 p22 p23
p24 = V M T
Z T vW M − VT M = 0
1 p31 p32 p33 p34 W M
1
, where UT , VT , WT are the three rows of . If n 6 pairs of points mi = ( ui , vi ) , Mi are used, a
linear system of 2n equations is obtained, which can be put into form L x = 0 , where L is a 2n12
matrix and xT = UT VT WT is the row vector of unknowns formed by the 12 coefficients of the
projection matrix. The solution, generally not exact, can be calculated as the vector corresponding to the
smallest singular value of the SVD (Single Value Decomposition) of L .
Another alternative is to apply the least squares method directly to the expression:
(u WT Mi − UT Mi ) + ( vni WT Mi − VT Mi )
2 2
ni
i
The result, in both cases, are the 12 parameters of a matrix proportional to the projection matrix. To
resolve this ambiguity the result is normalized taking into account that:
p31 p32 p33 = r31 r32 r33 p31 p32 p33 = p31
2
+ p32
2
+ p33
2
=1
Finally, the internal and external parameters are calculated directly from those obtained:
Image obtained from “The Geometry of Multiple Images”, Faugeras & Luong, 2001
Given a plane , if the axes of the world coordinate system are taken as shown in the figure, it is
verified :
p11 p12 p13 p14 p11 p12 p14
m M m p21 p22 p23 p24 = p21 p22 p24 = H M Π
0
p31 p32 p33 p34 p31 p32 p34
, which in coordinates of the image and the
plane results in :
The projections of a set of parallel lines of the world that join in a point of the plane at infinity have to join
in the corresponding point of the image plane. Vice versa, given a point m of the image plane, d = P−1 m
is the direction of the parallels of the world whose projections vanish to it.
O = 0 0 0 1
T
In the projective plane, , the intersection of the line at infinity with any circumference results in two
2
( x − a) + ( y − b) = c 2 x 2 + y 2 − 2ax − 2by + ( a 2 + b2 − c 2 ) = 0
2 2
Affine:
Homogeneous: 2
+ 2
− 2a − 2b + ( a 2 + b2 − c 2 ) 2
=0
I ( i 0) (1 i 0)
Intersection with =0:
2
+ 2
=0 = i
J ( −i 0 ) (1 −i 0 )
In the projective space, , the intersection of the plane at infinity with any sphere results in a complex
3
conic (located in the plane at infinity) that is called the absolute conic c :
= P p 1 0 0
= 0: 2
+ 2
+ 2
= 0 1 0 = 0
0 0 1
ω
The similarities are precisely the homographies that preserve this conic.
that a point m of the image plane corresponds to a point at infinity such that P −1 m = .
The infinite points ( = 0 ) that belong to the absolute conic will verify its equation :
(P m ) ω ( P−1 m ) = 0 ( P−1 m ) ( P −1 m ) = mT P −T P −1 m = 0
−1 T T
Taking into account that P = A R P−T P−1 = ( A R ) ( A R ) = A−T A−1 , it finally results:
−T −1
, that is to say, the points of the image plane that are projection of the absolute conic (called Image of the
Absolute Conic, IAC) form at the same time a conic that is given by the matrix: B = A−T A−1
Note that B does not depend on the position or orientation of the camera, and that once known B , its
inverse is the Krupa matrix K from which A can be directly obtained :
a c u0 a 2 + c 2 + u02 bc + u0 v0 u0
A = 0 b v0 K = B −1 = ( A −T A −1 ) = A AT = bc + u0 v0
−1
b 2 + v02 v0
0 0 1 u0 v0 1
Be a plane = ( 0, 0,1, 0 ) , that is, aligned with the axes X , Y . As it has been seen, for the points of
this plane it is verified :
, from where clearing r1 , r2 and taking into account that they are orthonormal, we obtain the relations :
r1T r2 = 0 ( A−1 h1 ) ( A−1 h2 ) = h1T A−T A−1 h2 = h1T B h2 = 0
T
, which only depend on the orientation of the plane, not on its position. Thus, an orientation of the plane
defines a homography that establishes two linear restrictions in matrix B of the IAC. Since this matrix
only depends on five parameters, it is enough to obtain three homographies (resulting from three
orientations of the plane) to find all their values.
First we obtain an initial approximation to the parameters of the matrix H following the linear method
based on coordinates, but simplified by the fact that Z = 0 , which requires a minimum of n = 4.5 points,
because the "3D" coordinates of the M i points of the board (that is, their 2D positions on the board) it is
possible to calculate them a priori automatically and precisely, and because the marking of the m i points
of the image is possible to assist it with automatic tools.
ˆ i of the points M i
Secondly, the homography obtained is used to calculate the estimated projections m
on the image plane, and iterated to minimize the geometric error :
n
m
i =1
i −m
ˆi
Taking into account that A is known, from the first relation it is possible to obtain the proportionality
factor by imposing unity norm on the rotation vector:
1
A −1 h1 = r1 = 1 =
A −1 h1
A −1 h1 A −1 h 2 A −1 h3
r1 = −1 r2 = −1 t = −1 r3 = r1 ×r2
A h1 A h1 A h1
Note that they are obtained with respect to the origin of world coordinates, that is, with respect to the
origin of coordinates ( X = 0, Y = 0 ) taken in the pattern.
Distortion by which a point of the scene that, in the absence of non-linearities, should be projected at
point m of the image plane, in practice it does so at point m , so that :
m = m + δ ( r , ) = m + δr + δ , being:
By working directly on the image (that is, in pixel coordinates), the following relationship can be
established :
m = cd + L ( r ) ( m − cd )
, m being the corrected point, m the projected point (uncorrected), c d the center of radial distortion
(which does not have to coincide with the principal point), r = m − cd the distance between the
projected point and the center of distortion, and L ( r ) the function that models the variation of distortion
as a function of the aforementioned distance. L ( r ) only takes values for positive r , and in general it can
be approximated in Taylor series by :
The most general approach to the calculation of the L ( r ) function and the distortion center c d is to
impose that the straight line images are effectively straight.
m HM
m H H −1 m = H m
m H M
m HR m, HR = Ha = Hb = H
HR = H = P P −1
This situation does not allow recovering the depth of a point M from its projections, but it does allow, for
example, to obtain the matrix of internal parameters of a rotating camera.
The projection of point M in the image plane (or ) must fall on the straight line projection of the ray Lm
(or Lm ) over (or ), which must be an epipolar line, that is, it must include the epipole e (or e ).
This conclusion restricts the search from m in (or from m in ) to a 1D problem. It only remains to
know the direction of the image plane in which to look for...
The relationship between a projection m (in ) and its epipolar line lm (in ) is the composition of
two projective transformations: that of the Lm ray at point m (of ) and that of the same ray on the
epipolar line lm (of ), both dependent on the position of the cameras (not on the projected point and
ray). Therefore, this relation is also a projective transformation, defined by a 3x3 matrix F that is called
the fundamental matrix and that is unique for a pair of points of view:
lm F m
For calibrated cameras, as we will see later, it is possible to deduce a closed expression for the matrix F
from the projection matrices , . For uncalibrated cameras, F can be obtained from several pairs of
matching projections:
In conclusion, the rank of F must be 2 ( det ( F ) = 0 ) . So, taking into account also the scale
factor, the matrix F just depends on 7 (9-2) parameters.
Calculation of F : each pair of points m, m offers a linear constraint or equation in the parameters of F
. Therefore, 7 points would be enough to calculate it. In practice, due to noise, the calculation is complex.
e m = lm e H m = lm
F m e H m F e H
Now applying this expression to the epipole e :
F e e H e e H e = 0
0
T
The optical center, expressed in homogeneous coordinates C = CT c , has to verify :
−P −1p
C = 0 P C + pc = 0 C
1
−P −1p
e C P p p − PP −1p
1
By applying a planar homography we would obtain the fundamental matrix. Choosing the homography H :
This relationship allows you to obtain F directly in calibrated camera systems and, therefore, obtain the
search direction for homologous points.
, expression that also verifies the epipolar restriction (which in this case forces points m and m to have the
same vertical affine coordinate):
0 0 0
mT F0 m = 0 0 0 1 = − = 0 = v = v
0 −1 0
mT F m = 0
mˆ = H m
( H m ) F0 ( H m ) =
T
ˆ = H m
m
= mT HT F0 H m = 0
F
Disparity map
Absolute conic
Straightness
Mundo
3D World
Reconstrucción
Projective
Plane at infinity proyectiva
reconstruction
‘Real’ points
Reconstrucción
Affine
Reconstrucción ‘euclidea’
Euclidean reconstruction reconstruction
afín