Calibrated camera get matched points for 3D recons

2019-07-21 08:41发布

问题:

I have previously asked the question "Use calibrated camera get matched points for 3D reconstruction", but the problem was not described clearly. So here I use a detail case with every step to show. Hope there is someone can help figure out where my mistake is.

At first I made 10 3D points with coordinates:

>> X = [0,0,0; 
       -10,0,0; 
       -15,0,0; 
       -13,3,0; 
         0,6,0; 
       -2,10,0; 
       -13,10,0; 
         0,13,0; 
       -4,13,0; 
       -8,17,0]

these points are on the same plane showing in this picture: http://oi59.tinypic.com/jjvh8w.jpg

My next step is to use the 3D-2D projection code to get the 2D coordinates. In this step, I used the MATLAB code from caltech calibration toolbox called "project_points.m". Also I used the OpenCV C++ code to verify the result and turned out the same. (I used cvProjectPoints2())

For the 1st projection, parameters are:

>> R = [0, 0.261799387, 0.261799387]
>> T = [0, 20, 100]
>> K = [12800, 0, 1850; 0, 12770, 1700; 0 0 1]

And no distortion

>> DisCoe = [0,0,0,0]

The rotation is just two rotations with pi/12. I then got the 1st view 2D coordinates:

>> Points1 = [1850, 4254; 
              686.5, 3871.7; 
              126.3, 3687.6; 
              255.2, 4116.5; 
              1653.9, 4987.6; 
              1288.6, 5391.0; 
              37.7, 4944.1; 
              1426.1, 5839.6; 
              960.0, 5669.1; 
              377.3, 5977.8]

For the 2nd view, I changed:

>> R = [0, -0.261799387, -0.261799387]
>> T = [0, -20, 100]

And then got the 2nd View 2D coordinates:

>> Points2 = [1850, -854; 
              625.4, -585.8; 
              -11.3, -446.3; 
              348.6, -117.7; 
              2046.1, -110.1; 
              1939.0, 442.9; 
              588.6, 776.9; 
              2273.9, 754.0; 
              1798.1, 875.7; 
              1446.2, 1501.8]

THEN will be the reconstruction steps, I have already built the ideal matched points(I guess so), next step is to calculate the Fundamental Matrix, using estimateFundamentalMatrix():

>> F = [-0.000000124206906,  0.000000155821234,  -0.001183448392236;
       -0.000000145592802,  -0.000000088749112,  0.000918286352329;  
        0.000872420357685,  -0.000233667041696,  0.999998470240927]

with known K, I used the matlab code below to calculate essential matrix and compute the R, t, finally 3D coordinates:

E = K'*F*K;
[u1,w1,v1] = svd(E);
t = (w1(1,1)+w1(2,2))/2;
w1_new = [t,0,0;0,t,0;0,0,0];
E_new = u1*w1_new*v1';
[u2,w2,v2] = svd(E_new);
W = [0,-1,0;1,0,0;0,0,1];
S = [0,0,-1];
P1 = K*eye(3,4);
R = u2*W'*v2';
t = u2*S;
P2 = K*[R t];
for i=1:size(Points1,1)
    A = [P1(3,:)*Poinst1(i,1)-P1(1,:);P1(3,:)*Points1(i,2)-P1(2,:);P2(3,:)*Points2(i,1)-P2(1,:);P2(3,:)*Points2(i,2)-P2(2,:)];
    [u3,w3,v3] = svd(A);
    dpt(i,:) = [v3(1,4) v3(2,4) v3(3,4)];
end

From this code I got the result as below:

>>X_result = [-0.00624167168027166  -0.0964921215725801 -0.475261364542900;
               0.0348079221692933   -0.0811757557821619 -0.478479857606225;
               0.0555763217997650   -0.0735028994611970 -0.480026199527202;
               0.0508767193762549   -0.0886557226954657 -0.473911682320574;
               0.00192300693541664  -0.121188713743347  -0.466462048338988;
               0.0150597271598557   -0.133665834494933  -0.460372995991565;
               0.0590515135110533   -0.115505488681438  -0.460357357303399;
               0.0110271144368152   -0.148447743355975  -0.455752218710129;
               0.0266380667320528   -0.141395768700202  -0.454774266762764;
               0.0470113238869852   -0.148215424398514  -0.445341461836899]

With showing these points in Geomagic, the result is "a little bit bending". But there positions seemed right. I don't know why this happened. Anybody have some idea? Please see the picture: http://oi59.tinypic.com/n6t63t.jpg

回答1:

It looks like numerical inaccuracies, maybe inside your function estimateFundamentalMatrix().

My second guess is that your estimateFundamentalMatrix() is not handling the planar case, which is a degenerate case for some algorithms (for the linear 8-points algo do not work well with planar scene for example).

The uncalibrated fundamental matrix estimation is ambiguous for planar scenes (2 solutions at least). See for example "Multiple View Geometry" by Hartley & Zisserman.