1

I have to reconstruct the 3D position of some visible features, which are visible on two images taken from a car. The photos have different positions and angles. I was able to derive the matrix K from the first image because the requirement of the project asked for the camera calibration matrix of that specific image.
For the 3D reconstruction, I have to follow these steps:

  1. Find the matching point, and estimate the fundamental matrix F.
  2. Since I don't have any information about the P2 (projection matrix of the second image), I have to use the Essential matrix to be able to retrieve the matrix R and T for the second camera.
  3. Executing triangulation and building the 3D position.
%% 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)';

The problem is for the matrices t which are derived from [t]×= ±E12R, I should have a 3x1 matrix but the answers are 3x3 matrices.

  • Welcome to Stack Overflow! We're lacking quite a few function and variable definitions, so we can't run your code. Please see [mcve] on what code is required on Stack Overflow. That said, this has (likely) to do with your implicit broadcasting. If `A*B` results in a 3x1 vector, `A.'*B` will might result in a 3x3 matrix, see [the documentation](https://mathworks.com/help/matlab/matlab_prog/compatible-array-sizes-for-basic-operations.html) – Adriaan Aug 22 '22 at 10:24
  • @Adriaan thanks for your comment. i tried the dot product but still is the same. about the lack of input data, I'm trying to add the .mat of my inputs but guess it is impossible to add them directly here. – Homeyra Mahmoudi Aug 22 '22 at 10:51
  • @Adriaan i added the Matric F and K1 which i guess is necessary for the calculation of E and other parameters. – Homeyra Mahmoudi Aug 22 '22 at 11:17
  • it could be better until coming to the translation matrix calculation to write out the E and t so we can be sure there is some mis-calculation steps. – Yunus Temurlenk Aug 23 '22 at 06:35

1 Answers1

0

after searching i figured out for matrix t i have to do such so:

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);