【问题标题】:Error around detectAndComputer method in openCV python codeopenCV python代码中detectAndComputer方法周围的错误
【发布时间】:2019-06-26 20:57:10
【问题描述】:

我在 VS Code 中使用 python 3.6.3,opencv-contrib-python-3.3.1.11。我正在尝试运行以下代码:

import cv2
image1 = cv2.imread('PATH.image1.jpg',0)
image2 = cv2.imread('PATH.image2.jpg',0)

sift = cv2.xfeatures2d.SIFT_create()

kp1, des1 = sift.detectAndComputer(image1,None)
kp2, desc2 = sift.detectAndComputer(image2,None)

我已经阅读了有关 SIFT 对 openCV 早期版本的更改以及使用户安装 opencv contrib 的更高版本。我的错误不是围绕 create 而是围绕 detectAndComputer 方法。这是错误:

Exception has occurred: AttributeError
'cv2.xfeatures2d_SIFT' object has no attribute 'detectAndComputer'

【问题讨论】:

    标签: python opencv sift


    【解决方案1】:

    正确的调用是kp1, des1 = sift.detectAndCompute(image1,None) 而不是detectAndComputer

    这个过程和代码语法有一些细节here

    【讨论】:

    • 谢谢!视力不好。
    【解决方案2】:

    应该是 sift.detectAndCompute 而不是 sift.detectAndCompute(r)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-11
      • 1970-01-01
      • 2018-06-17
      • 1970-01-01
      • 1970-01-01
      • 2016-09-19
      相关资源
      最近更新 更多