0001
0002
0003
0004
0005
0006
0007
0008
0009 clc
0010 close all
0011
0012 addpath(genpath('../General-Functions'))
0013
0014 fprintf('\n------ DEMO Single Image Geometry ------\n')
0015
0016 fprintf('\nIn order to shorten the output, we display transposed vectors\n')
0017
0018
0019
0020 fprintf('\nGiven:\n')
0021
0022
0023 fprintf('\n3D object point\n')
0024 X = [3,2,5,6]'; disp(['X = [', num2str(X'./X(end)),']'])
0025
0026
0027 c = 1;
0028 s = 0;
0029 xH = 0;
0030 yH = 0;
0031 m = 0;
0032
0033
0034 fprintf('\nProjection center\n')
0035 X0 = [1,2,3,1]'; disp(['XO = [', num2str(X0'),']'])
0036
0037 r=[0,0,0]';
0038
0039
0040 fprintf('\nInterior orientaion, calibration matrix\n')
0041 K = [c,s*c,xH;0,c*(1+m),yH;0,0,1]
0042
0043 fprintf('\nExterior orientaion, rotation matrix\n')
0044 R = calc_Rot_r(r)
0045
0046
0047 fprintf('\nProjection matrix for points, P = K R [I | -XO]\n')
0048 P = calc_P_from_KRZ(K,R,X0(1:3)/X0(4))
0049
0050
0051 fprintf('\nProjection matrix for 3D-lines, see PCV Eq.(12.71)\n')
0052 Q = calc_Q_from_P(P)
0053
0054
0055 fprintf('\nProjection of object point --> homogeneous coordiantes of image point\n')
0056 xh = P*X; disp(['x_h = [', num2str(xh'),']'])
0057
0058 fprintf('\nEuclidian coordinates of image point\n')
0059 xe = xh(1:2)/xh(3); disp(['x = [', num2str(xe'),']'])
0060
0061
0062 fprintf('\nProjection ray in Plücker coordiantes\n')
0063 Lxs = calc_Dual*Q'*xh ; disp(['L_xs = [', num2str(Lxs'),']'])
0064
0065 fprintf('\nCheck whether projection ray passes through 3D-point: should be 0\n')
0066 test_val = calc_Gammadual(Lxs) * X ; disp(['[', num2str(test_val'),']'])
0067
0068