-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetHomographyMatrices.m
More file actions
55 lines (41 loc) · 1.01 KB
/
Copy pathgetHomographyMatrices.m
File metadata and controls
55 lines (41 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function [Hxy,Hxz,Hyz,P] = getHomographyMatrices(refX,refY,refZ,refXlen,refYlen,refZlen,vX,vY,vZ,O)
fprintf('Origin\n');
disp(O);
fprintf('Ref Length X\n');
disp(refXlen);
fprintf('Ref Length Y\n');
disp(refYlen);
fprintf('Ref Length Z\n');
disp(refZlen);
fprintf('Reference Point X\n');
disp(refX);
fprintf('Reference Point Y\n');
disp(refY);
fprintf('Reference Point Z\n');
disp(refZ);
% scaling factor
a_x = ((vX - refX) \ (refX - O))/refXlen;
a_y = ((vY - refY) \ (refY - O))/refYlen;
a_z = ((vZ - refZ) \ (refZ - O))/refZlen;
fprintf('Scaling Result Ax \n');
disp(a_x);
fprintf('Scaling Result Ay\n');
disp(a_y);
fprintf('Scaling Result Az\n');
disp(a_y);
% Projection Matrix P
P = [vX * a_x, vY * a_y, vZ * a_z, O];
P = [P(:,1) -P(:,2) P(:,3) P(:,4)];
fprintf('Projection Matrix\n');
disp(P)
% Homography Matrix H
Hxy = [P(:,1),P(:,2),P(:,4)];
Hxz = [P(:,1),P(:,3),P(:,4)];
Hyz = [P(:,2),P(:,3),P(:,4)];
fprintf('Homography XY\n')
disp(Hxy)
fprintf('Homography XZ\n')
disp(Hxz)
fprintf('Homography YZ\n')
disp(Hyz)
end