Homework 02 - Projection Matrix of a Perspective Camera

Input Data

Find your data in the assignment '00data: Your data' in the submission system; the image daliborka_01.jpg, coordinates of 3D points x and their projections u, and point index vector ix. The data can be loaded e.g.

load( 'daliborka_01-ux.mat' ); % loads all variables from the file into the workspace
img = imread( 'daliborka_01.jpg' );


  1. Load the points u, x and the image into your matlab workspace.
  2. Examine the image points u by displaying them over the image
    image( img );
    hold on; % without this, the next drawing command would clear the figure
    plot( u(1,:), u(2,:), '.' );
    hold off
    axis equal
  3. Examine the 3D points x by displaying them (into a new figure created by e.g. subfig) (The 3D plot can be e.g. rotated.)
    plot3( x(1,:), x(2,:), x(3,:) )
    axis equal
  4. Implement the estimation of camera projection matrix Q from given image points u and 3D points x given your selection index ix as a function
    [Q points_sel err_max err_points Q_all] = estimate_Q( u, x, ix )
    where Q is the best projection matrix, points_sel are indices of the 6 points (w.r.t to all 109 points). The other output arguments are optional (not tested by A.E.), for your convenience: err_max should be vector of all maximal errors for all tested matrices, err_points should be vector of point errors for the best camera and Q_all should be cell matrix containing all tested camera matrices (will be used in HW-03).
    1. Perform all possible selections of 5 1/2 points from your 10 points (using ix)
    2. For each selection compute the projection matrix Q projecting the selected 5 1/2 points exactly.
    3. Compute the reprojection errors โ€“ Euclidean distances between measured image points u and the projections of 3D points x using the particular matrix Q (for all 109 points). Find the maximum error over all the correspondences.
    4. From all computed projection matrices select the one that has the maximum reprojection error minimal.
  5. Plot the decadic logarithm (log10()) of the maximum reprojection error of all the computed projection matrices as the function of their selection index and export the plot as a pdf file 02_Q_maxerr.pdf. (Use fig2pdf.m utility in Tools repository.)
  6. Display the image and plot u as blue dots (plot specifier 'b.'), highlight the points used for computing the best Q by plotting them as yellow dots ('y.'), and plot the projections of x using the best Q as red circles ('ro'). Export the plot as 02_Q_projections.pdf.
  7. Display the image and plot u as blue dots, highlight the points used for computing the best Q by plotting them as yellow dots, and plot the displacements of projected points x multiplied 100 times as red lines. Export the plot as 02_Q_projections_errors.pdf.
  8. Plot the reprojection error of the best Q on all 109 points as the function of point index and export as 02_Q_pointerr.pdf.

(Note: do not forget to create figure titles and describe axes where appropriate.)

Example results


Upload an archive containing the following files:

  1. 02_Q_projections.pdf, 02_Q_projections_errors.pdf
  2. 02_Q_maxerr.pdf, 02_Q_pointerr.pdf
  3. estimate_Q.m - implementation of the P matrix estimation
  4. hw02.m - your Matlab implementation. It makes all required figures, output files and prints.
  5. any other files required by hw02.m.

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

courses/gvg/labs/gvg-2017-hw-02.txt ยท Last modified: 2018/02/14 15:57 by policmic