【发布时间】: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