简体   繁体   English

OpenCV:基本矩阵分解

[英]OpenCV: Essential Matrix Decomposition

I am trying to extract Rotation matrix and Translation vector from the essential matrix. 我正在尝试从基本矩阵中提取“旋转矩阵”和“平移矢量”。

<pre><code>
SVD svd(E,SVD::MODIFY_A);
Mat svd_u = svd.u;
Mat svd_vt = svd.vt;
Mat svd_w = svd.w;

Matx33d W(0,-1,0,
          1,0,0,
          0,0,1);

Mat_<double> R = svd_u * Mat(W).t() * svd_vt; //or svd_u * Mat(W) * svd_vt; 
Mat_<double> t = svd_u.col(2); //or -svd_u.col(2)
</code></pre>

However, when I am using R and T (eg to obtain rectified images), the result does not seem to be right(black images or some obviously wrong outputs), even so I used different combination of possible R and T. 但是,当我使用R和T(例如,获取校正的图像)时,结果似乎并不正确(黑色图像或某些明显错误的输出),即使如此,我使用了可能的R和T的不同组合。

I suspected to E. According to the text books, my calculation is right if we have: 我怀疑是E。根据教科书,如果我们满足以下条件,我的计算是正确的:

E = U*diag(1, 1, 0)*Vt E = U * diag(1、1、0)* Vt

In my case svd.w which is supposed to be diag(1, 1, 0) [at least in term of a scale], is not so. 在我的情况下,svd.w至少应该是diag( 1,1,0 [至少就比例而言]不是。 Here is an example of my output: 这是我的输出示例:

svd.w = [21.47903827647813; svd.w = [21.47903827647813; 20.28555196246256; 20.28555196246256; 5.167099204708699e-010] 5.167099204708699e-010]

Also, two of the eigenvalues of E should be equal and the third one should be zero. 同样,E的两个特征值应相等,而第三个特征值应为零。 In the same case the result is: 在相同情况下,结果为:

eigenvalues of E = 0.0000 + 0.0000i, 0.3143 +20.8610i, 0.3143 -20.8610i E的特征值= 0.0000 + 0.0000i,0.3143 + 20.8610i,0.3143 -20.8610i

As you see, two of them are complex conjugates. 如您所见,其中两个是复共轭。

Now, the questions are: 现在,问题是:

  • Is the decomposition of E and calculation of R and T done in a right way? E的分解以及R和T的计算是否正确?
  • If the calculation is right, why the internal rules of essential matrix are not satisfied by the results? 如果计算正确,为什么结果不满足基本矩阵的内部规则?
  • If everything about E, R, and T is fine, why the rectified images obtained by them are not correct? 如果关于E,R和T的一切都很好,为什么它们获得的校正图像不正确?

I get E from fundamental matrix, which I suppose to be right. 我从基本矩阵中得到E,我认为是正确的。 I draw epipolar lines on both the left and right images and they all pass through the related points (for all the 16 points used to calculate the fundamental matrix). 我在左图和右图上都画了极线,它们都穿过相关点(用于计算基本矩阵的所有16个点)。

Any help would be appreciated. 任何帮助,将不胜感激。 Thanks! 谢谢!

I see two issues. 我看到两个问题。

First, discounting the negligible value of the third diagonal term, your E is about 6% off the ideal one: err_percent = (21.48 - 20.29) / 20.29 * 100 . 首先,将第三个对角线项的值忽略不计,您的E大约比理想值小6%:err_percent =(21.48-20.29)/ 20.29 * 100。 Sounds small, but translated in terms of pixel error it may be an altogether larger amount. 听起来很小,但换算成像素误差可能会更大。

So I'd start by replacing E with the ideal one after SVD decomposition: Er = U * diag(1,1,0) * Vt. 因此,我将在SVD分解后以理想的E替换E:Er = U * diag(1,1,0)* Vt。

Second, the textbook decomposition admits 4 solutions, only one of which is physically plausible (ie with 3D points in front of the camera). 其次,教科书分解承认4种解决方案,其中只有一种在物理上是合理的(即,在镜头前有3D点)。 You may be hitting one of non-physical ones. 您可能遇到了非身体性疾病之一。 See http://en.wikipedia.org/wiki/Essential_matrix#Determining_R_and_t_from_E . 请参阅http://en.wikipedia.org/wiki/Essential_matrix#Determining_R_and_t_from_E

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

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