我一直在尝试计算2张图片中的功能,然后将这些功能传回CameraParams.R
,但没有运气。功能已成功计算和匹配,但问题是将它们传递回R & t
。
我知道你必须分解Homography
才能实现这一点,我已经用这样的方式完成了这个:https://github.com/syilma/homography-decomp,但我真的做得对吗?
现在我只是使用:
匹配
vector< vector<DMatch> > matches;
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create(algorithmName);
matcher->knnMatch( descriptors_1, descriptors_2, matches, 50 );
vector< DMatch > good_matches; // Storing good matches here
我注意到good_matches
没有在任何地方使用过。所以我想我的问题是,如何将good_matches
传回cameras.R/t
?
提取Homography:
Mat K;
cameras[img_idx].K().convertTo(K, CV_32F);
findHomography -> decomposeHomography(H, K, outputR,outputT,noarray()).
然后利用上面的库,我传递R
&amp;的值。 t
但回答是在4种可能的结果中没有发现单应性。
我在正确的道路上吗?看起来像decomposeHomography是一个3D解决方案,但是,findHomography是2D?
绝对目标:
根据图像中的功能优化CameraParam.R/t
。
为什么呢?因为我正在从设备旋转矩阵传递.R
,但旋转稍微不准确。在我之前的问题上查看有关它的更多信息:Refining Camera parameters and calculating errors - OpenCV
答案 0 :(得分:3)
如果您使用计算出的R进行图像拼接,则无需使用分解单应性。整个拼接管道假定为零翻译。因此,它仅为旋转情况提供了完美的输出,并且在摄像机姿势中引入了平移,引入了轻微的误差。如果你从单应性中研究R的opencv计算,它假定0翻译。
Mat R = K_from.inv() * pairwise_matches[pair_idx].H.inv() * K_to;
cameras[edge.to].R = cameras[edge.from].R * R;
您可以在motion_estimators.cpp - &gt; calcRotation函数中找到源代码。 使用好的匹配来计算R. goodmatches的问题实际上用于计算单应矩阵,使用 findhomography 函数
所以整个过程就像
查找匹配项(如您所述)
使用 findhomography 从这些匹配中查找单应矩阵 功能