Giacomo Boracchi - CVPR USI 2020

Post on 30-Jan-2022

13 views 0 download

Transcript of Giacomo Boracchi - CVPR USI 2020

Giacomo Boracchi

Single-View GeometryGiacomo Boracchi

giacomo.boracchi@polimi.it

February 25th, 2020

USI, Lugano

Book: HZ, chapter 2

Giacomo Boracchi

Planar Geometry

Today we will study the geometry on the image plane ฮ , and in particular

the properties of points and lines and their relationships

XY

๐‘๐ถ ๐‘

๐‘“

๐‘ฅ

y

๐‘ƒ

๐‘

ฮ 

Giacomo Boracchi

Points in โ„™2

In homogeneous coordinates a point on ฮ  corresponds to a triplet

๐’™ = ๐‘ฅ, ๐‘ฆ, ๐‘ค โŠบ

We will always consider column vectors as these are more convenient in

linear algebra operations

In homogeneous coordinates a point corresponds to a class of equivalence that includes all the scaled versions of ๐’™

๐’™ = ๐‘ฅ, ๐‘ฆ, ๐‘ค โŠบ =๐‘ฅ

๐‘ค,๐‘ฆ

๐‘ค, 1

โŠบ

The latter representation is mapped in โ„2 by removing the last coordinate

๐‘ฅ

๐‘ค,๐‘ฆ

๐‘ค, 1

โŠบ

โ†’๐‘ฅ

๐‘ค,๐‘ฆ

๐‘ค

โŠบ

โˆˆ โ„2

Giacomo Boracchi

Lines in โ„2

In โ„2 the equation of a line ๐‘™ is

๐‘Ž๐‘ฅ + ๐‘๐‘ฆ + ๐‘ = 0

being โˆ’๐‘Ž/๐‘ the angular coefficient and โˆ’๐‘/๐‘ the intercept

๐‘™

โˆ’๐‘Ž/๐‘โˆ’๐‘/๐‘

Giacomo Boracchi

Lines in โ„™2

Thus we can associate a point to each line

๐‘™ โ†’ ๐‘Ž, ๐‘, ๐‘ โŠบ

This association is not one-to-one since ๐œ†๐‘Ž๐‘ฅ + ๐œ†๐‘๐‘ฆ + ๐œ†๐‘ = 0, ๐œ† โ‰  0identifies the same line but with different parameters

๐‘™ โ†’ ๐œ†๐‘Ž, ๐œ†๐‘, ๐œ†๐‘ โŠบ

Thus, representations ๐œ†๐‘Ž, ๐œ†๐‘, ๐œ†๐‘ โŠบ and ๐‘Ž, ๐‘, ๐‘ โŠบ do coincide

Rmk: lines are naturally represented in โ„™2

Rmk: this is the reason why a line has 3 coefficients but indeed only two

degrees of freedom (gradient and intercept)

Rmk: the vector 0,0,0 โŠบ does not correspond to any line

๐‘™

โˆ’๐‘Ž/๐‘โˆ’๐‘/๐‘

Giacomo Boracchi

Incidence relation

A point ๐’™ โˆˆ โ„2, ๐’™ = (๐‘ฅ, ๐‘ฆ) belongs to a line ๐‘™ = ๐‘Ž, ๐‘, ๐‘ โŠบ if and only if

๐‘Ž๐‘ฅ + ๐‘๐‘ฆ + ๐‘ = 0

The above relation can be written as

๐‘Ž, ๐‘, ๐‘ โ‹…๐‘ฅ๐‘ฆ1

= 0

Where โ‹… denotes the scalar product. Then

Property (incidence):

A point ๐’™ โˆˆ โ„™2 lies on the line ๐‘™ if and only if

๐‘™โŠบ๐’™ = ๐’™โŠบ๐‘™ = 0

Giacomo Boracchi

Incidence relation

A point ๐’™ โˆˆ โ„2, ๐’™ = (๐‘ฅ, ๐‘ฆ) belongs to a line ๐‘™ = ๐‘Ž, ๐‘, ๐‘ โŠบ if and only if

๐‘Ž๐‘ฅ + ๐‘๐‘ฆ + ๐‘ = 0

The above relation can be written as

๐‘Ž, ๐‘, ๐‘ โ‹…๐‘ฅ๐‘ฆ1

= 0

Where โ‹… denotes the scalar product. Then

Property (incidence):

A point ๐’™ โˆˆ โ„™2 lies on the line ๐‘™ if and only if

๐‘™โŠบ๐’™ = ๐’™โŠบ๐‘™ = 0

This is the reason why this

number i set to 1 when

moving from Euclidean to

homogeneous coordinates

Giacomo Boracchi

Intersection of lines

Property (intersection of lines):

The intersection of two lines ๐‘™, ๐‘š, their intersection ๐’™ โˆˆ โ„™2 is

๐’™ = ๐‘™ ร— ๐‘š

where ร— denote the cross product of two 3-dimensional vectors.

Giacomo Boracchi

Cross Product

Let ๐’‚, ๐’ƒ โˆˆ โ„3 be two vectors, their cross product is a vector ๐’‚ ร— ๐’ƒ โˆˆ โ„3

โ€ข That is perpendicular to the plane < ๐’‚, ๐’ƒ >

โ€ข Has orientation of the right-hand rule

โ€ข Has lenght proportional to the area of the parallelogram spanned by

the vectors, ๐’‚ ร— ๐’ƒ = ๐’‚ ๐’ƒ sin๐œฝ

By Acdx - Self-made

Giacomo Boracchi

Cross Product

Rmk: the cross product can be also computed as

๐’‚ ร— ๐’ƒ =๐’Š๐‘Ž1๐‘Ž1

๐’‹๐‘Ž2๐‘2

๐’Œ๐‘Ž3๐‘3

being ๐’Š, ๐’‹, ๐’Œ the versors of โ„3 and โ‹… the determinant

Rmk: the cross product is anti-commutative

๐’ƒ ร— ๐’‚ = โˆ’๐’‚ ร— ๐’ƒ

But this is not an issue when we want to intersect two lines, since the

result in the same point of โ„™2 (equivalence up to a multiplication by โˆ’1)

Giacomo Boracchi

Cross Product

Rmk: the cross product is distributive over addition

๐’‚ ร— ๐’ƒ + ๐’„ = ๐’‚ ร— ๐’ƒ + ๐’‚ ร— ๐’„

Rmk: the cross product is compatible with scalar product

๐œ† ๐’‚ ร— ๐’ƒ = ๐œ†๐’‚ ร— ๐’ƒ = ๐’‚ ร— ๐œ†๐’ƒ

Giacomo Boracchi

Cross Product

Rmk: the cross product is not associative

๐’‚ ร— ๐’ƒ ร— ๐’„ โ‰  ๐’‚ ร— ๐’ƒ ร— ๐’„

Rmk: the triple scalar product identity follows by definition of cross

product (which is orthogonal to both terms)

๐’‚ โ‹… ๐’‚ ร— ๐’ƒ = ๐’ƒ โ‹… ๐’‚ ร— ๐’ƒ = 0

This also proves the fact the intersection of two lines ๐‘™ โˆฉ ๐‘š is ๐’™ = ๐‘™ ร— ๐‘š

In fact ๐’™ belongs to both ๐‘™ and ๐‘š since the incidence equation is satisfied

๐‘™ โ‹… ๐‘™ ร— ๐‘š = ๐‘š โ‹… ๐‘™ ร— ๐‘š = 0

Giacomo Boracchi

Line joining two points

Property: given ๐’™, ๐’š โˆˆ โ„™2, the line ๐‘™ joining ๐’™ and ๐’š is

๐‘™ = ๐’™ ร— ๐’š

Rmk this can be verified by checking that both ๐’™ and ๐’š belong to ๐’™ ร— ๐’šthrough the incidence equation

Rmk: we have seen that the cross product is anti-commutative

๐’™ ร— ๐’š = โˆ’๐’š ร— ๐’™

This is not an issue for the resulting lines, since these are intrinsecally

equivalent up to a multiplication by a scalar

Giacomo Boracchi

An interesting property

An interesting property, given two points in homogeneous coordinates

๐‘Ž = ๐‘Ž1; ๐‘Ž2; ๐‘Ž3 and ๐‘ = ๐‘1; ๐‘2; ๐‘3 any linear combination ๐œ†๐‘Ž + ๐œ‡๐‘,๐œ†, ๐œ‡ โˆˆ โ„ belongs to the line joining ๐‘Ž, ๐‘

Proof

Let ๐‘™ = ๐‘Ž ร— ๐‘, for which holds ๐‘™โŠบ๐‘Ž = ๐‘™โŠบ๐‘ = 0 (incidence equation)

Then, ๐œ†๐‘Ž + ๐œ‡๐‘ ๐‘™โŠบ = ๐œ†๐‘Ž๐‘™โŠบ + ๐œ‡๐‘๐‘™โŠบ = 0 + 0

Giacomo Boracchi

Angles in the Euclidean Plane

In Euclidean geometry the angle between two lines is computed from the

dot product of their normals. For the lines ๐‘™ = (๐‘™1; ๐‘™2; ๐‘™3), and ๐‘š =(๐‘š1;๐‘š2;๐‘š3), the angle ๐œƒ is such that

cos ๐œƒ =๐‘™1๐‘š1 + ๐‘™2๐‘š2

๐‘™12 + ๐‘™2

2 (๐‘š12 +๐‘š2

2)

We will see later interesting properties on projective plane

Giacomo Boracchi

Intersection of parallel Lines

Consider two parallel lines ๐‘™ = ๐‘Ž, ๐‘, ๐‘ and ๐‘š = (๐‘Ž, ๐‘, ๐‘‘), then their intersection is:

๐‘™ ร— ๐‘š =๐’Š๐‘Ž๐‘Ž

๐’‹๐‘๐‘

๐’Œ๐‘๐‘‘

= ๐’Š ๐‘๐‘‘ โˆ’ ๐‘๐‘ โˆ’ ๐’‹ ๐‘Ž๐‘‘ โˆ’ ๐‘Ž๐‘ + ๐’Œ ๐‘Ž๐‘ โˆ’ ๐‘Ž๐‘

๐‘™ ร— ๐‘š =๐‘๐‘‘ โˆ’ ๐‘๐‘๐‘Ž๐‘ โˆ’ ๐‘Ž๐‘‘

0= (๐‘‘ โˆ’ ๐‘)

๐‘โˆ’๐‘Ž0

That corresponds to the homogeneous point ๐’™ = ๐‘,โˆ’๐‘Ž, 0 โŠบ

Rmk if we try to move to Euclidean coordinates we get ๐‘

0,๐‘Ž

0which goes

to infinity.

These are the ideal points or points at the infinity

Giacomo Boracchi

Point at the Infinity

Definition: a point of โ„™2 with the third coordinate equal zero is a point at

the infinity (or ideal point)

Rmk: ๐‘™ = ๐‘Ž, ๐‘, ๐‘ โŠบ passes through the ideal point ๐‘™โˆž = ๐‘,โˆ’๐‘Ž, 0 โŠบ

Rmk: ideal points can be seen as sort of directions

Rmk: โ„™2 augments โ„2 by including directions

Rmk: finite points in โ„™2 are those having the third coordinate โ‰  0 and

these corresponds to โ„2 up to a normalization factor

Giacomo Boracchi

Line at the infinity โ„“โˆž

Property: all the ideal points lie in the line at the infinity โ„“โˆž having

coordinates

โ„“โˆž = 0; 0; 1

Rmk: Thanks to ideal points

โ€ข any pair of lines in โ„™2 intersect in a single (homogeneous) point.

โ€ข any pair of points of โ„™2 lie a single line

This does not hold in โ„2 where parallel lines do not meet.

โ„“โˆž๐‘™1 ๐‘™2

๐‘šโˆž๐‘š1๐‘š2

๐‘™โˆž

Giacomo Boracchi

Example

Isometric cube, draw missing points as the intersection of lines parallel to

this and passing through another point

Giacomo Boracchi

A model for โ„™2

Points of โ„™2 are represented by all the rays of

โ„3 through the origin, since all

๐’™ = ๐œ† ๐‘Ž; ๐‘; 1 , โˆ€๐œ†

corresponds to the same point

Lines of โ„™2 are represented as planes passing

through the origin

The Euclidean plane is the plane ๐’™๐Ÿ‘ = 1 and

projection to Euclidean coordinates is

computing the intersection between the ray and

the plane ฮ , i. e. , ๐’™๐Ÿ‘ = 1.

Lines lying in the plane ๐’™๐Ÿ‘ = 0 represent ideal

points (directions) as these do not instersect ฮ .Hartley Zisserman Fig.2.1

Giacomo Boracchi

Point Line Duality in โ„™2

Duality principle. To any theorem of 2-dimensional projective geometry (โ„™2)there corresponds a dual theorem, which may be derived by interchanging the roles of points and lines in the original theorem.

Theorem Dual Theorem

- Point โ†’ - Line

- Line โ†’ - Point

- Belongs to โ†’ - Go through

- Go through โ†’ - Belongs to

E.g. The incidence equation, the line passing through two points which has the same formulation of the intersection between lines

Rmk: Note that is it not necessary to prove the dual of a given theorem once the original theorem has been proved

Giacomo Boracchi

Linear Combinations in โ„™2

An interesting property, given two points in homogeneous coordinates

๐‘Ž = ๐‘Ž1; ๐‘Ž2; ๐‘Ž3 and ๐‘ = ๐‘1; ๐‘2; ๐‘3 any linear combination ๐œ†๐‘Ž + ๐œ‡๐‘,๐œ†, ๐œ‡ โˆˆ โ„ belongs to the line joining ๐‘Ž, ๐‘

Proof

Let ๐‘™ = ๐‘Ž ร— ๐‘, for which holds ๐‘™โ€ฒ๐‘Ž = ๐‘™โ€ฒ๐‘ = 0 (incidence equation)

Then, ๐œ†๐‘Ž + ๐œ‡๐‘ ๐‘™โ€ฒ = ๐œ†๐‘Ž๐‘™โ€ฒ + ๐œ‡๐‘๐‘™โ€ฒ = 0 + 0

Giacomo Boracchi

Single-View GeometryGiacomo Boracchi

giacomo.boracchi@polimi.it

February 28th, 2020

USI, Lugano

Book: HZ, chapter 4

Giacomo Boracchi

Outline

โ€ข Trasformations in โ„™2

โ€ข The Projective Space โ„™3

โ€ข Vanishing Points

โ€ข Affine Rectification

Giacomo Boracchi

Transformations in โ„™2

Giacomo Boracchi

Homographies

The most general transformation we consider in โ„™2

Definition A projectivity is an invertible mapping โ„Ž from โ„™2 to itself such

that three points ๐’™๐Ÿ, ๐’™๐Ÿ and ๐’™3 lie on the same line if and only if โ„Ž(๐’™1), โ„Ž(๐’™2) and โ„Ž(๐’™3) do.

Rmk this property is called collinearity

Alternative names

โ€ข Collineation

โ€ข Projective transformation

โ€ข Homography

๐‘Œ๐ธ๐‘†

๐‘๐‘‚

Giacomo Boracchi

Homographies

Theorem 2.10. A mapping โ„Ž:โ„™2 โ†’ โ„™2 is a projectivity if and only if there

exists a non-singular 3 ร— 3 matrix ๐ป such that for any point in โ„™2

represented by a vector ๐’™ it is true that โ„Ž(๐’™) = ๐ป๐’™

๐ป =

โ„Ž1,1โ„Ž2,1โ„Ž3,1

โ„Ž1,2โ„Ž2,2โ„Ž3,2

โ„Ž1,3โ„Ž2,3โ„Ž3,3

Each and every linear mapping in โ„™2 is an homography, and only linear

mapping are homographies

Giacomo Boracchi

Homographies and Points in โ„™2

From theorem follows

๐’™โ€ฒ = ๐ป๐’™

Rmk: if we scale both ๐’™โ€ฒ and ๐’™ by arbitrary factors the relation holds

since we are in โ„™2

๐’™โ€ฒ = ๐œ†๐ป๐’™, โˆ€๐œ† โˆˆ โ„\{0}

Thus, ๐ป has 9 entries but only 8 degrees of freedom, since only the ratio

between the elements counts. ๐ป is said to be an homogeneous matrix.

Giacomo Boracchi

Homographies and Lines in โ„™2

An homography transform each line ๐’ in a line ๐‘š such that:

๐‘š = ๐ปโˆ’1 โŠบ ๐‘™

We say that points transform contravariantly and lines and conics

transform covariantly.

Giacomo Boracchi

Mapping between planes: homography

Mapping between planes induced by a central projection is an

homography, as this preserves collinearity

If a coordinate system is defined in each plane and points are represented

in homogeneous coordinates, then the central projection mapping may be

expressed by

๐’™โ€ฒ = ๐ป๐’™

where ๐ป is a non-singular

3 ร— 3 matrix

Hartley Zisserman Fig.2.3

Giacomo Boracchi

Other examples where homographies apply

Hartley Zisserman Fig.2.5

Giacomo Boracchi

A Hierarchy of Transformations

Giacomo Boracchi

Linear Transformation

We consider linear transformations of โ„™2,

โ€ข these can be expressed as a 3 ร— 3 matrix ๐ป,

โ€ข the homogeneous constraint applies

Depending on the structure of ๐ป there are different class of

transformations with a different number of degrees of freedom

Giacomo Boracchi

Isometries

Giacomo Boracchi

Isometries

H =

0.8660 -0.5000 0

0.5000 0.8660 0

0 0 1.0000

theta =

30

eps =

1

Giacomo Boracchi

Isometries

H =

0.8660 -0.5000 0

0.5000 0.8660 0

0 0 1.0000

theta =

30

eps =

-1

Giacomo Boracchi

Isometries

Isometries can be written as

๐’™โ€ฒ = ๐ป๐ผ๐’™

where

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’sin๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ๐‘ก๐‘ฆ1

๐‘ฅ๐‘ฆ1

and ๐œ– = ยฑ1.

Giacomo Boracchi

Isometries

Isometries can be written as

๐’™โ€ฒ = ๐ป๐ผ๐’™

A more compact representation is

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin ๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ

1

๐‘ฅ๐‘ฆ1

where R โˆˆ ๐‘‚(2) is a rotation matrix, i.e. an orthogonal matrix

RโŠบR = RRโŠบ = ๐ผ2

And ๐ญ โˆˆ โ„๐Ÿ is a translation vector .

Pure rotation ๐ญ = [0; 0], pure translation R = ๐ผ2

R ๐ญ๐ŸŽโŠบ

Giacomo Boracchi

Isometries: Invariants

Isometries describe a 2D motion of a rigid object

Isometries preserves the angles, the distances, the areas.

Giacomo Boracchi

Isometries: Remarks

Isometries have three degrees of freedom: the rotation angle ๐œƒ and the

translation vector [๐‘ก๐‘ฅ , ๐‘ก๐‘ฆ]

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ๐‘ก๐‘ฆ1

๐‘ฅ๐‘ฆ1

Rmk Isometries can be estimated from two point correspondences

Rmk When ๐œ– = 1 the isometry preserves the orientation, when ๐œ– = โˆ’1the isometry reverses the orientation.

For instance diag(โˆ’1,1,1) is a reflection

Giacomo Boracchi

Isometries: Remarks

Isometries have three degrees of freedom: the rotation angle ๐œƒ and the

translation vector [๐‘ก๐‘ฅ , ๐‘ก๐‘ฆ]

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ๐‘ก๐‘ฆ1

๐‘ฅ๐‘ฆ1

Rmk Isometries do not modify ideal points:

โ€ข Ideal points in โ„™2 remain ideal points (they might change but always

remain ideal points in โ„“โˆž)

โ€ข Finite points in โ„™2 remain finite points

โ€ข โ„“โˆž = ๐ป๐ผโˆ’โŠบโ„“โˆž

Giacomo Boracchi

Similarities

Giacomo Boracchi

Similarities

H =

1.2990 -0.7500 0

0.7500 1.2990 0

0 0 1.0000

s =

1.5

theta=

30

Giacomo Boracchi

Similarities

Similarities can be written as

๐’™โ€ฒ = ๐ป๐‘†๐’™

where

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐‘  cos ๐œƒ๐‘  sin ๐œƒ0

โˆ’๐‘  sin ๐œƒ๐‘  cos ๐œƒ0

๐‘ก๐‘ฅ๐‘ก๐‘ฆ1

๐‘ฅ๐‘ฆ1

and ๐‘  โˆˆ โ„

Rmk Similarities can be seen as an isometry composed with an isotropic

scaling of the axis

Giacomo Boracchi

Similarities

Similarities can be written as

๐’™โ€ฒ = ๐ป๐‘†๐’™

A more compact representation is

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin ๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ

1

๐‘ฅ๐‘ฆ1

where

โ€ข ๐‘  โˆˆ โ„ is the scaling factor

โ€ข R โˆˆ ๐‘‚(2) is a rotation matrix,

โ€ข ๐ญ โˆˆ โ„๐Ÿ is a translation vector.

๐‘ R ๐ญ๐ŸŽโŠบ

Giacomo Boracchi

Similarities: Invariants

Similarities are also known as equi-form transformations

Similarities preserves the angles and the shapes, while not the length and

the areas.

The ratio between lengths and areas is preserved since the scaling factor

cancels out

Giacomo Boracchi

Similarities : Properties

Similarities have four degrees of freedom: the scaling factor ๐‘ , the rotation

angle ๐œƒ and the translation vector [๐‘ก๐‘ฅ , ๐‘ก๐‘ฆ]

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐‘  cos ๐œƒ๐‘  sin ๐œƒ0

โˆ’๐‘  sin ๐œƒ๐‘  cos ๐œƒ0

๐‘ก๐‘ฅ๐‘ก๐‘ฆ1

๐‘ฅ๐‘ฆ1

Rmk โ„“โˆž = ๐ป๐‘†โˆ’โŠบโ„“โˆž, thus finite points remain finite points

Rmk Similarities can be estimated from two point correspondences

Metric structure means that the structure is preserved up to a scaling

Giacomo Boracchi

Affinities

Giacomo Boracchi

Affine Transformation

H =

3.5784 -1.3499 0

2.7694 3.0349 0

0 0 1.0000

det(A) =

14.5985

Giacomo Boracchi

Affinities

Affinities can be written as

๐’™โ€ฒ = ๐ป๐ด๐’™

where

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=

๐‘Ž1,1๐‘Ž2,10

๐‘Ž1,2๐‘Ž2,20

๐‘ก๐‘ฅ๐‘ก๐‘ฆ1

๐‘ฅ๐‘ฆ1

and ๐‘Ž1,1๐‘Ž2,1

๐‘Ž1,2๐‘Ž2,2

is an invertible matrix

Giacomo Boracchi

Affinities

Affinities can be written as

๐’™โ€ฒ = ๐ป๐ด๐’™

A more compact representation is

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin ๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ

1

๐‘ฅ๐‘ฆ1

where

โ€ข ๐ด โˆˆ โ„2,2 is an invertible matrix

โ€ข ๐ญ โˆˆ โ„๐Ÿ is a translation vector.

Rmk Affinities can be seen as a linear, non singular transformation of

followed by a translation

๐ด ๐ญ๐ŸŽโŠบ

Giacomo Boracchi

Decomposition of Affinities

The linear part of the affine transformation can be seen as the

composition of two fundamental transformations:

โ€ข rotation

โ€ข and non-isotropic scaling.

The affine matrix A can always be decomposed

๐ด = ๐‘…(๐œƒ) ๐‘…(โˆ’๐œ‘)๐ท๐‘…(๐œ‘)

where ๐‘…(๐œƒ) and ๐‘…(๐œ‘) are rotations by ๐œƒ and ๐œ‘ respectively, and ๐ท is

๐ท =๐œ†10

0๐œ†2

Giacomo Boracchi

Decomposition of Affinities

This decomposition can be obtained via ๐‘†๐‘‰๐ท ๐ด

๐ด = ๐‘ˆ๐ท๐‘‰โŠบ, being ๐‘ˆ๐‘ˆโŠบ = ๐‘‰๐‘‰โŠบ = ๐ผ2๐ด = ๐‘ˆ ๐‘‰๐‘‰โŠบ ๐ท๐‘‰โŠบ =

๐ด = ๐‘ˆ๐‘‰ ๐‘‰โŠบ๐ท๐‘‰โŠบ

๐ด = ๐‘…(๐œƒ) ๐‘…(โˆ’๐œ‘)๐ท๐‘…(๐œ‘)

non-isotropic

scaling.

Giacomo Boracchi

Non-isotropic Scaling in Affinities

Hartley Zisserman Fig.2.7

Giacomo Boracchi

Affinities: Invariants

Due to the non-isotropic scaling, the similarity invariants of length ratios

and angles between lines are not preserved under an affinity.

Affinities preserves

โ€ข Parallel lines, since โ„“โˆž = ๐ป๐ดโˆ’โŠบโ„“โˆž

โ€ข Ratio of lengths over parallel lines

โ€ข Ratio of areas (since each area is scaled of det(๐ด), which cancels out)

Giacomo Boracchi

Affinities: Properties

Similarities have six degrees of freedom: the four terms of ๐ด and the

translation vector [๐‘ก๐‘ฅ , ๐‘ก๐‘ฆ]

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=

๐‘Ž1,1๐‘Ž2,10

๐‘Ž1,2๐‘Ž2,20

๐‘ก๐‘ฅ๐‘ก๐‘ฆ1

๐‘ฅ๐‘ฆ1

Rmk Similarities can be estimated from four point correspondences

Rmk โ„“โˆž = ๐ป๐ดโˆ’โŠบโ„“โˆž, thus finite points remain finite points

Giacomo Boracchi

Homographies

Giacomo Boracchi

Projective Transformation

H =

-1.0689 -2.9443 0

-0.8095 1.4384 0

0.0100 0.0010 1.0000

det(A) =

-3.9209

Giacomo Boracchi

Homographies

Homographies are the most general transformation in homogeneous

coordinates, and can be written as

๐’™โ€ฒ = ๐ป๐‘ƒ๐’™

namely

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin ๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ

๐‘ฃ

๐‘ฅ๐‘ฆ1

where ๐’— = [๐‘ฃ1; ๐‘ฃ2] and ๐‘ฃ โˆˆ โ„ (possibly zero)

While this transformation applies in โ„™2, it is not always possible to scale

๐ป๐‘ƒ to have ๐‘ฃ = 1, as this might be zero.

๐ด ๐ญ๐’—โŠบ

Giacomo Boracchi

Homographies: Invariants

Homographies generalize an affine transformation, which is the

composition of a general non-singular linear transformation of

inhomogeneous coordinates and a translation.

Invariants: the cross ratio of four collinear points: a ratio of lengths on a

line is invariant under affinities, but not under projectivities. However, a

ratio of ratios or cross ratio of lengths on a line is a projective invariant.

๐‘ƒ3 โˆ’ ๐‘ƒ1 ๐‘ƒ4 โˆ’ ๐‘ƒ2๐‘ƒ3 โˆ’ ๐‘ƒ2 ๐‘ƒ4 โˆ’ ๐‘ƒ1

๐‘ƒ1

๐‘ƒ2

๐‘ƒ3๐‘ƒ4

Giacomo Boracchi

Homographies: Invariants

The matrix has nine elements with only their ratio significant, so the

transformation is specified by eight parameters

A projective transformation between two planes can be computed from

four point correspondences, with no three collinear on either plane.

Giacomo Boracchi

Homographies: Properties

Similarities have eight degrees of freedom: the four terms of ๐ด and the

translation vector [๐‘ก๐‘ฅ , ๐‘ก๐‘ฆ]

๐‘ฅโ€ฒ๐‘ฆโ€ฒ1

=๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin ๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ

๐‘ฃ

๐‘ฅ๐‘ฆ1

Rmk Homographies can be estimated from four point correspondences

Rmk โ„“โˆž โ‰  ๐ป๐‘ƒโˆ’โŠบโ„“โˆž when ๐’— โ‰  ๐ŸŽ, thus ideal points might become finite

points. For instance given ๐’™ = ๐‘ฅ1; ๐‘ฅ2; 0 , then

๐ป๐‘ƒ๐’™ =

โ€ฆโ€ฆ

๐‘ฃ1๐‘ฅ + ๐‘ฃ2๐‘ฆ + ๐‘ฃ0

๐ด ๐ญ๐’—โŠบ

Giacomo Boracchi

Homographies: Properties

Under a projective transformation ideal points may be mapped to finite

points, and consequently โ„“โˆž is mapped to a finite line.

However, if the transformation is an affinity (๐’— = [0, 0]), then โ„“โˆž is not

mapped to a finite line, but remains at infinity.

The image of ๐‘™โˆž is

๐ปโˆ’1 โŠบ ๐‘™โˆž

๐œ– cos ๐œƒ๐œ– sin ๐œƒ0

โˆ’ sin๐œƒcos ๐œƒ0

๐‘ก๐‘ฅ

๐‘ฃ

001

=๐‘ฃ1๐‘ฃ2๐‘ฃ

๐ดโˆ’โŠบ ๐’—

๐’•โˆ’โŠบ๐ดโˆ’โŠบ

Giacomo Boracchi

Affine Trasformation and Line at Infinity

Rmk: ๐‘™โˆž is not fixed pointwise under an affine transformation

Under an affinity a point on ๐‘™โˆž (i.e., an ideal point) can be mapped to a

different point on ๐‘™โˆž. This is the reason why orthogonality is lost.

Giacomo Boracchi

Affine Rectification

Hartley Zisserman Fig.2.6

Giacomo Boracchi

Summarizing

Hartley Zisserman Tab 2.1

Giacomo Boracchi

Summarizing

Hartley Zisserman Tab 2.1

Transformations higher in the

table can produce all the actions

of the ones below

Giacomo Boracchi

Homographies: Properties

For a given affinity the areas are scaled of det ๐ด anywhere on the plane;

and the orientation of a transformed line depends only on its initial

orientation, not on its position on the plane.

In contrast, area scaling in homographies varies with position (e.g. under

perspective a more distant square on the plane has a smaller image than

one that is nearer)

Giacomo Boracchi

The Projective Space โ„™3

Giacomo Boracchi

Points and Planes in โ„™3

A point in โ„™3 is defined as

๐‘‹ = ๐‘ฅ; ๐‘ฆ; ๐‘ง; 1

The incidence equation for a plane (i.e. ๐’™ โˆˆ ๐œ‹) is

๐‘Ž๐‘ฅ + ๐‘๐‘ฆ + ๐‘๐‘ง + ๐‘‘ = 0

Which can be written in matrix form as

๐‘Ž, ๐‘, ๐‘, ๐‘‘ โ‹… ๐‘‹ = 0

And this implies that the plane is identified by a vector in โ„™3

๐œ‹ = ๐‘Ž; ๐‘; ๐‘; ๐‘‘

Rmk planes have 3 degrees of freedom, since their equation holds up to a scaling of a parameter

Rmk planes in โ„™3 are plays the same role as lines in โ„™2

๐‘ฅ

๐‘ฆ

๐‘ง

Giacomo Boracchi

Lines in โ„™3

More difficult to represent.

They have 4 degrees of freedom:

โ€ข Their direction

โ€ข The distance from the origin

(along the plane orthogonal to the direction)

Lines in โ„™3 are defined as intersections of two planes

๐‘ฅ

๐‘ฆ

๐‘ง

Giacomo Boracchi

Number of parameters of a line

Hartley Zisserman Fig.3.1

Giacomo Boracchi

The Plane at infinity

The plane at infinity has the canonical position

๐œ‹โˆž = 0; 0; 0; 1

in affine 3D-space.

๐œ‹โˆžcontains ideal points (directions) ๐‘ƒโˆž = [๐‘ฅ; ๐‘ฆ; ๐‘ง; 0], and enables the

identification of affine properties such as parallelism.

In particular:

โ€ข Two planes are parallel if and only if their line of intersection is on ๐…โˆž

โ€ข A line is parallel to another line, or to a plane, if their point of

intersection is on ๐…โˆž

Giacomo Boracchi

The Plane at infinity

Giacomo Boracchi

Ideal Points in โ„™3

Ideal points in โ„™3 are defined similarly to ideal points in โ„™2

Ideal points are the intersection of parallel lines.

โ€ข All the parallel lines in the space intersect in the same ideal point ๐‘ƒโˆž

๐‘ฅ

๐‘ฆ

๐‘ง๐‘ƒโˆž โˆˆ ๐œ‹โˆž

Giacomo Boracchi

Planes in โ„™3 and ideal lines

โ€ข A plane ๐œ‹ contains infinite parallel lines along infinite directions

โ€ข Each set of parallel lines intersect in an ideal point (belonging to ๐œ‹โˆž)

โ€ข All these ideal points lie on the ideal line โ„“โˆž(๐œ‹): the line at infinity of ๐œ‹

๐ดโˆž โˆˆ ๐œ‹โˆž

๐ถโˆž โˆˆ ๐œ‹โˆž

๐œ‹

โ„“โˆž(๐œ‹)

๐ตโˆž โˆˆ ๐œ‹โˆž

Giacomo Boracchi

Consider the plane of the earth

Giacomo Boracchi

Consider the plane of the earth, which contains

a few parallel lines

Giacomo Boracchi

These are not anymore parallel

Giacomo Boracchi

Homography is the mapping among two planes

Hartley Zisserman Fig.

Giacomo Boracchi

Vanishing point

๐‘ฃ

Giacomo Boracchi

A set of parallel lines in the world plane intersect

in a point in the image, the vanishing point

๐‘ฃ

Giacomo Boracchi

Vanishing points

Vanishing points are the projection in the image plane of ideal points in

the 3D world

If a line has direction ๐’…, then it intersects ๐œ‹โˆž in the point ๐‘‹โˆž = [๐’…; 0]

Then the vanishing point ๐‘ฃ is the image of ๐‘‹โˆž by means of the camera

matrix ๐‘€ = ๐พ[๐ผ3, ๐ŸŽ] (consider the camera center as the origin)

๐‘ฃ = ๐‘€๐‘‹โˆž = ๐พ ๐ผ3, ๐ŸŽ โ‹… [๐’…; 0] = ๐พ๐’…

Hartley Zisserman Fig.8.14

Giacomo Boracchi

Vanishing points

When ๐‘‹ โ†’ โˆž along a line, its image converges to ๐‘ฃ, which is the

intersection of the image plane with the line passing through ๐ถ and

directed as ๐‘‹

Hartley Zisserman Fig.8.14

Equally spaced pointsThe spacing among

image points

monotinically

decreases

Giacomo Boracchi

Vanishing points

Vanishing points are the projection in the image plane of ideal points in

the 3D world

Hartley Zisserman Fig.8.14

Giacomo Boracchi

Horizon

Horizon or Vanishing line for a plane ๐œ‹ is the image of the line at the

infinity of that plane, โ„“โˆž(๐œ‹)

Horizon helps humans to intuitively deduce properties about the image

that might not be apparent mathematically.

We can understand when two lines are parallel in the 3D world, since they

intersect with the horizon

Giacomo Boracchi

Horizon

Giacomo Boracchi

Remember!

The horizon line holds for a single plane of the 3D world

When the image contains multiple planes,

there is an horizon line for each of these

And ideal points of lines in a plane

are often not the same of lines on other

planes

Giacomo Boracchi

โ„“โˆž(๐œ‹3)

โ„“โˆž(๐œ‹1)

โ„“โˆž(๐œ‹2)

๐œ‹3๐œ‹1

๐œ‹2

Giacomo Boracchi

Affine Rectification

Idea:

โ€ข Identify the โ„“โˆž in the image

โ€ข transform the identified โ„“โˆž to its canonical position of [0; 0; 1]

Let ๐‘™ = (๐‘™1; ๐‘™2; ๐‘™3) be the image of the line at the infinity with ๐‘™3 โ‰  0,

A suitable homography which maps ๐‘™ back to โ„“โˆž = [0; 0; 1] is

๐ป = ๐ป๐ด

1 0 00 1 0๐‘™1 ๐‘™2 ๐‘™3

Giacomo Boracchi

Affine Rectification

Idea:

โ€ข Identify the โ„“โˆž in the image

โ€ข transform the identified โ„“โˆž to its canonical position of [0; 0; 1]

Let ๐‘™ = (๐‘™1; ๐‘™2; ๐‘™3) be the image of the line at the infinity with ๐‘™3 โ‰  0,

A suitable homography which maps ๐‘™ back to โ„“โˆž = [0; 0; 1] is

๐ป = ๐ป๐ด

1 0 00 1 0๐‘™1 ๐‘™2 ๐‘™3

Rmk: ๐‘™ can be rescaled to improve conditioning of ๐ป

Giacomo Boracchi

Affine Rectification

Hartley Zisserman Fig.2.12

Giacomo BoracchiHartley Zisserman Fig. 2.13

Giacomo Boracchi

Single-View GeometryGiacomo Boracchi

giacomo.boracchi@polimi.it

March 3rd, 2020

USI, Lugano

Book: HZ, chapter 2,3

Giacomo Boracchi

Outline

โ€ข DLT Algorithm for Least Squares Fitting in โ„™2

โ€ข Homography estimation

โ€ข Camera Calibration

โ€ข Applying Point Trasformations to Images

โ€ข Conics in โ„™2

โ€ข Conic Fitting

Giacomo Boracchi

DLT algorithm

HZ chapter 4

Giacomo Boracchi

DLT

Direct Linear Trasformation (DLT) algorithm, solves many relevant

problems in Computer Vision

โ€ข 2D Homography estimation

โ€ข Camera projection matrix estimation (projections from 3D to 2D)

โ€ข Fundamental matrix computation

โ€ข Trifocal tensor computation

Giacomo Boracchi

Homography estimation

We consider a set of point correspondences

๐’™๐’Šโ€ฒ, ๐’™๐’Š , ๐‘– = 1,โ€ฆ , 4

belonging to two different images. Our problem is to compute a ๐ป โˆˆ โ„3ร—3

such that ๐’™๐’Šโ€ฒ = ๐ป๐’™๐’Š for each ๐‘–.

Rmk if we look at ๐’™ as a 3d vector the equality ๐’™๐’Šโ€ฒ = ๐ป๐’™๐’Š does not hold

Equality holds in โ„™2 (but linear systems are solved as in โ„3).

What makes the DLT is distinct from standard cases since the left and

right sides of the defining equation can differ by an unknown

multiplicative factor which is dependent on the number of equations.

Giacomo Boracchi

DLT for Homography Estimation

In โ„3, ๐’™๐’Šโ€ฒ and ๐’™๐’Š have the same direction, but may differ in magnitude.

Therefore collinearity constraints can be written as

๐’™๐’Šโ€ฒ ร— ๐ป๐’™๐’Š = ๐ŸŽ , ๐‘– = 1,โ€ฆ , 4

where ๐ŸŽ = [0; 0; 0]

By Acdx - Self-made

Giacomo Boracchi

DLT for Homography Estimation

Let ๐’™๐’Š = ๐‘ฅ๐‘–; ๐‘ฆ๐‘–; ๐‘ค๐‘– and ๐ป = [๐’‰๐ŸโŠบ ; ๐’‰๐Ÿ

โŠบ ; ๐’‰๐Ÿ‘โŠบ ] being ๐’‰1

โŠบ

Then the cross product can be written as..

๐’™๐’Šโ€ฒ ร— ๐ป๐’™๐’Š =

๐‘ฆ๐‘–โ€ฒ๐’‰๐Ÿ‘

โŠบ ๐’™๐’Š โˆ’๐‘ค๐‘–โ€ฒ๐’‰๐Ÿ

โŠบ ๐’™๐’Š๐‘ค๐‘–โ€ฒ๐’‰๐Ÿ

โŠบ ๐’™๐’Š โˆ’ ๐‘ฅ๐‘–โ€ฒ๐’‰๐Ÿ‘

โŠบ ๐’™๐’Š๐‘ฅ๐‘–โ€ฒ๐’‰๐Ÿ

โŠบ ๐’™๐’Š โˆ’ ๐‘ฆ๐‘–โ€ฒ๐’‰๐Ÿ

โŠบ ๐’™๐’Š

Giacomo Boracchi

DLT for Homography Estimation

And after some linear algebra, this can be expressed in a matrix form as

๐ŸŽโŠบ

๐‘คโ€ฒ๐‘–๐’™๐’ŠโŠบ

โˆ’๐‘ฆโ€ฒ๐‘–๐’™๐’ŠโŠบ

โˆ’๐‘คโ€ฒ๐‘–๐’™๐’ŠโŠบ

๐ŸŽโŠบ

๐‘ฅโ€ฒ๐‘–๐’™๐’ŠโŠบ

๐‘ฆโ€ฒ๐‘–๐’™๐’ŠโŠบ

โˆ’๐‘ฅ๐‘–๐’™๐’ŠโŠบ

๐ŸŽโŠบ

๐’‰๐Ÿ

๐’‰๐Ÿ

๐’‰๐Ÿ‘

= 0

This is a 3 ร— 9 matrix multiplied times a vector of 9 elements

Rmk The equation is an equation linear in the unknown vector

๐’‰ = ๐’‰๐Ÿ ; ๐’‰๐Ÿ ; ๐’‰๐Ÿ‘

Rmk the three rows of the matrix are linearly dependent (the third row is

the sum of โˆ’๐‘ฅ๐‘–/๐‘ค๐‘– times the first row and โˆ’๐‘ฆ๐‘–/๐‘ค๐‘– times the second)

Giacomo Boracchi

DLT for Homography Estimation

Thus, keep only two rows giving rise to an homogeneous linear system

๐ŸŽโŠบ

๐‘คโ€ฒ๐‘–๐’™๐’ŠโŠบโˆ’๐‘คโ€ฒ๐‘–๐’™๐’Š

โŠบ

๐ŸŽโŠบ๐‘ฆโ€ฒ๐‘–๐’™๐’Š

โŠบ

โˆ’๐‘ฅ๐‘–๐’™๐’ŠโŠบ

๐’‰๐Ÿ

๐’‰๐Ÿ

๐’‰๐Ÿ‘

= ๐ŸŽ

Which can be written as

๐ด๐‘–๐’‰ = ๐ŸŽ, ๐‘– = 1,โ€ฆ , 4

Rmk remember that ๐’‰ has been unrolled row-wise, not column-wise

Giacomo Boracchi

DLT for Homography Estimation

Stacking 4 point correspondences gives an 8 ร— 9 matrix

๐ด๐’‰ = ๐ŸŽ

We are not interested in the trivial solution ๐’‰ = ๐ŸŽ

Solve it as ๐’‰ = ๐‘…๐‘๐‘†(๐ด) and arbitrarily imposing ๐’‰ = 1

Giacomo Boracchi

DLT in the overdetermined case

Let us assume ๐‘› > 4 point correspondences are given, such that ๐ด is

a 2๐‘› ร— 9 matrix

๐ด๐’‰ = ๐ŸŽ

The system is overdetermined. We are not interested

โ€ข in the trivial solution ๐’‰ = ๐ŸŽ and

โ€ข not even in an exact solution, since typically this does not exist

because of noise in the measurements ๐’™๐’Šโ€ฒ, ๐’™๐’Š

Thus, impose the constraint ๐’‰ = 1 and minimize a cost function

๐’‰โˆ— = argmin ๐ด๐’‰๐Ÿ๐‘ . ๐‘ก. ๐’‰

๐Ÿ= 1

Giacomo Boracchi

DLT in the overdetermined case

The solution of this problem is obtained by

๐’‰โˆ— = argmin ๐ด๐’‰๐Ÿ๐‘ . ๐‘ก. ๐’‰

๐Ÿ= 1

The solution is the (unit) eigenvector of ๐ด๐‘‡๐ด with least eigenvalue.

Equivalently, the solution is the unit singular vector corresponding to the

smallest singular value of ๐‘จ. (See HZ A5.3(p592) )

Specifically, if ๐ด = ๐‘ˆ๐ท๐‘‰โŠบ with D diagonal with positive diagonal entries,

arranged in descending order down the diagonal, then ๐’‰ is the last

column of ๐‘‰.

Rmk DLT algorithm minimizes the residual ๐ด๐’‰ , which has to be

interpreted as an algebraic error

Giacomo Boracchi

DLT and the reference system

Are the outcome of DLT independent of the reference system being used

to express ๐’™โ€ฒ and ๐’™?

Unfortunately DLT is not invariant to similarity transformations.

Therefore, it is necessary to apply a normalizing transformation to the

data before applying the DLT algorithm.

Normalizing the data makes the DLT invariant to the reference system, as

it is always being estimated in a canonical reference

Normalization is also called Pre-conditioning

Giacomo Boracchi

Preconditioning

Needed because in homogeneous coordinate systems, components

typically have very different ranges

โ€ข Row and Column indexes ranges in [0 โˆ’ 4๐พ]

โ€ข Third component is 1

Define a maping

๐‘ฅ โ†’ ๐‘‡๐‘ฅ

That brings all the points ยซaronud the originยป and rescale each component

to the same range (say at an average distance 2 from the origin)

Giacomo Boracchi

Preconditioning

๐’™ โ†’ ๐‘‡๐’™

โ„™2 (with ๐œƒ = 0 since we do not need rotations)

๐‘‡ =1/๐‘ 00

01/๐‘ 0

โˆ’๐‘ก๐‘ฅ/๐‘ โˆ’๐‘ก๐‘ฆ/๐‘ 

1

The preconditioning for a set of points ๐‘‹ of โ„™2 is defined as

๐‘ก๐‘ฅ = mean ๐‘‹(1, : )

๐‘ก๐‘ฆ = mean ๐‘‹(2, : )

Which brings the barycentre of ๐‘‹ to the origin, the scaling is

๐‘  =mean std ๐‘‹, 2

2

Giacomo Boracchi

Homography estimation with preconditioning

Estimate the homography between two sets of points ๐‘‹, ๐‘‹โ€ฒ

1. Compute ๐‘‡, ๐‘‡โ€™ preconditioning transformation of ๐‘‹, ๐‘‹โ€ฒ

2. Apply transformation

๐‘‹๐‘ = ๐‘‡๐‘‹, ๐‘‹๐‘โ€ฒ = ๐‘‡โ€ฒ๐‘‹โ€ฒ

1. Estimate the homography from ๐‘‹๐‘ and ๐‘‹๐‘โ€ฒ ,

๐ป = ๐ท๐ฟ๐‘‡(๐‘‹๐‘ , ๐‘‹๐‘โ€ฒ)

1. Define the transformation

๐ป๐‘ = ๐‘‡โ€ฒโˆ’1๐ป๐‘‡

Giacomo Boracchi

How to apply linear transformations to an image?

pixel intensities

Giacomo Boracchi

Apply the inverse of the desired transformation on a grid covering the output image

H =

-1.0689 -2.9443 0

-0.8095 1.4384 0

0.0040 0.0010 1.0000

Giacomo Boracchi

Here is the grid of the transformed imagePixel centers in the transformed image

Giacomo Boracchi

Place the grid transformed by ๐ปโˆ’1on the input image

Giacomo Boracchi

Place the grid transformed by ๐ปโˆ’1on the image

Giacomo Boracchi

Place the grid transformed by ๐ปโˆ’1on the image

Giacomo Boracchi

Define image intensity at blue points by means of bilinear interpolation

Giacomo Boracchi

Bilinear Interpolation

Intensity value over the transformed grid (๐‘ฅ, ๐‘ฆ)are defined by interpolating values of

neighbouring pixels { ๐‘ฅ๐‘– , ๐‘ฆ๐‘– , ๐‘– = 1,2}. Several

interpolation options are viable. Bilinear

interpolation is a weighted average with weights

proportional to the areas illustrated here.

By Cmglee - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=21409164

Giacomo Boracchi

Bilinear Interpolation

Let (๐‘ฅ, ๐‘ฆ) be the point and ๐‘“(๐‘ฅ, ๐‘ฆ) the value we

want to estimate.

Bilinear interpolation corresponds to

โ€ข Perform a 1D-linear interpolation along ๐‘ฅ axis

to estimate ๐‘“ ๐‘ฅ, ๐‘ฆ1 and ๐‘“ ๐‘ฅ, ๐‘ฆ2

๐‘“ ๐‘ฅ, ๐‘ฆ1 =๐‘ฅ2 โˆ’ ๐‘ฅ

๐‘ฅ2 โˆ’ ๐‘ฅ1๐‘“ ๐‘ฅ1, ๐‘ฆ1 +

๐‘ฅ โˆ’ ๐‘ฅ1๐‘ฅ2 โˆ’ ๐‘ฅ1

๐‘“ ๐‘ฅ2, ๐‘ฆ1

๐‘“ ๐‘ฅ, ๐‘ฆ2 =๐‘ฅ2 โˆ’ ๐‘ฅ

๐‘ฅ2 โˆ’ ๐‘ฅ1๐‘“ ๐‘ฅ1, ๐‘ฆ2 +

๐‘ฅ โˆ’ ๐‘ฅ1๐‘ฅ2 โˆ’ ๐‘ฅ1

๐‘“ ๐‘ฅ2, ๐‘ฆ2

โ€ข Perform 1D-linear interpolation along ๐‘ฆ axis

but considering ๐‘“(๐‘ฅ, ๐‘ฆ1) and ๐‘“(๐‘ฅ, ๐‘ฆ2)

By Cmglee - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=21409164

Giacomo Boracchi

Re-arrange the new estimated values over a regular grid to obtain the transformed image

Giacomo Boracchi

Black pixels are points out of the image grid

Giacomo Boracchi

Single-View GeometryGiacomo Boracchi

giacomo.boracchi@polimi.it

March 10th, 2020

USI, Lugano

Book: HZ, chapter 2

Giacomo Boracchi

Outline

โ€ข Implications of image calibration

โ€ข Camera Center

โ€ข Viewing Rays

โ€ข Factorization of ๐‘€

โ€ข Conics and Conic Fitting

โ€ข Comments on Error Minimization

โ€ข Measuring Angles

โ€ข Single View Rectification

Giacomo Boracchi

The Camera Center ๐ถ

The 3D coordinates of the center of a camera having matrix ๐‘€ โˆˆ โ„3,4

satisfy

๐ถ โˆˆ ๐‘…๐‘๐‘†(๐‘€)

Where ๐‘…๐‘๐‘†(โ‹…) denotes the Right Null Space.

Note that when the ๐‘…๐‘๐‘†(๐‘€) has dimension 1 (i.e. always but in

degenerate cases) all the points ๐ถ โˆˆ ๐‘…๐‘๐‘† ๐‘€ coincide in the

homogenous space.

Giacomo Boracchi

The Camera Center ๐ถ

Proof

Let us consider ๐ถ โˆˆ ๐‘…๐‘๐‘†(๐‘€), then

๐‘€๐‘ƒ = ๐‘€ ๐‘ƒ + ๐œ†๐ถ โˆ€๐œ† โˆˆ โ„, โˆ€๐‘ƒ โˆˆ โ„™3

This means that the line ๐‘ƒ + ๐œ†๐ถ does not change its projection through

๐‘€, thus ๐‘ƒ + ๐œ†๐ถ is a viewing ray. Since this has to hold โˆ€๐‘ƒ โˆˆ โ„™3, this

means that ๐ถ is the camera center.

The converse is trivial because given the camera center ๐ถ, then

๐‘€ ๐‘ƒ + ๐œ†๐ถ = ๐‘€๐‘ƒ โˆ€๐‘ƒ โˆˆ โ„™3 (since ๐‘ƒ + ๐œ†๐ถ is homogeneous coordinates

is the viewing ray), thus ๐ถ โˆˆ ๐‘…๐‘๐‘†(๐‘€)

Giacomo Boracchi

Calibrated Cameras: Viewing Rays Coordinates

We can associate to each point on the image, a viewing ray

๐’— = ๐ถ + ๐œ† ๐พ๐‘… โˆ’1๐’‘0

Remember that ๐ถ = ๐‘…๐‘๐‘† ๐‘€

XY

๐‘๐ถ

ฮ 

๐‘

๐‘“

๐‘ฅ

๐‘ฆ

๐‘ƒ

๐’‘

๐’—

Giacomo Boracchi

Once Calibrated

We can associate to each point on the image, a viewing ray

๐’— = ๐ถ + ๐œ† ๐พ๐‘… โˆ’1๐’‘0

In fact

๐‘€๐’— = ๐‘€ ๐ถ + ๐œ† ๐พ๐‘… โˆ’1๐’‘0

๐‘€๐’— = ๐‘€๐ถ + ๐œ†๐พ ๐‘…, ๐‘‡ ๐พ๐‘… โˆ’1๐’‘0

๐‘€๐’— = ๐œ† ๐พ๐‘…,๐พ๐‘‡ ๐พ๐‘… โˆ’1๐’‘0

๐‘€๐’— = ๐œ†๐’‘ = ๐’‘ โˆ€๐œ†

Giacomo Boracchi

Once Calibrated: Factorization of ๐‘€

Once the camera has been calibrated we are want to factorize ๐‘€ as

๐‘€ = ๐พ ๐‘…, ๐’•

where ๐‘… is a rotation matrix, and ๐พ is upper triangular.

By doing so we can:

โ€ข Compute viewing rays, which requires ๐พ๐‘… โˆ’1

โ€ข Preserve ๐พ when the camera moves, since the intrinsic parameters do

not change and do not need to be estimated from scratches.

Giacomo Boracchi

Factorization of ๐‘€

For computing viewing rays we need to factorize the matrix ๐‘€ estimated

through camera calibration

๐‘€ โ‰ƒ ๐พ[๐‘…, ๐’•]

Let us write

๐‘€ = เทฉ๐‘€,๐’Ž๐Ÿ’

Then we have to find a way to write เทฉ๐‘€ = ๐พ๐‘…, where ๐พ is upper triangular

and ๐‘… is a rotation matrix.

Giacomo Boracchi

Factorization of ๐‘€

Let us compute the QR-decomposition of เทฉ๐‘€โˆ’1 ( เทฉ๐‘€ โˆˆ โ„3ร—3)

เทฉ๐‘€โˆ’1 = เทฉ๐‘„ เทฉ๐‘‡

where เทฉ๐‘„ is orthogonal and เทฉ๐‘‡ is upper triangular. Since

เทฉ๐‘€โˆ’1 = ๐‘…โˆ’1๐พโˆ’1,

Then we need to set

๐‘… = det เทฉ๐‘„ เทฉ๐‘„ โŠบ, ๐พ = เทฉ๐‘‡ โˆ’1

Since by doing so det ๐‘… > 0 (we are allowed changing the sign of a

matrix, thus we obtain a rotation and no reflection)

Similarly we can multiply 1

๐พ(3,3)to have 1 in the bottom right entry of ๐พ

๐’• = det เทฉ๐‘„ ๐พโˆ’1๐’Ž๐Ÿ’

Giacomo Boracchi

Factorization of ๐‘€

function [K,R,t] = krt (M)

%KRT Internal and external parameters from M

[Q,T] = qr_p(inv(M(1:3, 1:3))); %qr decomposition

yielding positive diagonal values over T, to make

qr factorization unique

s = det(Q);

R = s*Qโ€™;

t = s*T*M(1:3,4);

K = inv(T./T(3,3));

end

Andrea Fusiello, Elaborazione delle Immagini: Visione Computazionale, ttp://www.diegm.uniud.it/fusiello/index.php/Visione_Computazionale

Giacomo Boracchi

A recap on Camera Projection

Giacomo Boracchi

The Coordinate Systems Involved in Camera Projection

Andrea Fusiello, Elaborazione delle Immagini: Visione Computazionale, http://www.diegm.uniud.it/fusiello/index.php/Visione_Computazionale

[๐‘…, ๐’•]

World 3D

reference

system

[meters]

Camera 3D

reference

system

[meters]

2D Normalized

Coordinates

[meters]

Image

Coordinates

[pixels]

Giacomo Boracchi

Conics

Giacomo Boracchi

Conics

By Pbroks13 - Own work, CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=5919064

Giacomo Boracchi

Conics in โ„™2

A conic is a curve described by a second-degree equation in the plane.

In Euclidean coordinates a conic becomes

๐‘Ž๐‘ฅ2 + ๐‘๐‘ฅ๐‘ฆ + ๐‘๐‘ฆ2 + ๐‘‘๐‘ฅ + ๐‘’๐‘ฆ + ๐‘“ = 0

๐‘ฅ โ†’ ๐‘ฅ1/๐‘ฅ3, ๐‘ฆ โ†’ ๐‘ฅ2/๐‘ฅ3 gives

๐‘Ž๐‘ฅ12 + ๐‘๐‘ฅ1๐‘ฅ2 + ๐‘๐‘ฅ2

2 + ๐‘‘๐‘ฅ1๐‘ฅ3 + ๐‘’๐‘ฅ2๐‘ฅ3 + ๐‘“๐‘ฅ32 = 0

or in matrix form

๐’™โŠบ๐ถ๐’™ = 0

where the conic coefficient matrix C is given by ๐ถ =

๐‘Ž ๐‘/2 ๐‘‘/2๐‘/2 ๐‘ ๐‘’/2๐‘‘/2 ๐‘’/2 ๐‘“

Giacomo Boracchi

Conics in โ„™2

๐’™โŠบ๐‘Ž ๐‘/2 ๐‘‘/2๐‘/2 ๐‘ ๐‘’/2๐‘‘/2 ๐‘’/2 ๐‘“

๐’™ = 0

Rmk The conic coefficient matrix is symmetric,

Rmk multiplying C by a non-zero scalar does not change. Only the ratios

of the elements in ๐ถ are important, as for homogeneous points and for

lines.

Rmk The conic has five degrees of freedom :

โ€ข the ratios {a : b : c : d : e : f} or equivalently

โ€ข the six elements of a symmetric matrix less one for scale.

Giacomo Boracchi

Conic Fitting

Giacomo Boracchi

Conic fitting

Five points define a conic.

Let ๐’™ = [๐‘ฅ๐‘–; ๐‘ฆ๐‘–] โˆˆ โ„2 a point belonging to a conic

๐‘Ž๐‘ฅ๐‘–2 + ๐‘๐‘ฅ๐‘–๐‘ฆ๐‘– + ๐‘๐‘ฆ๐‘–

2 + ๐‘‘๐‘ฅ๐‘– + ๐‘’๐‘ฆ๐‘– + ๐‘“ = 0

To determine the conic coefficients we need five such equations in ๐’„ =๐‘Ž, ๐‘, ๐‘, ๐‘‘, ๐‘’, ๐‘“ โ€ฒ, since the conic is determined up to a scaling factor.

In matrix expression

๐‘ฅ๐‘–2, ๐‘ฅ๐‘–๐‘ฆ๐‘– , ๐‘ฆ๐‘–

2, ๐‘ฅ๐‘– , ๐‘ฆ๐‘– , 1 ๐’„ = 0

We re-arrange the first term as a matrix, the solution to solve is

Giacomo Boracchi

Conic fitting

๐‘ฅ12, ๐‘ฅ1๐‘ฆ1, ๐‘ฆ1

2, ๐‘ฅ1, ๐‘ฆ1, 1

โ€ฆ

๐‘ฅ๐‘2 , ๐‘ฅ๐‘๐‘ฆ๐‘, ๐‘ฆ๐‘

2 , ๐‘ฅ๐‘, ๐‘ฆ๐‘, 1

๐’„ = 0,

๐‘–. ๐‘’., ๐ด๐’„ = 0

Rmk: The system is ๐ด โˆˆ โ„๐‘ร—6, solved by ๐’„ โˆˆ ๐‘…๐‘๐‘† ๐ด when ๐‘ = 5

Unique solution, when N= 4 the ๐‘…๐‘๐‘† has dimension larger than one, any

of the vectors in ๐‘…๐‘๐‘†(๐‘ƒ) is a solution

Giacomo Boracchi

Conic fitting

๐‘ฅ12, ๐‘ฅ1๐‘ฆ1, ๐‘ฆ1

2, ๐‘ฅ1, ๐‘ฆ1, 1

โ€ฆ

๐‘ฅ๐‘2 , ๐‘ฅ๐‘๐‘ฆ๐‘, ๐‘ฆ๐‘

2 , ๐‘ฅ๐‘, ๐‘ฆ๐‘, 1

๐’„ = 0,

๐‘–. ๐‘’., ๐ด๐’„ = 0

Rmk: The conic identified by ๐’„ is the same as the one from ๐œ†๐’„

So, when ๐‘ > 5 we are interested in solving

๐’Žโˆ— = argmin ๐ด๐’Ž๐Ÿ๐‘ . ๐‘ก. ๐’Ž

๐Ÿ= 1

Giacomo Boracchi

Lines tangent to a conic

Theorem The line ๐’ tangent to ๐ถ at a point ๐’™ on ๐ถ is given by ๐’ = ๐ถ๐’™.

Proof (HZ result 2.7)

he line ๐’ = ๐ถ๐’™ passes through ๐’™, since ๐’โŠบ๐’™ =๐’™โŠบ๐ถ๐’™ = 0. So, ๐’ has at least one contact with the conic.

Now we prove that ๐’™ is the only point belonging to both ๐’ and ๐ถ, thus ๐’ is

the tangent in ๐’™.

Suppose that ๐’ meets the conic in another point ๐’š, such that ๐’šโŠบ๐ถ๐’š = 0and ๐’โŠบ๐’š = 0. This also implies ๐’โŠบ๐’š = ๐’™โŠบ๐ถ ๐’š = ๐’™โŠบ๐ถ๐’š = 0. Then

๐’™ + ๐›ผ๐’š โŠบ๐ถ(๐’™ + ๐›ผ๐’š) = 0 for all ๐›ผ, which means that the line ๐’ = ๐ถ๐’™joining ๐’™ and ๐’š lies on the conic ๐ถ, which is therefore degenerate.

Giacomo Boracchi

Matlab Example

Giacomo Boracchi

Comments on Error Minimization

Giacomo Boracchi

DLT and Error minimization

DLT algorithm minimizes the algebraic residual:

๐’‰โˆ— = argmin ๐ด๐’‰๐Ÿ๐‘ . ๐‘ก. ๐’‰

๐Ÿ= 1

This does not have a physical meaning being ๐ด (in case of homography

estimation) made of rows like

๐ŸŽโŠบ

๐‘คโ€ฒ๐‘–๐’™๐’ŠโŠบโˆ’๐‘คโ€ฒ๐‘–๐’™๐’Š

โŠบ

๐ŸŽโŠบ๐‘ฆโ€ฒ๐‘–๐’™๐’Š

โŠบ

โˆ’๐‘ฅ๐‘–๐’™๐’ŠโŠบ

The norm of ๐ด๐’‰ does not admit a straightforward geometric interpretation

Giacomo Boracchi

DLT and Error minimization

It would be better to measure the re-projection error, which has a physical

meaning and refers to metric quantities (e.g. cm)

1

๐‘

๐‘–

๐’™๐’Šโ€ฒ โˆ’๐ป๐’™๐’Š 2 + ๐’™๐’Š โˆ’๐ปโˆ’1๐’™๐’Šโ€ฒ 2

Provided the set of pairs ๐’™๐’Šโ€ฒ, ๐’™๐’Š , ๐‘– = 1,โ€ฆ ,๐‘

This indicates how far the mapped points are to the destination.

However, minimizing this error is non trivial.

Rmk. If we take only 4 pairs of points, the algebraic and geometric error is

zero

Giacomo Boracchi

DLT and Error minimization

It would be better to measure the re-projection error, which has a physical

meaning and refers to metric quantities (e.g. cm)

1

๐‘

๐‘–

๐’™๐’Šโ€ฒ โˆ’๐ป๐’™๐’Š 2 + ๐’™๐’Š โˆ’๐ปโˆ’1๐’™๐’Šโ€ฒ 2

Provided the set of pairs ๐’™๐’Šโ€ฒ, ๐’™๐’Š , ๐‘– = 1,โ€ฆ ,๐‘

This indicates how far the mapped points are to the destination.

However, minimizing this error is non trivial.

Rmk. If we take only 4 pairs of points, the algebraic and geometric error is

zero

Giacomo Boracchi

The standard procedure

1. Estimate the homography ๐ป by minimizing the Algebraic error (e.g.

through DLT)

2. Refine the estimated homography by minimizing the geometric error

through a numerical solver

โ€ข In this latter step, use ๐ป as an initial guess for the nonlinear minimization

Giacomo Boracchi

Dual Conic

Giacomo Boracchi

Dual conics (conics envelopes)

Conics are defined by point equations

๐’™โŠบ๐ถ๐’™ = 0

However, point-line duality makes it possible to define conics by lines

A line ๐’ tangent to the conic ๐ถ satisfies

๐’โŠบ๐ถโˆ—๐’ = 0

where ๐ถโˆ— is the adjoint of ๐ถ which in case of symmetric and non-singular

matrix is ๐ถโˆ— = ๐ถโˆ’1

Giacomo Boracchi

Dual conics (conics envelopes)

Hartley Zisserman Fig.2.2

Point Conic Line Conic

Giacomo Boracchi

Homographies and lines and conics

An homography transform each point ๐’™ in a point ๐’™โ€ฒ such that:

๐’™ โ†’ ๐ป๐’™ = ๐’™โ€ฒ

An homography transform each line ๐’ in a line ๐’โ€ฒ such that:

๐’ โ†’ ๐ปโˆ’1 โŠบ ๐’ = ๐’โ€ฒ

An homography transform each conic ๐ถ in a conic ๐ถโ€ฒ such that:

๐ถ โ†’ ๐ปโˆ’1 โŠบ๐ถ๐ปโˆ’1 = ๐ถโ€ฒ

An homography transform each dual (line) conic ๐ถโˆ— in a dual conic ๐ถโˆ—โ€ฒ

๐ถโˆ— โ†’ ๐ป๐ถโˆ—๐ปโŠบ = ๐ถโˆ—โ€ฒ

We say that points transform contravariantly and lines and conics

transform covariantly.

Giacomo Boracchi

Degenerate Conics

When the matrix ๐ถ is not of full rank, a point conic ๐ถ degenerates in

โ€ข two lines (๐ถ has rank 2),

โ€ข or a repeated line (๐ถ has rank 1)

A line conic ๐ถโˆ— degenerates in

โ€ข two points (๐ถโˆ— has rank 2),

โ€ข a repeated point (๐ถโˆ— has rank 1)

For instance, ๐ถโˆ— such that rank(๐ถโˆ—) = 2

๐ถโˆ— = ๐’™๐’šโŠบ + ๐’š๐’™โŠบ

Is the set of all the lines passing through ๐’™ and ๐’š (not the that ๐ถโˆ—

remains a 3 ร— 3 matrix)

Giacomo Boracchi

Circular Points and Conic dual to circular points

Giacomo Boracchi

Circular Points: ๐‘ฐ and ๐‘ฑ

These are very special points in ๐’โˆž

๐‘ฐ =1๐‘–0

, ๐‘ฑ =1โˆ’๐‘–0

These are called circular points since they correspond to the intersection

of any circle with ๐’โˆž

Rmk a circle can be fit through 3 points. Or can be fit as a general conic

passing through 3 points + the two circular points

โ„“โˆž

๐‘ฑ๐‘ฐ

Giacomo Boracchi

Circular Points: ๐‘ฐ and ๐‘ฑ

Circular points are fixed under an orientation-preserving similarity

๐ป๐‘†๐‘ฐ = ๐‘ฐ, ๐ป๐‘†๐‘ฑ = ๐‘ฑ

a reflection instead swaps ๐‘ฐ and ๐‘ฑ

Rmk circular points are not fixed under projective transformations

Giacomo Boracchi

Conic dual to circular points: ๐ถโˆžโˆ—

๐ถโˆ—

๐ถโˆ— = ๐’™๐’šโŠบ + ๐’š๐’™โŠบ

F0r which rank(๐ถโˆ—) = 2 and is the set of all the lines passing through ๐’™and ๐’š (note the that ๐ถโˆ— remains a 3 ร— 3 matrix)

We can compute the dual conic associated to circular points

๐ถโˆžโˆ— = ๐‘ฐ๐‘ฑโŠบ + ๐‘ฑ๐‘ฐโŠบ

which also is a degenerate line conic

๐‘ฐ =1๐‘–0

, ๐‘ฑ =1โˆ’๐‘–0

โ†’ ๐ถโˆžโˆ— =

1 0 00 1 00 0 0

Giacomo Boracchi

Conic dual to circular points: ๐ถโˆžโˆ—

Property ๐ถโˆžโˆ— is fixed under an orientation-preserving similarity

Property ๐ถโˆžโˆ— in the Euclidean plane can be written as

๐ถโˆžโˆ— =

1 0 00 1 00 0 0

Therefore, any homography transforms ๐ถโˆžโˆ— like any other line conic

๐ถโˆžโˆ— โ†’ ๐ถโˆž

โˆ— โ€ฒ = ๐ป๐ถโˆžโˆ— ๐ปโŠบ

In an image, the equations of ๐ถโˆžโˆ— โ€ฒ might be different from

1 0 00 1 00 0 0

Giacomo Boracchi

Single Image Rectification From ๐ถโˆžโˆ—

Giacomo Boracchi

Single Image Rectification

๐ถโˆžโˆ— =

1 0 00 1 00 0 0

๐ถโˆžโˆ— โ€ฒ = ?

๐ป

Giacomo Boracchi

Single Image Rectification

๐ถโˆžโˆ— =

1 0 00 1 00 0 0

๐ถโˆžโˆ— โ€ฒ = ?

๐ป

Giacomo Boracchi

Single Image Rectification

Affine rectification: find the homography ๐ป๐‘ƒ that sends ๐‘™โˆž in its canonical

equation [0; 0; 1].

Metric rectification: after applying ๐ป๐‘ƒ, determine an affine transformation

๐ป๐ด that maps circular points back to their canonical position [1;ยฑ๐‘–; 0].

โ€ข Any similarity transformation applied next would not change the

location of circular points

Rmk it is enough to find an homography that brings ๐ถโˆžโˆ— โ€ฒ in

1 0 00 1 00 0 0

Giacomo Boracchi

Single Image Rectification

Important Property after an affine rectification, ๐ถโˆžโˆ— โ€ฒ can be written as

๐ถโˆžโˆ— โ€ฒ = ๐ด๐ดโŠบ ๐ŸŽ

๐ŸŽโŠบ 0

Being ๐ด a 2 ร— 2 invertible matrix (cfr HZ example 2.26)

(this is the image of the canonical ๐ถโˆžโˆ— through an affine transformation

since similarities do not change ๐ถโˆžโˆ— , and that projective transformation

has been removed by the affine rectification)

Giacomo Boracchi

Single Image Rectification (after affine rectification)

Our goal is to estimate that ๐ป in order to define the inverse mapping ๐ปโˆ’1

Assume now that that affine rectification has been already performed

๐ถโˆžโˆ— =

1 0 00 1 00 0 0

๐ถโˆžโˆ— โ€ฒ = ๐ด๐ดโŠบ ๐ŸŽ

๐ŸŽโŠบ 0

๐ป

Giacomo Boracchi

Single Image Rectification

Our goal is to estimate that ๐ป in order to define the inverse mapping ๐ปโˆ’1

๐ถโˆžโˆ— =

1 0 00 1 00 0 0

Rectification can achieved by estimating ๐ถโˆžโˆ— โ€ฒ (in this case ๐ด๐ดโŠบ) in the image

๐ถโˆžโˆ— โ€ฒ = ๐ด๐ดโŠบ ๐ŸŽ

๐ŸŽโŠบ 0

๐ป

Giacomo Boracchi

Single Image Rectification provided ๐ถโˆžโˆ— โ€ฒ

1. Perform affine rectification, such that ๐‘™โˆž = [0; 0; 1]

2. Fit an ellipse to ๐›พโ€ฒ the image of a circle ๐›พ

3. Compute ๐‘ฐโ€ฒ, ๐‘ฑโ€ฒ by intersecting ๐›พโ€ฒ with ๐‘™โˆž

4. We have ๐ถโˆžโˆ— โ€ฒ = ๐‘ฐโ€ฒ๐‘ฑโ€ฒโŠบ + ๐‘ฑโ€ฒ๐‘ฐโ€ฒโŠบ

๐›พ๐›พโ€ฒ

Giacomo Boracchi

Single Image Rectification provided ๐ถโˆžโˆ— โ€ฒ

1. Perform affine rectification, such that ๐‘™โˆž = [0; 0; 1]

2. Fit an ellipse to ๐›พโ€ฒ the image of a circle ๐›พ

3. Compute ๐‘ฐโ€ฒ, ๐‘ฑโ€ฒ by intersecting ๐›พโ€ฒ with ๐‘™โˆž

4. We have ๐ถโˆžโˆ— โ€ฒ = ๐‘ฐโ€ฒ๐‘ฑโ€ฒโŠบ + ๐‘ฑโ€ฒ๐‘ฐโ€ฒโŠบ

๐›พ๐›พโ€ฒ

๐›พโ€ฒ โˆฉ ๐‘™โˆž

๐‘ฐโ€ฒ

๐‘ฑโ€ฒ

Giacomo Boracchi

Single Image Rectification provided ๐ถโˆžโˆ— โ€ฒ

The SVD of ๐ถโˆžโˆ— โ€ฒ can be used to define the rectifying homography

transformation.

In fact, up to a similarity transformation that rescales eigenvalues we

obtain ๐ถโˆžโˆ— !

๐‘†๐‘‰๐ท ๐ถโˆžโˆ— โ€ฒ = ๐‘ˆ

1 0 00 1 00 0 0

๐‘ˆโŠบ

So, it is enough to take ๐‘ˆ to rectify the image, since the similarity

transformation does not affect ๐ถโˆžโˆ—

Giacomo Boracchi

Single Image Rectification From OrthogonalLines

Giacomo Boracchi

Recap: Angles in the Euclidean Plane

In Euclidean geometry the angle between two lines is computed from the

dot product of their normals. For the lines ๐’ = (๐‘™1; ๐‘™2; ๐‘™3), and ๐’Ž =(๐‘š1;๐‘š2;๐‘š3), the angle ๐œƒ is such that

cos ๐œƒ =๐‘™1๐‘š1 + ๐‘™2๐‘š2

๐‘™12 + ๐‘™2

2 (๐‘š12 +๐‘š2

2)

We will see later interesting properties on projective plane

Giacomo Boracchi

Recap: Angles in the Euclidean Plane

In Euclidean geometry the angle between two lines is computed from the

dot product of their normals. For the lines ๐’ = (๐‘™1; ๐‘™2; ๐‘™3), and ๐’Ž =(๐‘š1;๐‘š2;๐‘š3), the angle ๐œƒ is such that

cos ๐œƒ =๐‘™1๐‘š1 + ๐‘™2๐‘š2

๐‘™12 + ๐‘™2

2 (๐‘š12 +๐‘š2

2)

We will see later interesting properties on projective plane

Time has come!

Rmk the first two components of ๐’ and ๐’Ž do not have a pre-defined

meaning in โ„™2

Giacomo Boracchi

Angles in the Projective Plane

An analogous expression, that is invariant to projective transformation, for

the angle ๐œƒ between lines ๐’ = (๐‘™1; ๐‘™2; ๐‘™3) and ๐’Ž = (๐‘š1;๐‘š2;๐‘š3), is

cos ๐œƒ =๐’โŠบ๐ถโˆž

โˆ— ๐’Ž

๐’โŠบ๐ถโˆžโˆ— ๐’ (๐’ŽโŠบ๐ถโˆž

โˆ— ๐’Ž)

Rmk when ๐ถโˆžโˆ— =

1 0 00 1 00 0 0

and we are in homogeneous coordinates. The

system the above equation becomes the same as in the previous slide

Giacomo Boracchi

Angles in the Projective Plane

Rmk it is easy to verify that

cos ๐œƒ =๐’โŠบ๐ถโˆž

โˆ— ๐’Ž

๐’โŠบ๐ถโˆžโˆ— ๐’ (๐’ŽโŠบ๐ถโˆž

โˆ— ๐’Ž)

is invariant w.r.t. any projective transformation ๐ปdefinition for an angle

(just replace ๐‘™ โ†’ ๐ปโˆ’1 โŠบ๐‘™, and ๐ถโˆ— โ†’ ๐ป๐ถโˆ—๐ปโˆ’1)

Rmk the image of two orthogonal lines ๐’โ€ฒ,๐’Žโ€ฒ have to satisfy

๐’โ€ฒโŠบ๐ถโˆžโˆ— โ€ฒ๐’Žโ€ฒ = ๐ŸŽ

Giacomo Boracchi

Single Image Rectification from orthogonal lines

๐’๐’Ž

๐’โ€ฒ

๐’Žโ€ฒ

Let ๐’โ€ฒ,๐’Žโ€ฒ be the images of two orthogonal lines ๐’ and ๐’Ž in the 3D space

๐ถโˆžโˆ— =

1 0 00 1 00 0 0

๐ถโˆžโˆ— โ€ฒ = ?

๐ป

Giacomo Boracchi

Single Image Rectification from orthogonal lines

If ๐’โ€ฒ and ๐’Žโ€ฒ are images two orthogonal lines ๐’ and ๐’Ž (in the 3D world),

then it has necessarily to hold

๐’โ€ฒโŠบ๐ถโˆžโˆ— โ€ฒ๐’Žโ€ฒ = 0

Let us use this information to compute ๐ถโˆžโˆ— โ€ฒ, thus compute ๐ป

Remember that, after an affine rectification

๐ถโˆžโˆ— โ€ฒ = ๐ด๐ดโŠบ ๐ŸŽ

๐ŸŽโŠบ 0

and that ๐‘† = ๐ด๐ดโŠบ is a symmetric homogeneous matrix ๐ด๐ดโŠบ = ๐ดโŠบ๐ด , thus

there are only 2 unknowns to identify ๐ถโˆžโˆ— โ€ฒ

Each pair of orthogonal lines yield a single equation

๐’โ€ฒ 1: 2 โŠบ๐‘† ๐’Žโ€ฒ(1: 2) = 0

Giacomo Boracchi

Single Image Rectification from orthogonal lines

If ๐’โ€ฒ and ๐’Žโ€ฒ are images two orthogonal lines ๐’ and ๐’Ž (in the 3D world),

then it has necessarily to hold

๐’โ€ฒโŠบ๐ถโˆžโˆ— โ€ฒ๐’Žโ€ฒ = 0

Let us use this information to compute ๐ถโˆžโˆ— โ€ฒ, thus compute ๐ป

Remember that, after an affine rectification

๐ถโˆžโˆ— โ€ฒ = ๐ด๐ดโŠบ ๐ŸŽ

๐ŸŽโŠบ 0

and that ๐‘† = ๐ด๐ดโŠบ is a symmetric homogeneous matrix ๐ด๐ดโŠบ = ๐ดโŠบ๐ด , thus

there are only 2 unknowns to identify ๐ถโˆžโˆ— โ€ฒ

Each pair of orthogonal lines yield a single equation

๐’โ€ฒ 1: 2 โŠบ๐‘† ๐’Žโ€ฒ(1: 2) = 0

Two pairs of orthogonal lines are enough to identify ๐ถโˆžโˆ— โ€ฒ

Giacomo Boracchi

Stratified Rectification from Orthogonal Lines

๐’โ€ฒ 1: 2 โŠบ๐‘† ๐’Žโ€ฒ(1: 2) = 0

Two pairs of (different, i.e. not parallel) orthogonal lines are enough to

estimate ๐‘†, (thus ๐ด through Choleski decomposition)

Hartley Zisserman Fig.2.17

Giacomo Boracchi

Rectification from 5 pairs of orthogonal lines

Assume no affine rectification has been done before

In principle, any pair of lines ๐’โ€ฒ,๐’Žโ€ฒ that in the scene are orthogonal

provides a single equation

๐’โ€ฒโŠบ๐ถโˆžโˆ— โ€ฒ๐’Žโ€ฒ = 0

This is a linear constraint in the entries of ๐ถโˆžโˆ— โ€ฒ (this is exactly like fitting a

conic through 5 points).

Five of these equations are enough to set up a linear system

๐ด๐’„ = 0

where ๐’„ contains the six parameters of the conic. The solution is:

๐’„ = ๐‘…๐‘๐‘†(๐ด)

Giacomo Boracchi

Rectification from 5 pairs of orthogonal lines

Now the pairs of lines

(highlighted by solid white

lines) can also be parallel

in the 3D world (like the

windows here), since

affine rectification has not

been performed, yet.

Hartley Zisserman Fig.2.17

Giacomo Boracchi

Rectification from 5 pairs of orthogonal lines

Now the pairs of lines

(highlighted by solid white

lines) can also be parallel

in the 3D world (like the

windows here), since

affine rectification has not

been performed, yet.

Hartley Zisserman Fig.2.17

Giacomo Boracchi

Camera Calibration and the 3D world

Giacomo Boracchi

Normal to the horizon

Let ๐‘€ = ๐พ[๐‘…, ๐’•] be the projection matrix of a calibrated camera, the

normal ๐‘› to the plane of an horizon ๐‘™โ„Ž in the image is:

๐‘› = ๐พ๐‘‡๐‘™โ„Ž

C

๐‘›

lhoriz

ฯ€lโˆž

ฯ€'

Giacomo Boracchi

Normal to the horizon

Let ๐‘€ = ๐พ[๐‘…, ๐’•] be the projection matrix of a calibrated camera, the

normal ๐‘› to the plane of an horizon ๐‘™โ„Ž in the image is:

๐‘› = ๐พ๐‘‡๐‘™โ„Ž

C

๐‘›

lhoriz

ฯ€lโˆž

ฯ€'Once the camera is calibrated we can

compute the 3D orientation of any plane

for which we see the horizon

Giacomo Boracchi

Angle between vanishing points

Let ๐‘ฃ1 and ๐‘ฃ2 be the vanishing points of two directions ๐‘‘1 and ๐‘‘2, then

cos ๐œƒ =๐‘‘1 โ‹… ๐‘‘2

๐‘‘1 ๐‘‘2

And the same can be also computed from the vanishing points

cos ๐œƒ =๐‘ฃ1โŠบ๐Ž๐‘ฃ2

๐‘ฃ1โŠบ๐Ž๐‘ฃ1 ๐‘ฃ2

โŠบ๐Ž๐‘ฃ2

C

d1

v2

v1d2

๐œƒx1โˆž

x2โˆž

Giacomo Boracchi

Angles between two vanishing points

Let ๐‘ฃ1 and ๐‘ฃ2 be the vanishing points of two lines (having ideal points

๐‘‹1โˆž and ๐‘‹2โˆž), and let

๐Ž = ๐พ๐พโŠบ โˆ’1

Then If ๐œƒ is the angle between the two line directions, then

cos ๐œƒ =๐‘ฃ1โŠบ๐Ž๐‘ฃ2

๐‘ฃ1โŠบ๐Ž๐‘ฃ1 ๐‘ฃ2

โŠบ๐Ž๐‘ฃ2

Giacomo Boracchi

Angles between two planes

Let ๐‘™1 and ๐‘™2 be the horizon of planes having normal ๐‘›1 ๐‘›2

Then, the angle between the planes is

cos ๐œƒ =๐‘›1 โ‹… ๐‘›2

๐‘›1 ๐‘›2

cos ๐œƒ =๐‘™1โŠบ๐Žโˆ’1๐‘™2

๐‘™1โŠบ๐Žโˆ’1๐‘™1 ๐‘™2

โŠบ๐Žโˆ’1๐‘™2

Giacomo Boracchi

Camera Calibration from Vanishing Points

Vanishing points are images of points at infinity, and provide orientation

information as fixed stars.

Ideal points are part of the scene and can be used as references. Their

position in the image (i.e. the vanishing points) depend only on the

camera rotation.

Giacomo Boracchi

Calibration From 3D Orthogonal Vanishing Points

Note that any pair of vanishing point ๐‘ฃ1, ๐‘ฃ2 corresponding orthogonal

lines in the image yields a scalar equation in ๐Ž

๐‘ฃ1โŠบ๐Ž๐‘ฃ2

๐‘ฃ1โŠบ๐Ž๐‘ฃ1 ๐‘ฃ2

โŠบ๐Ž๐‘ฃ2= 0

๐‘ฃ1โŠบ๐Ž๐‘ฃ2 = 0

The matrix ๐Ž is symmetric (๐Ž = ๐พ๐พโŠบ โˆ’1), thus 5 unknonwns

๐Ž =

๐‘ค1 ๐‘ค2 ๐‘ค4

๐‘ค2 ๐‘ค3 ๐‘ค5

๐‘ค4 ๐‘ค5 ๐‘ค6

If the camera has zero skew ๐‘ค2 = 0

If pixels are squared ๐‘ค3 = ๐‘ค1

Giacomo Boracchi

Calibration From 3D Orthogonal Vanishing Points

The matrix ๐Ž is symmetric for a squared pixel and zeros-skew camera

๐Ž =๐‘ค1 0 ๐‘ค4

0 ๐‘ค1 ๐‘ค5

๐‘ค4 ๐‘ค5 ๐‘ค6

This has 4 unknowns (up to a scalar factor) -> three pairs of orthogonal

lines can be used to compute ๐Ž

Once ๐Ž has been computed, ๐พ can be obtained by Cholesky factorization

Giacomo Boracchi

Giacomo Boracchi

Giacomo Boracchi

Giacomo Boracchi

Recap

โ€ข Implications of image calibration

โ€ข Camera Center

โ€ข Viewing Rays

โ€ข Factorization of ๐‘€

โ€ข Conics and Conic Fitting

โ€ข Comments on Error Minimization

โ€ข Measuring Angles

โ€ข Single View Rectification

Next Class, Epipolar Geometry

๐‘ฅ ๐‘ฅโ€ฒ

๐‘‹

๐ถโ€ฒ๐ถ

๐‘’ ๐‘’โ€ฒ

๐œ‹

๐‘™ ๐‘™โ€ฒ