This page is located in archive. Go to the latest version of this course pages.

Homework 03 - Perspective Camera Pose and Internal Calibration


[ K R C ] = Q2KRC( Q );

Create a function Q2KRC for decomposing a camera matrix Q (3×4) into into the projection centre C (3×1), rotation matrix R (3×3) and upper triangular matrix K (3×3) such that

Q = λ ( K R | - K R C )

where K(3,3) = 1, K(1,1) > 0, and det(R) = 1.

plot_csystem( Base, b, color, name );

Create a function for drawing a coordinate system base Base located in the system origin b. The base and origin is expressed in the world coordinate system δ. The base consists of a three or two three-dimensional column vectors. E.g.

plot_csystem( eye(3), zeros(3,1), 'k', '\\delta'' )
should plot the δ system. The function should label each base vector (e.g. δ_x, δ_y, δ_z). The text function can be used, e.g.

text( x, y, z, [ name '_x' ], 'color', color )

(here x,y,z are coordinates of the end of the first base vector (base x-axis), name and color are the input arguments). Note that Matlab can plot greek numbers using TeX sequences ( '\\alpha', '\\beta', etc.).


  1. Decompose the optimal camera matrix Q you have recovered in HW-02. Let the horizontal pixel size be 5 μm. Compute f (in metres) and compose matrix Pb (Pβ) using K, R, C, and f.
  2. For the camera, compute bases and centres of coordinate systems α, β, γ, δ, ε, κ, υ. Express all bases and centres in the world coordinate system δ. The bases should be stored in matrices Alpha, Beta, Gamma, Delta, Epsilon, Kappa, Nu, respectively, the coordinate system centres should be stored in matrices a, b, g, d, e, k, n, respectively.
  3. Save Pb, f, all bases and coordinate system centres into 03_bases.mat.
    save( 'bases.mat', 'Pb', 'f', 'Alpha', 'a', 'Beta', 'b', 'Gamma', 'g', ...
          'Delta', 'd', 'Epsilon', 'e', 'Kappa', 'k', 'Nu', 'n', '-v6' );
  4. For following plots, multiply the first vectors of bases α, β by image width (1100) and the second vectors of bases α, β by image height (850).
  5. Draw the coordinate systems δ (black), ε (magenta), κ (brown), υ (cyan), draw the system β (red) with its base scaled-up 50 times additionally , and draw the 3D scene points (109 points, blue). Label each base vector (e.g. δ_x, δ_y, δ_z). Export as 03_figure1.pdf.
  6. Draw the coordinate systems α (green), β (red), γ (blue), draw the image points (109 points, blue). Label each base vector. Export as 03_figure2.pdf.
  7. Draw the coordinate systems δ (black), ε (magenta), plot the 3D scene points (blue), and plot centers (red) of all cameras you have tested in HW-02 (using the decomposition). Zoom-in such that the coordinate systems are clearly visible. Export as 03_figure3.pdf. Note that the coordinate system ε is for the optimal camera only.


Upload an archive containing the following files:

  1. 03_bases.mat
  2. 03_figure1.pdf, 03_figure2.pdf, 03_figure3.pdf
  3. Q2KRC.m, plot_csystem.m
  4. hw03.m – your Matlab implementation entry point; it makes all required figures, output files and prints.
  5. any other files required by hw03.m.

Note: The required files must be in the root directory of the archive.

courses/gvg/labs/gvg-2017-hw-03.txt · Last modified: 2018/02/09 20:34 (external edit)