-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDLT_test_2cam.m
More file actions
executable file
·132 lines (86 loc) · 3 KB
/
DLT_test_2cam.m
File metadata and controls
executable file
·132 lines (86 loc) · 3 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
% DLT test script - modified to work with gwyneth's data 20040129
% clear all
%
% num_pts = 20;
%
% line_param_1 = linspace( -40, 5, 100 );
%
% line_param_2 = linspace( -40, 5, 100 );
%
% line_param_3 = linspace( -5, 50, 100 );
%
% [ L_1, L_2, L_3, F ] = get_test_pts; ----> run get_test_points_g before this
% Changes to run this test with get_test_po* GW Pulford, ''Taxonomy of multiple target tracking methods'', IEE Radar Sonar Navig, 2005
** ([[:Image:Pulford2005_IEERadarSonarNavig.pdf]])ints_g
num_pts = 40;
line_param_1 = linspace( -50, 600, 100 ); %red
line_param_2 = linspace( -60, 500, 100 ); %green
%line_param_3 = linspace( 0, 100, 100 ); %yellow
% Get cube bndry
coords_min = min( F );
coords_max = max( F );
% Get some random points
rnd_pts = rand( num_pts, 3 );
% Scale random pts into calibration data
a = repmat( ( coords_max - coords_min ), num_pts, 1 );
b = repmat( coords_min, num_pts, 1 );
rnd_pts = a.*rnd_pts + b;
figure%(1)
hold on
plot3( rnd_pts(:,1), rnd_pts(:,2), rnd_pts(:,3), '.b' )
% Camera 1 plot ------------------------------------------------
% Get DLT coeff 1
[ DLT_1, avgres ] = dltfu( F, L_1, [] );
% Get image points
[ u, v ] = dlt_3D_to_2D( DLT_1, rnd_pts(:,1), rnd_pts(:,2), rnd_pts(:,3) );
% Get the line params
for i = 1:num_pts
[ params_x( i, 1:2 ), params_y( i, 1:2 ), params_z( i, 1:2 ) ] = dlt_2D_to_3D( DLT_1, u(i), v(i) );
line(i).x = params_x(i,1) + params_x(i,2)*line_param_1;
line(i).y = params_y(i,1) + params_y(i,2)*line_param_1;
line(i).z = params_z(i,1) + params_z(i,2)*line_param_1;
plot3( line(i).x, line(i).y, line(i).z, 'r' );
%pause
end
%axis equal
% Camera 2 plot ------------------------------------------------
% Get DLT coeff 1
[ DLT_2, avgres ] = dltfu( F, L_2, [] );
% Get image points
[ u, v ] = dlt_3D_to_2D( DLT_2, rnd_pts(:,1), rnd_pts(:,2), rnd_pts(:,3) );
% Get the line params
for i = 1:num_pts
[ params_x( i, 1:2 ), params_y( i, 1:2 ), params_z( i, 1:2 ) ] = dlt_2D_to_3D( DLT_2, u(i), v(i) );
line(i).x = params_x(i,1) + params_x(i,2)*line_param_2;
line(i).y = params_y(i,1) + params_y(i,2)*line_param_2;
line(i).z = params_z(i,1) + params_z(i,2)*line_param_2;
plot3( line(i).x, line(i).y, line(i).z, 'g' );
%pause
end
axis equal
% % Camera 3 plot ------------------------------------------------
%
% % Get DLT coeff 1
% [ DLT_3, avgres ] = dltfu( F, L_3, [] );
%
% % Get image points
% [ u, v ] = dlt_3D_to_2D( DLT_3, rnd_pts(:,1), rnd_pts(:,2), rnd_pts(:,3) );
%
% % Get the line params
% for i = 1:num_pts
%
% [ params_x( i, 1:2 ), params_y( i, 1:2 ), params_z( i, 1:2 ) ] = dlt_2D_to_3D( DLT_3, u(i), v(i) );
%
% line(i).x = params_x(i,1) + params_x(i,2)*line_param_3;
%
% line(i).y = params_y(i,1) + params_y(i,2)*line_param_3;
%
% line(i).z = params_z(i,1) + params_z(i,2)*line_param_3;
%
% plot3( line(i).x, line(i).y, line(i).z, 'y' );
%
% %pause
%
% end
axis tight
view( 30, 45 )