【问题标题】:Why is findHomography returning bad result?为什么 findHomography 返回不好的结果?
【发布时间】:2014-10-15 12:40:00
【问题描述】:

我让用户在两张大小不同的图像上选择 5 个点(也许这就是问题所在)。 当用户在任何图像上选择一个点时,我将向 Point2f 推送一个专用于该特定图像的向量。

所以在一个实例中,我有以下数据:

1. Image 2 at x: 607, and y: 286
2. Image 2 at x: 750, and y: 367
3. Image 2 at x: 527, and y: 353
4. Image 2 at x: 752, and y: 469
5. Image 2 at x: 584, and y: 482

--

1. Image 1 at x: 301, and y: 343
2. Image 1 at x: 440, and y: 328
3. Image 1 at x: 275, and y: 472
4. Image 1 at x: 478, and y: 457
5. Image 1 at x: 389, and y: 597

但是findHomohraphy 返回

[0, 0, 0;

 0, 0, 0;

 0, 0, 0]

这就是我的函数在获得 2 个 4 个点的向量后所做的事情。

Mat tranform( std::vector<cv::Point2f> src, std::vector<cv::Point2f> dst) {
     transMatrix = findHomography(src, dst, CV_RANSAC);
     std::cout << transMatrix << std::endl;
     return transMatrix;
}

我还尝试将 findHomohraphy 的方法参数从 0 更改为 CV_RANSAC

我正在进一步调试,但在打印Point2f 向量时遇到问题。也许我没有正确分配它

这是我目前在图像窗口回调函数中所做的。

imgOnePoints.assign(imgOneIndex, Point2f(x,y));

【问题讨论】:

  • 我认为找不到任何相似之处。
  • 我可能没有正确分配向量
  • 寻找单应性的一般建议;更多点=更好。尤其是 Ransac,因为这允许忽略异常值。一个零矩阵结果意味着它无法找到单应性(并不总是意味着没有一个ofcource)
  • 是的,我同意。我之前尝试过6-7分,但在转换它时仍然不友好。我在所需的方向图片上挑选了一些奇怪的点。如果您有兴趣了解我的意思,我会通过电子邮件发送给您。

标签: c++ opencv perspectivecamera


【解决方案1】:

原来我真的没有正确分配向量

我通过使用push_back 实现分配来修复它

imgOnePoints.push_back(Point2f(x,y));

现在我得到以下结果

[9.160730442076495, -1.849442562331516, -180.7111392985398;
  4.977742556341154, 2.013216209765684, -1267.475935610038;
  0.007750660030394876, -0.0003148605099947704, 0.9999999999999999]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-23
    • 1970-01-01
    • 1970-01-01
    • 2012-07-28
    • 2013-03-10
    相关资源
    最近更新 更多