diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/fact')
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/construct_w.m | 25 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/construct_w2.m | 25 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/factor.m | 50 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/factor_test.m | 52 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/factor_test2.m | 52 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/factorizaion.tar | bin | 0 -> 81920 bytes | |||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/findG.m | 48 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/findg1.m | 49 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/findg2.m | 56 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/hotel.mat | bin | 0 -> 56320 bytes | |||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/show_3dpoints.m | 22 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/show_S.m | 17 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/show_t.m | 10 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/show_t3.m | 10 | ||||
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/zt.m | 6 |
15 files changed, 422 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/fact/construct_w.m b/SD-VBS/common/toolbox/toolbox_basic/fact/construct_w.m new file mode 100755 index 0000000..372b4b6 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/fact/construct_w.m | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | function W = construct_w(centers,Ds,img_center,indexes,frames) | ||
| 2 | % | ||
| 3 | % function W = construct_w(centers,Ds,img_center,indexes,frames) | ||
| 4 | % optional: frames | ||
| 5 | % | ||
| 6 | |||
| 7 | |||
| 8 | points = length(indexes); | ||
| 9 | if (nargin == 4), | ||
| 10 | frames = 0.5*size(centers,2); | ||
| 11 | end | ||
| 12 | |||
| 13 | W = zeros(2*frames,points); | ||
| 14 | |||
| 15 | center_x = img_center(1); | ||
| 16 | center_y = img_center(2); | ||
| 17 | |||
| 18 | for j=1:frames, | ||
| 19 | % x is centers(:,2*j-1) | ||
| 20 | % y is centers(:,2*j) | ||
| 21 | % d is Ds(:,2*j-1) | ||
| 22 | W(j,:) = (centers(indexes,2*j-1) -center_x)'./Ds(indexes,2*j-1)'; | ||
| 23 | W(j+frames,:) = (centers(indexes,2*j) -center_y)'./Ds(indexes,2*j-1)'; | ||
| 24 | % W(j+2*frames,:) = ones(1,points)./Ds(indexes,2*j-1)'; | ||
| 25 | end \ No newline at end of file | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/fact/construct_w2.m b/SD-VBS/common/toolbox/toolbox_basic/fact/construct_w2.m new file mode 100755 index 0000000..b2939b7 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/fact/construct_w2.m | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | function W = construct_w2(centers,Ds,img_center,indexes,frames) | ||
| 2 | % | ||
| 3 | % function W = construct_w2(centers,Ds,img_center,indexes,frames) | ||
| 4 | % optional: frames | ||
| 5 | % | ||
| 6 | |||
| 7 | |||
| 8 | points = length(indexes); | ||
| 9 | if (nargin == 4), | ||
| 10 | frames = 0.5*size(centers,2); | ||
| 11 | end | ||
| 12 | |||
| 13 | W = zeros(3*frames,points); | ||
| 14 | |||
| 15 | center_x = img_center(1); | ||
| 16 | center_y = img_center(2); | ||
| 17 | |||
| 18 | for j=1:frames, | ||
| 19 | % x is centers(:,2*j-1) | ||
| 20 | % y is centers(:,2*j) | ||
| 21 | % d is Ds(:,2*j-1) | ||
| 22 | W(j,:) = (centers(indexes,2*j-1) -center_x)'./Ds(indexes,2*j-1)'; | ||
| 23 | W(j+frames,:) = (centers(indexes,2*j) -center_y)'./Ds(indexes,2*j-1)'; | ||
| 24 | W(j+2*frames,:) = ones(1,points)./Ds(indexes,2*j-1)'; | ||
| 25 | end \ No newline at end of file | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/fact/factor.m b/SD-VBS/common/toolbox/toolbox_basic/fact/factor.m new file mode 100755 index 0000000..635c29a --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/fact/factor.m | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | % | ||
| 2 | % Usage: | ||
| 3 | % | ||
| 4 | % [R,t,S] = factor(W) | ||
| 5 | % | ||
| 6 | % Function to factor a matrix of input data (W) into the camera | ||
| 7 | % rotation matrix (R), translation (t), and the shape matrix (S). | ||
| 8 | % Three-dimensional version. Failure of normalization results in | ||
| 9 | % empty R and S. | ||
| 10 | |||
| 11 | function [R,t,S] = factor(W) | ||
| 12 | |||
| 13 | pts = size(W,2); | ||
| 14 | t = W*ones(pts,1)/pts; | ||
| 15 | W = W - t*ones(1,pts); | ||
| 16 | |||
| 17 | % Use SVD to factor W. | ||
| 18 | [a,b,c] = svd(W,0); | ||
| 19 | |||
| 20 | smallb = b(1:3,1:3); % Since W is rank 3, b has only three meaningful values | ||
| 21 | sqrtb = sqrt(smallb); | ||
| 22 | Rhat = a(:,1:3) * sqrtb; | ||
| 23 | Shat = sqrtb * c(:,1:3)'; | ||
| 24 | |||
| 25 | G = findG(Rhat); | ||
| 26 | |||
| 27 | if size(G,1) == 0, | ||
| 28 | R = []; | ||
| 29 | S = []; | ||
| 30 | else | ||
| 31 | R = Rhat*G; | ||
| 32 | S = inv(G)*Shat; | ||
| 33 | |||
| 34 | % rotation matrix that aligns the reference frame with the first camera | ||
| 35 | F = size(R,1)/2; | ||
| 36 | R1 = R(1,:); | ||
| 37 | R1 = R1/norm(R1); | ||
| 38 | R2 = R(F+1,:); | ||
| 39 | R2 = R2/norm(R2); | ||
| 40 | R3 = cross(R1,R2); | ||
| 41 | R3 = R3/norm(R3); | ||
| 42 | P = [R1; R2; R3]; | ||
| 43 | P = P'; | ||
| 44 | |||
| 45 | R = R*P; | ||
| 46 | S = inv(P)*S; | ||
| 47 | end | ||
| 48 | |||
| 49 | |||
| 50 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/fact/factor_test.m b/SD-VBS/common/toolbox/toolbox_basic/fact/factor_test.m new file mode 100755 index 0000000..12ceb95 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/fact/factor_test.m | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | % | ||
| 2 | % Usage: | ||
| 3 | % | ||
| 4 | % [R,t,S] = factor(W) | ||
| 5 | % | ||
| 6 | % Function to factor a matrix of input data (W) into the camera | ||
| 7 | % rotation matrix (R), translation (t), and the shape matrix (S). | ||
| 8 | % Three-dimensional version. Failure of normalization results in | ||
| 9 | % empty R and S. | ||
| 10 | |||
| 11 | function [R,t,S,C,b] = factor(W) | ||
| 12 | |||
| 13 | pts = size(W,2); | ||
| 14 | t = W*ones(pts,1)/pts; | ||
| 15 | W = W - t*ones(1,pts); | ||
| 16 | |||
| 17 | % Use SVD to factor W. | ||
| 18 | [a,b,c] = svd(W,0); | ||
| 19 | |||
| 20 | figure(3);plot(diag(b)) | ||
| 21 | |||
| 22 | smallb = b(1:3,1:3); % Since W is rank 3, b has only three meaningful values | ||
| 23 | sqrtb = sqrt(smallb); | ||
| 24 | Rhat = a(:,1:3) * sqrtb; | ||
| 25 | Shat = sqrtb * c(:,1:3)'; | ||
| 26 | |||
| 27 | [G,C] = findg1(Rhat); | ||
| 28 | |||
| 29 | if size(G,1) == 0, | ||
| 30 | R = []; | ||
| 31 | S = []; | ||
| 32 | else | ||
| 33 | R = Rhat*G; | ||
| 34 | S = inv(G)*Shat; | ||
| 35 | |||
| 36 | % rotation matrix that aligns the reference frame with the first camera | ||
| 37 | F = size(R,1)/2; | ||
| 38 | R1 = R(1,:); | ||
| 39 | R1 = R1/norm(R1); | ||
| 40 | R2 = R(F+1,:); | ||
| 41 | R2 = R2/norm(R2); | ||
| 42 | R3 = cross(R1,R2); | ||
| 43 | R3 = R3/norm(R3); | ||
| 44 | P = [R1; R2; R3]; | ||
| 45 | P = P'; | ||
| 46 | |||
| 47 | R = R*P; | ||
| 48 | S = inv(P)*S; | ||
| 49 | end | ||
| 50 | |||
| 51 | |||
| 52 | |||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/fact/factor_test2.m b/SD-VBS/common/toolbox/toolbox_basic/fact/factor_test2.m new file mode 100755 index 0000000..3520122 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/fact/factor_test2.m | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | % | ||
| 2 | % Usage: | ||
| 3 | % | ||
| 4 | % [R,t,S] = factor(W) | ||
| 5 | % | ||
| 6 | % Function to factor a matrix of input data (W) into the camera | ||
| 7 | % rotation matrix (R), translation (t), and the shape matrix (S). | ||
| 8 | % Three-dimensional version. Failure of normalization results in | ||
| 9 | % empty R and S. | ||
