c++ - undistortPoints,findEssentialMat,recoverPose : What is the relation between their arguments?

标签 c++ opencv image-processing camera-calibration 3d-reconstruction

为了更广泛的受众,我在这里重新发布了我在 answers.opencv.org 上提出的问题

TL;DR:传递给 undistortPointsfindEssentialMatrecoverPose 的参数之间应该保持什么关系?

我的程序中有如下代码,Kdist_coefficients 是相机内在函数,imgpts. 匹配来自 2 个图像的特征点.

     Mat mask; // inlier mask
     undistortPoints(imgpts1, imgpts1, K, dist_coefficients, noArray(), K);
     undistortPoints(imgpts2, imgpts2, K, dist_coefficients, noArray(), K);

     Mat E = findEssentialMat(imgpts1, imgpts2, 1, Point2d(0,0), RANSAC, 0.999, 3, mask);
     correctMatches(E, imgpts1, imgpts2, imgpts1, imgpts2);
     recoverPose(E, imgpts1, imgpts2, R, t, 1.0, Point2d(0,0), mask);

在找到基本矩阵之前,我undistort Points。该文档指出可以将新的相机矩阵作为最后一个参数传递。省略时,点位于标准化 坐标中(介于 -1 和 1 之间)。在那种情况下,我希望我将 1 作为焦距,将 (0,0) 作为主点传递给 findEssentialMat,因为这些点已标准化。所以我认为这是方式:

  1. 可能性1(归一化坐标)

     Mat mask; // inlier mask
     undistortPoints(imgpts1, imgpts1, K, dist_coefficients);
     undistortPoints(imgpts2, imgpts2, K, dist_coefficients);
     Mat E = findEssentialMat(imgpts1, imgpts2, 1.0, Point2d(0,0), RANSAC, 0.999, 3, mask);
     correctMatches(E, imgpts1, imgpts2, imgpts1, imgpts2);
     recoverPose(E, imgpts1, imgpts2, R, t, 1.0, Point2d(0,0), mask);
    
  2. 可能性2(不归一化坐标)

     Mat mask; // inlier mask
     undistortPoints(imgpts1, imgpts1, K, dist_coefficients, noArray(), K);
     undistortPoints(imgpts2, imgpts2, K, dist_coefficients, noArray(), K);
     double focal = K.at<double>(0,0);
     Point2d principalPoint(K.at<double>(0,2), K.at<double>(1,2));
     Mat E = findEssentialMat(imgpts1, imgpts2, focal, principalPoint, RANSAC, 0.999, 3, mask);
     correctMatches(E, imgpts1, imgpts2, imgpts1, imgpts2);
     recoverPose(E, imgpts1, imgpts2, R, t, focal, principalPoint, mask);  
    

但是,我发现,只有当我告诉 undistortPoints 旧相机矩阵仍然有效(我想在那种情况下只有失真被移除)并将参数传递给findEssentialMat 就好像这些点被归一化了,但事实并非如此。

这是错误、文档不足还是用户错误?

更新

可能是 correctedMatches 应该用(非标准化的)图像/像素坐标和基本矩阵调用,而不是 E,这可能是我计算中的另一个错误。可以通过F = K^-T * E * K^-1

得到

最佳答案

事实证明,我的数据似乎已关闭。通过使用手动标记的对应关系,我确定可能性 12 确实是正确的,正如人们所期望的那样。

关于c++ - undistortPoints,findEssentialMat,recoverPose : What is the relation between their arguments?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31290414/

相关文章:

C++ 数组下标运算符模板

c++ - 使用类时,计时器似乎运行得更快。在 C 版本中,它按预期工作

c++ - 丢失指针值

python - 使用 python 和 opencv 保存视频时出错

python - 在 python + openCV 中使用网络摄像头的问题

OpenCV 使用摄像头检测电视屏幕

c++ - C++程序员应该知道的著名设计模式

opencv - 如何检查获得的单应矩阵是否良好?

php - imagecreatefromstring() 用于 .bmp 文件

python - 使用opencv的几何均值滤波器