【问题标题】:Python: plotting sift points returns points off the picturesPython:绘制筛选点从图片中返回点
【发布时间】:2016-04-24 15:08:40
【问题描述】:

我正在使用 sift 实现以及“使用 Python 编程计算机视觉”中的代码。

在 vision.py 中使用 plotMatches 函数(相当于书中的 plot_matches() 函数)时,一些绘制的点甚至不在图像上:

如您所见,大多数点都不在任何一张图片上。

这可能是我必须对我的 plotMatches() 函数进行更改的结果:

        for i, m in enumerate(matchscores):
            if i > 0:
                 lab.plot([locs1[i][1], locs2[i][1] + cols1],
                 [locs1[i][0], locs2[i][0]], 'c')

原代码:

        for i, m in enumerate(matchscores):
            if i > 0:
                lab.plot([locs1[i][1], locs2[m][1] + cols1],
                [locs1[i][0], locs2[m][0]], 'c')

会抛出以下错误:

    Traceback (most recent call last):
    File "/home/peter-brown/AI/Markus/ImageRecognition.py", line 37,     in <module>
     sch.plotMatches(image, image2, l1, l2, matches, show_below=False)
     File "/home/peter-brown/AI/Markus/vision.py", line 199, in    plotMatches
     lab.plot([locs1[i][1], locs2[m][1] + cols1],
     IndexError: index 1 is out of bounds for axis 0 with size 1

通过更改代码中使用的任何“m”,程序可以运行,但会输出不正确。

为什么输出与图像不对应,如何更改 plotMatches 函数才能工作?

【问题讨论】:

    标签: python computer-vision sift


    【解决方案1】:

    matplotlib 中,xy 坐标被翻转。从您的图像看来,您将所有x 坐标解释为y 坐标,反之亦然。从您的功能来看,这是一个简单的更改:

    for i, m in enumerate(matchscores):
            if i > 0:
                 lab.plot([locs1[i][0], locs2[i][0] + cols1],
                 [locs1[i][1], locs2[i][1]], 'c')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-21
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      相关资源
      最近更新 更多