summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/UnWarpPlane.m
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/UnWarpPlane.m
parent601ed25a4c5b66cb75315832c15613a727db2c26 (diff)
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/UnWarpPlane.m')
-rwxr-xr-xSD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/UnWarpPlane.m54
1 files changed, 54 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/UnWarpPlane.m b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/UnWarpPlane.m
new file mode 100755
index 0000000..8addf52
--- /dev/null
+++ b/SD-VBS/common/toolbox/toolbox_basic/TOOLBOX_calib/UnWarpPlane.m
@@ -0,0 +1,54 @@
1function [u_hori,u_vert] = UnWarpPlane(x1,x2,x3,x4);
2
3% Recovers the two 3D directions of the rectangular patch x1x2x3x4
4% x1 is the origin point, ie any point of planar coordinate (x,y) on the
5% rectangular patch will be projected on the image plane at:
6% x1 + x * u_hori + y * u_vert
7%
8% Note: u_hori and u_vert are also the two vanishing points.
9
10
11if nargin < 4,
12
13 x4 = x1(:,4);
14 x3 = x1(:,3);
15 x2 = x1(:,2);
16 x1 = x1(:,1);
17
18end;
19
20
21% Image Projection:
22L1 = cross(x1,x2);
23L2 = cross(x4,x3);
24L3 = cross(x2,x3);
25L4 = cross(x1,x4);
26
27% Vanishing point:
28V1 = cross(L1,L2);
29V2 = cross(L3,L4);
30
31% Horizon line:
32H = cross(V1,V2);
33
34if H(3) < 0, H = -H; end;
35
36
37H = H / norm(H);
38
39
40X1 = x1 / dot(H,x1);
41X2 = x2 / dot(H,x2);
42X3 = x3 / dot(H,x3);
43X4 = x4 / dot(H,x4);
44
45scale = X1(3);
46
47X1 = X1/scale;
48X2 = X2/scale;
49X3 = X3/scale;
50X4 = X4/scale;
51
52
53u_hori = X2 - X1;
54u_vert = X4 - X1;