-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisp_vanish.m
69 lines (64 loc) · 2.4 KB
/
disp_vanish.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
57
58
59
60
61
62
63
64
65
66
67
68
69
function disp_vanish(rectimg, lines, vp)
% disp_vanish.m
%%
figure; imshow(rectimg,[]); hold on;
im_size = size(rectimg)
%%
if length(vp)==3 && ~isempty(vp{1}) && ~isempty(vp{2}) && ~isempty(vp{3})
plot([vp{1}(1) vp{2}(1) vp{3}(1)], [vp{1}(2) vp{2}(2) vp{3}(2)], 'ro', 'Markersize', 10, 'LineWidth', 2,'MarkerFaceColor','w');
% plot([vp{2}(1) vp{3}(1)], [vp{2}(2) vp{3}(2)], 'bx', 'Markersize', 20, 'LineWidth', 4);
try
[p1ext p2ext] = extline(vp{1}, vp{3}, size(rectimg,2), size(rectimg,1));
% plot([p1ext(1) p2ext(1)], [p1ext(2) p2ext(2)], 'w', 'LineWidth', 3);
plot([p1ext(1) p2ext(1)], [p1ext(2) p2ext(2)], 'c', 'LineWidth', 3);
catch
% extline might fail when both vp's are outside of image
end
try
[p1ext p2ext] = extline(vp{2}, vp{3}, size(rectimg,2), size(rectimg,1));
% plot([p1ext(1) p2ext(1)], [p1ext(2) p2ext(2)], 'w', 'LineWidth', 3);
plot([p1ext(1) p2ext(1)], [p1ext(2) p2ext(2)], 'c', 'LineWidth', 3);
catch
% extline might fail when both vp's are outside of image
end
end
%% undistorted
% figure; hold on;
% plot(vp1(1), vp1(2), 'r.', 'MarkerSize',20);
% plot(vp2(1), vp2(2), 'g.', 'MarkerSize',20);
% plot(vp3(1), vp3(2), 'b.', 'MarkerSize',20);
for k = 1:length(lines)
% xy = [lines(k).point1_dist; lines(k).point2_dist];
xy = [lines(k).point1; lines(k).point2];
if lines(k).lineclass == 1
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','red');
elseif lines(k).lineclass == 2
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
elseif lines(k).lineclass == 3
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','blue');
else
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','yellow');
end
end
% disp(round([vp1; vp2; vp3]));
% disp([normal_vec{1}; normal_vec{2}; normal_vec{3}]);
%% distorted
% figure; imshow(rectimg); hold on;
% plot(vp1(1), vp1(2), 'r.', 'MarkerSize',20);
% plot(vp2(1), vp2(2), 'g.', 'MarkerSize',20);
% plot(vp3(1), vp3(2), 'b.', 'MarkerSize',20);
% for k = 1:length(lines)
% xy = [lines(k).point1; lines(k).point2];
% if lines(k).lineclass1 == 1
% plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','red');
% elseif lines(k).lineclass2 == 1
% plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% elseif lines(k).lineclass3 == 1
% plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','blue');
% else
% plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','black');
% end
% end
% disp(round([vp1; vp2; vp3]));
% disp([n1; n2; n3]);
%