-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcamheightCriminisi.m
56 lines (43 loc) · 1.13 KB
/
camheightCriminisi.m
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
56
clear all; close all;
addpath('./matlab');
Zc_gt = 5.2;
Zt = 1.8;
% Plot word coordinate frame
Tcam = transl(0,0,Zc_gt)*trotx(deg2rad(-90))*troty(deg2rad(45))*trotx(deg2rad(-35));
cam = CentralCamera('focal', 0.015,'pixel',10e-6, ...
'resolution',[1280 1024],'centre',[640 512],'pose',Tcam);
world = SE3();
trplot(world,'frame','0','color','b');
xlim([-1 5]);
ylim([-1 5]);
zlim([-0.1 5.5]);
% plot camera
cam.plot_camera();
% Plot points
hold on;
%%P = mkgrid(2,0.2,'pose',transl(0.7,0.7,0));
%P = mkcube(1.8,'pose',transl([4,4,0.9]));
%P = P(:,[1,5]);
P = [ 4 4; 4 4; 0 Zt];
plot3(P(1,:),P(2,:),P(3,:),'LineWidth',7);
cam.plot(P);
B = P(:,1);
T = P(:,2);
xy = cam.project(P);
b = [xy(:,1);1];
t = [xy(:,2);1];
R = cam.T.R;
R = R';
K = cam.K
[v1,v2,v3] = computeVanishingPointsviaRandK(R,K);
Zc = computeCameraHeight(v1,v2,v3,b,t,Zt);
% hoz = cross(v1,v2);
% btLine = cross(b,t);
% i = cross(btLine,hoz);
% i = i/i(3);
%
% hoznor = hoz/norm(hoz);
%
% alpha = (-norm(cross(b,t)))/(dot(hoznor,b)*norm(cross(v3,t))*Zt)
% Zc = (-norm(cross(b,i)))/(dot(hoznor,b)*norm(cross(v3,i))*alpha)
% Zc2 = -(inv(dot(hoznor,v3)))/alpha