~~NOTOC~~ ====== 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' ); ==== Task ==== - Load the points ''u'', ''x'' and the image into your matlab workspace. - Examine the image points ''u'' by displaying them over the imageimage( img ); hold on; % without this, the next drawing command would clear the figure plot( u(1,:), u(2,:), '.' ); hold off axis equal - 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 - 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). - Perform all possible selections of 5 1/2 points from your 10 points (using ''ix'') - For each selection compute the projection matrix ''Q'' projecting the selected 5 1/2 points exactly. - 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. - From all computed projection matrices select the one that has the maximum reprojection error minimal. - 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 [[http://cw.felk.cvut.cz/courses/GVG/2017/Tools|Tools repository]].) - 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''. - 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''. - 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 ^^ | {{courses:gvg:labs:02_q_projections.png|}} | {{courses:gvg:labs:02_q_projections_errors.png|}} | | {{courses:gvg:labs:02_q_maxerr.png|}} | {{courses:gvg:labs:02_q_pointerr.png|}} | ==== Upload ==== Upload an archive containing the following files: - ''02_Q_projections.pdf'', ''02_Q_projections_errors.pdf'' - ''02_Q_maxerr.pdf'', ''02_Q_pointerr.pdf'' - ''estimate_Q.m'' - implementation of the P matrix estimation - ''hw02.m'' - your Matlab implementation. It makes all required figures, output files and prints. - any other files required by hw02.m. Note: The required files must be in the root directory of the archive.