matlab 如何从本质矩阵求出平移矩阵?

0yg35tkg  于 2022-11-15  发布在  Matlab
关注(0)|答案(1)|浏览(213)

我必须重建一些可见特征的3D位置,这些可见特征在从汽车拍摄的两张图像上可见。这些照片有不同的位置和Angular 。我能够从第一张图像推导出矩阵K,因为项目的要求需要该特定图像的相机校准矩阵。
对于3D重建,我必须遵循以下步骤:
1.找到匹配点,估计基本矩阵F
1.由于我没有关于P2(第二张图像的投影矩阵)的任何信息,所以我必须使用基本矩阵才能检索第二个相机的矩阵RT
1.进行三角剖分,建立三维位置。

%% finding fundomental metrix
matched_points_image1  = [x_i_1, y_i_1];
matched_points_image2 = [x_i_2, y_i_2];

[F, inliers] = estimateFundamentalMatrix(matched_points_image1,matched_points_image2,'NumTrials',2000);

F = [-0.0000   -0.0000    0.0028;
    0.0001   -0.0000   -0.0038;
   -0.0050   -0.0060    1.0000];

%% Finding the essential metrix
fprintf("Finding the essential metrics because we don't know the R and T between two cameras whose took the pictures...\n")
K1 = [ 1.1137         0    1.2254;
         0    1.6541    0.0428;
         0         0    0.0001];

E = K1'*F*K1;

%putting the first camera as world reference 
P1 = K1*eye(3,4);

%Estimation of P2 based on svd decomposition of E 
[U,S,V] = svd(E);

W = [0 1 0;-1 0 0;0 0 1];

R_2_positive = U*W'*V';
R_2_negative = U*W*V';

%since there are two rotation matrices, for each of them there are two
%possible translation matrice.  [t]×= ±E12R

t_2_1_positive = E*(R_2_positive)';
t_2_2_positive = E'*(R_2_positive)';

t_2_1_negative = E*(R_2_negative)';
t_2_2_negative = E'*(R_2_negative)';

问题是对于从[t]×= ±E12R派生的矩阵t,我应该有一个3x1矩阵,但答案是3x3矩阵。

4sup72z8

4sup72z81#

在搜索之后,我算出了矩阵t,我必须这样做:

t = reshape(U(:, 3) / max(abs(U(:, 3))), [3, 1]);
P2_1(:, :, 1) = cat(2, U*W*V', t);
P2_2(:, :, 2) = cat(2, U*W*V', -t);
P2_3(:, :, 3) = cat(2, U*W'*V', t);
P2_4(:, :, 4) = cat(2, U*W'*V', -t);

相关问题