【发布时间】:2016-05-11 16:51:58
【问题描述】:
我目前有立体相机设置。我已经校准了两个摄像头,并拥有两个摄像头K1 和K2 的内在矩阵。
K1 = [2297.311, 0, 319.498;
0, 2297.313, 239.499;
0, 0, 1];
K2 = [2297.304, 0, 319.508;
0, 2297.301, 239.514;
0, 0, 1];
我还使用来自 OpenCV 的 findFundamentalMat() 确定了两个相机之间的基本矩阵 F。我已经使用一对对应点 x1 和 x2(在像素坐标中)测试了对极约束,它非常接近 0。
F = [5.672563368940768e-10, 6.265600996978877e-06, -0.00150188302445251;
6.766518121363063e-06, 4.758206104804563e-08, 0.05516598334827842;
-0.001627120880791009, -0.05934224611334332, 1];
x1 = 133,75
x2 = 124.661,67.6607
transpose(x2)*F*x1 = -0.0020
从F 我能够以E = K2'*F*K1 获得基本矩阵E。我使用 MATLAB SVD 函数分解 E 以获得 K2 相对于 K1 的 4 种旋转和平移可能性。
E = transpose(K2)*F*K1;
svd(E);
[U,S,V] = svd(E);
diag_110 = [1 0 0; 0 1 0; 0 0 0];
newE = U*diag_110*transpose(V);
[U,S,V] = svd(newE); //Perform second decompose to get S=diag(1,1,0)
W = [0 -1 0; 1 0 0; 0 0 1];
R1 = U*W*transpose(V);
R2 = U*transpose(W)*transpose(V);
t1 = U(:,3); //norm = 1
t2 = -U(:,3); //norm = 1
假设K1 用作我们进行所有测量的坐标系。因此,K1 的中心位于C1 = (0,0,0)。有了这个,应该可以应用正确的旋转R和平移t,这样C2 = R*(0,0,0)+t(即K2的中心是相对于K1的中心测量的)
现在假设使用我对应的对 x1 和 x2。如果我知道我的两个相机中每个像素的长度,并且因为我知道内在矩阵的焦距,我应该能够为两个相机确定两个向量v1 和v2,它们在所见的同一点相交下面。
pixel_length = 7.4e-6; //in meters
focal_length = 17e-3; //in meters
dx1 = (133-319.5)*pixel_length; //x-distance from principal point of 640*480 image
dy1 = (75-239.5) *pixel_length; //y-distance from principal point of 640*480 image
v1 = [dx1 dy1 focal_length] - (0,0,0); //vector found using camera center and corresponding image point on the image plane
dx2 = (124.661-319.5)*pixel_length; //same idea
dy2 = (67.6607-239.5)*pixel_length; //same idea
v2 = R * ( [dx2 dy2 focal_length] - (0,0,0) ) + t; //apply R and t to measure v2 with respect to K1 frame
有了这个向量并且知道了参数形式的线方程,我们就可以将两条线等同起来进行三角剖分,并通过 MATLAB 中的左手除法函数求解两个标量 s 和 t 以求解方程组.
C1 + s*v1 = C2 + t*v2
C1-C2 = tranpose([v2 v1])*transpose([s t]) //solve Ax = B form system to find s and t
确定s 和t 后,我们可以通过插入直线方程找到三角点。但是,我的过程并不成功,因为我找不到单个 R 和 t 解决方案,其中点位于两个摄像头的前面并且两个摄像头都指向前方。
我的管道或思维过程有问题吗?是否有可能获得每个单独的像素射线?
【问题讨论】:
标签: matlab opencv matlab-cvst triangulation stereo-3d