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

Homework 03 - Perspective Camera Pose and Internal Calibration

Implementation

matlab python
[ K, R, C ] = Q2KRC( Q ) K, R, C = hw03.Q2KRC( Q )

Create a function Q2KRC for decomposing a non-zero scale of the image projection matrix Q (3×4) into into the camera projection center 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.

Create a function 'plot_csystem' for drawing a coordinate system with base Base located in the origin b with a given name and color. The base and origin are expressed in the world coordinate system $\delta$. The base consists of a two or three three-dimensional column vectors of coordinates. E.g.

plot_csystem(eye(3),zeros(3,1),'k','\\delta'); hw03.plot_csystem(np.eye(3),np.zeros([3,1]),'k','d')

should plot the $\delta$ system. The function should label each base vector (e.g. $\delta_x$, $\delta_y$, $\delta_z$). The automatic evaluation just verifies if the function with this name is present in your code.

Steps

  1. Decompose the optimal scaled image projection matrix Q you have recovered in HW-02. Let the horizontal pixel size be 5 μm. Compute f (in metres) and compose the image projection matrix Pb ($\mathtt{P}_\beta$) using K, R, C, and f.
  2. For the camera, compute bases and centres of coordinate systems $(o, \alpha)$, $(C, \beta)$, $(C, \gamma)$, $(O, \delta)$, $(C, \epsilon)$, $(O, \kappa)$, $(C, \nu)$ (see Figure 7.2 in GVG Materials). Express all bases in basis $\delta$ and centres in the world coordinate system $(O, \delta)$. 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.
  4. For the following plots, multiply the first vectors of bases $\alpha$, $\beta$ by image width (1100) and the second vectors of bases $\alpha$, $\beta$ by image height (850).
  5. Draw the coordinate systems with bases $\delta$ (black), $\epsilon$ (magenta), $\kappa$ (brown), $\nu$ (cyan), draw the system with basis $\beta$ (red) with its base scaled-up 50 times additionally , and draw the 3D scene points (109 points, blue). Label each base vector (e.g. $\delta_x$, $\delta_y$, $\delta_z$). Export as 03_figure1.pdf.
  6. Draw the coordinate systems with bases $\alpha$ (green), $\beta$ (red), $\gamma$ (blue), draw the image points (109 points, blue). Label each base vector. Export as 03_figure2.pdf.
  7. Draw the coordinate systems with bases $\delta$ (black), $\epsilon$ (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 with basis $\epsilon$ is for the optimal camera only.
save( '03_bases.mat', 'Pb', 'f', …
'Alpha', 'a', …
'Beta', 'b',…
'Gamma', 'g', …
'Delta', 'd', …
'Epsilon', 'e',…
'Kappa', 'k', …
'Nu', 'n' );
sio.savemat( '03_bases.mat', { 'Pb':Pb, 'f':f,
'Alpha':Alpha, 'a':a,
'Beta':Beta, 'b':b,
'Gamma':Gamma, 'g':g,
'Delta':Delta, 'd':d,
'Epsilon':Epsilon, 'e':e,
'Kappa':Kappa, 'k':k,
'Nu':Nu, 'n':n } )

Upload

Upload an archive containing the following files:

matlab python
03_bases.mat
03_figure1.pdf, 03_figure2.pdf, 03_figure3.pdf
Q2KRC.m, plot_csystem.m
hw03.m hw03.py containing the required functions
any other file used by your solution

The input entry point script hw03 should make all required figures, output files and prints without manual intervention.

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

courses/gvg/labs/hw-03.txt · Last modified: 2023/03/07 22:23 by korotvik