undistortPoints,findEssentialMat,recoverPose:它们的参数之间是什么关系? [英] undistortPoints, findEssentialMat, recoverPose: What is the relation between their arguments?

查看:604
本文介绍了undistortPoints,findEssentialMat,recoverPose:它们的参数之间是什么关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了希望有更多的读者,我在这里重新发布了我在

In the hope for a broader audience, I repost my question here which I asked on answers.opencv.org as well.

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

TL;DR: What relation should hold between the arguments passed to undistortPoints, findEssentialMat and recoverPose?

我的程序中有类似以下的代码,其中Kdist_coefficients是相机内在函数,并且imgpts.是来自2张图像的匹配特征点.

I have code like the following in my program, with K and dist_coefficients being camera intrinsics and imgpts. matching feature points from 2 images.

     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);

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

I undistort the Points before finding the essential matrix. The doc states that one can pass the new camera matrix as the last argument. When omitted, points are in normalized coordinates (between -1 and 1). In that case, I would expect that I pass 1 for the focal length and (0,0) for the principal point to findEssentialMat, as the points are normalized. So I would think this to be the way:

  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 (不对坐标进行标准化)

  • Possibility 2 (do not normalize coordinates)

     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时,我才能得到合理的结果.这些点已归一化,但不是.

    However, I have found, that I only get reasonable results when I tell undistortPoints that the old camera matrix shall still be valid (I guess in that case only distortion is removed) and pass arguments to findEssentialMat as if the points were normalized, which they are not.

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

    Is this a bug, insufficient documentation or user error?

    更新

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

    It might be that correctedMatches should be called with (non-normalised) image/pixel coordinates and the Fundamental Matrix, not E, this may be another mistake in my computation. It can be obtained by F = K^-T * E * K^-1

    推荐答案

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

    As it turns out, my data seemingly is off. By using manually labelled correspondences I determined that Possibility 1 and 2 are indeed the correct ones, as one would expect.

    这篇关于undistortPoints,findEssentialMat,recoverPose:它们的参数之间是什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆