Computer Vision: Lecture 3 · 2016. 1. 27. · logoonly The Inner Parameters -K The matrix K is the...

28
logoonly Computer Vision: Lecture 3 Magnus Oskarsson 2016-01-27 Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 1 / 28

Transcript of Computer Vision: Lecture 3 · 2016. 1. 27. · logoonly The Inner Parameters -K The matrix K is the...

  • logoonly

    Computer Vision: Lecture 3

    Magnus Oskarsson

    2016-01-27

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 1 / 28

  • logoonly

    Todays Lecture

    Camera Calibration

    The inner parameters - K .

    Projective vs. Euclidean Reconstruction.

    Finding the camera matrix.

    DLT - Direct Linear Transformation.

    Normalization of uncalibrated cameras.

    Radial distortion

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 2 / 28

  • logoonly

    The Inner Parameters -K

    The matrix K is the upper triangular matrix:

    K =

    γf sf x00 f y00 0 1

    .f - focal length

    γ - aspect ratio

    s - skew

    (x0, y0) - principal points

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 3 / 28

  • logoonly

    The Inner Parameters -K

    The focal length f fxfy1

    = f 0 00 f 0

    0 0 1

    xy1

    Re scales the images (e.g. meters → pixels).

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 4 / 28

  • logoonly

    The Inner Parameters -K

    The principal point (x0, y0) fx + x0fy + y01

    = f 0 x00 f y0

    0 0 1

    xy1

    Re centers the image. Typically transforms the point (0, 0, 1) to themiddle of the image.

    0

    0

    480

    640

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 5 / 28

  • logoonly

    The Inner Parameters -K

    Aspect ratio γfx + x0fy + y01

    = γf 0 x00 f y0

    0 0 1

    xy1

    Pixels are not always squares but can be rectangular. In such cases thescaling in the x-direction should be different from the y-direction.

    Skew γf sf x00 f y00 0 1

    Corrects for tilted pixels. Typically zero.Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 6 / 28

  • logoonly

    Projective vs. Euclidean Reconstruction

    Calibrated Cameras

    A cameraP = K [R t] ,

    where the inner parameters K are known is called calibrated. If we changecoordinates in the image using

    x̃ = K−1x,

    we get a so called normalized (calibrated) camera

    x̃ = K−1K [R t]X = [R t]X.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 7 / 28

  • logoonly

    Projective vs. Euclidean Reconstruction

    Projective

    The reconstruction is determined up to a projective transformation.If λx = PX, then for any projective transformation

    X̃ = H−1X

    we haveλx = PHH−1X = PHX̃.

    PH is also a valid camera.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 8 / 28

  • logoonly

    Projective vs. Euclidean Reconstruction

    Euclidean

    The reconstruction is determined up to a similarity transformation.If λx = [R t]X, then for any similarity transformation

    X̃ =

    [sQ v0 1

    ]−1X

    we haveλ

    sx = [R t]

    [Q v/s0 1/s

    ]X̃ = [RQ R

    v

    s+

    t

    s]X̃.

    Since RQ is a rotation this is a normalized camera.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 9 / 28

  • logoonly

    Projective vs. Euclidean Reconstruction

    Projective Euclidean

    Arc de triomphe, Paris. The reconstructions have exactly the samereprojection error. But the projective coordinate system makes things lookstrange.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 10 / 28

  • logoonly

    Projective vs. Euclidean Reconstruction

    Demo.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 11 / 28

  • logoonly

    Finding K

    See lecture notes.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 12 / 28

  • logoonly

    RQ-factorization

    Theorem

    If A is an n × n matrix then there is an orthogonal matrix Q and a righttriangular matrix R such that A = RQ.

    (If A is invertible and the diagonal elements are chosen to be positive,then the factorization is unique.)

    Note: In our case we will use K for the triangular matrix and R for therotation.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 13 / 28

  • logoonly

    Finding K

    See lecture notes.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 14 / 28

  • logoonly

    Direct Linear Transformation - DLT

    Finding the camera matrix

    Use images of a known object to eliminate the projective ambiguity. If Xiare 3d-points of a known object, and xi corresponding projections we have

    λ1x1 = PX1λ2x2 = PX2

    ...λNxN = PXN .

    There are 3N equations and 11 + N unknowns. We need3N ≥ 11 + N ⇒ N ≥ 6 points to solve the problem.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 15 / 28

  • logoonly

    Direct Linear Transformation - DLT

    Matrix Formulation

    P =

    pT1pT2pT3

    where pi are the rows of P The first equality is

    XT1 p1 − λ1x1 = 0XT1 p2 − λ1y1 = 0XT1 p3 − λ1 = 0,

    where x1 = (x1, y1, 1). In matrix form

    XT1 0 0 −x10 XT1 0 −y10 0 XT1 −1

    p1p2p3λ1

    = 00

    0

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 16 / 28

  • logoonly

    Direct Linear Transformation - DLT

    Matrix Formulation

    More equations:

    XT1 0 0 −x1 0 0 . . .0 XT1 0 −y1 0 0 . . .0 0 XT1 −1 0 0 . . .XT2 0 0 0 −x2 0 . . .0 XT2 0 0 −y2 0 . . .0 0 XT2 0 −1 0 . . .XT3 0 0 0 0 −x3 . . .0 XT3 0 0 0 −y3 . . .0 0 XT3 0 0 −1 . . ....

    ......

    ......

    .... . .

    ︸ ︷︷ ︸

    =M

    p1p2p3λ1λ2λ3...

    ︸ ︷︷ ︸

    =v

    = 0

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 17 / 28

  • logoonly

    Direct Linear Transformation - DLT

    Homogeneous Least Squares

    See lecture notes...

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 18 / 28

  • logoonly

    Singular values decomposition

    Theorem

    Each m × n matrix M (with real coefficients) can be factorized into

    M = USV T ,

    where U and V are orthogonal (m ×m and n × n respectively),

    S =

    [diag(σ1, σ2, ..., σr ) 0

    0 0

    ],

    σ1 ≥ σ2 ≥ ... ≥ σr > 0 and r is the rank of the matrix.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 19 / 28

  • logoonly

    Direct Linear Transformation - DLT

    Homogeneous Least Squares

    See lecture notes...

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 20 / 28

  • logoonly

    Direct Linear Transformation - DLT

    Improving the Numerics (Normalization of uncalibrated cameras)

    The matrix contains entries xi , yj and ones. Since xi and yi can be about athousand, the numerics are often greatly improved by translating thecoordinates such that their “center of mass” is zero and then rescaling thecoordinates to be roughly 1.

    Change coordinates according to

    x̃ =

    s 0 −sx̄0 s −sȳ0 0 1

    x.Solve the homogeneous linear least squares system and transformback to the original coordinate system.

    Similar transformations for the 3D-points Xi may also improve theresults.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 21 / 28

  • logoonly

    Pose estimation using DLT

    3D points measured using scanning arm.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 22 / 28

  • logoonly

    Pose estimation using DLT

    14 points used for computing the camera matrix.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 23 / 28

  • logoonly

    Pose estimation using DLT

    14 points used for computing the camera matrix.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 24 / 28

  • logoonly

    Texturing the chair

    Project the rest of the points into the image.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 25 / 28

  • logoonly

    Texturing the chair

    Form triangles. Use the texture from the image.

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 26 / 28

  • logoonly

    Textured chair

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 27 / 28

  • logoonly

    Radial Distortion

    Not modeled by the K -matrix.Cannot be removed by a projective mapping sincelines are not mapped onto lines (see Szeliski).

    Magnus Oskarsson Computer Vision: Lecture 3 2016-01-27 28 / 28