简体   繁体   English

从基本矩阵构成,反之亦然

[英]Pose from Fundamental matrix and vice versa

I have computed the Fundamental Matrix between two cameras using opencv's findFundamentalMat . 我使用opencv的findFundamentalMat计算了两台摄像机之间的基本矩阵。 Then I plot the epipolar lines in the image. 然后我绘制图像中的极线。 And I get something like: 我得到类似的东西:

极线可以 Now, I tried to get the pose from that fundamental matrix, computing first the essential matrix and then using Hartley & Zissserman approach. 现在,我试图从基本矩阵中获得姿势,首先计算基本矩阵,然后使用Hartley和Zissserman方法。

K2=np.mat(self.calibration.getCameraMatrix(1))
K1=np.mat(self.calibration.getCameraMatrix(0))
E=K2.T*np.mat(F)*K1

赫兹

w,u,vt = cv2.SVDecomp(np.mat(E))   
if np.linalg.det(u) < 0:
    u *= -1.0
if np.linalg.det(vt) < 0:
    vt *= -1.0 
#Find R and T from Hartley & Zisserman
W=np.mat([[0,-1,0],[1,0,0],[0,0,1]],dtype=float)
R = np.mat(u) * W * np.mat(vt)
t = u[:,2] #u3 normalized.

In order to check everything until here was correct, I recompute E and F and plot the epipolar lines again. 为了检查一切,直到这里是正确的,我重新计算E和F并再次绘制极线。

S=np.mat([[0,-T[2],T[1]],[T[2],0,-T[0]],[-T[1],T[0],0]])
E=S*np.mat(R)
F=np.linalg.inv(K2).T*np.mat(E)*np.linalg.inv(K1)

But surprise, the lines have moved and they don't go through the points anymore. 但令人惊讶的是,线条已经移动,他们不再通过积分了。 Have I done something wrong? 我做错了什么吗?

epilines坏

It might be related with this question http://answers.opencv.org/question/18565/pose-estimation-produces-wrong-translation-vector/ , but they didn't provide a solution 它可能与这个问题有关http://answers.opencv.org/question/18565/pose-estimation-produces-wrong-translation-vector/ ,但他们没有提供解决方案

The matrices I get are: 我得到的矩阵是:

Original F=[[ -1.62627683e-07  -1.38840952e-05   8.03246936e-03]
 [  5.83844799e-06  -1.37528349e-06  -3.26617731e-03]
 [ -1.15902181e-02   1.23440336e-02   1.00000000e+00]]

E=[[-0.09648757 -8.23748182 -0.6192747 ]
 [ 3.46397143 -0.81596046  0.29628779]
 [-6.32856235 -0.03006961 -0.65380443]]

R=[[  9.99558381e-01  -2.72074658e-02   1.19497464e-02]
  [  3.50795548e-04   4.12906861e-01   9.10773189e-01]
  [ -2.97139627e-02  -9.10366782e-01   4.12734058e-01]]

T=[[-8.82445166e-02]
 [8.73204425e-01]
 [4.79298380e-01]]

Recomputed E=
[[-0.0261145  -0.99284189 -0.07613091]
 [ 0.47646462 -0.09337537  0.04214901]
 [-0.87284976 -0.01267909 -0.09080531]]

Recomputed F=
[[ -4.40154169e-08  -1.67341327e-06   9.85070691e-04]
 [  8.03070680e-07  -1.57382143e-07  -4.67389530e-04]
 [ -1.57927152e-03   1.47100268e-03   2.56606003e-01]]

The first F is defined up to scale, hence if you're going to compare the returned F and with the F matrix computed from E you need to normalize them to make sure both are at the same scale. 第一个F按比例定义,因此如果您要比较返回的F和从E计算的F矩阵,则需要将它们标准化以确保两者的比例相同。 Hence you need to normalize the second computed F. 因此,您需要规范化第二个计算F.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM