OpenCV Python代码中的detectAndComputer方法错误

2024-05-01 21:54:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在VS代码中使用python3.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)

我已经读到了关于早期版本openCV和更高版本的SIFT的变化,使得用户安装openCV contrib。我的错误不在于create,而在于detectAndComputer方法。这是错误:

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

Tags: path代码版本nonecreatecontribcv2jpg
2条回答

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

有一些关于这个过程和代码语法的详细信息here

应该是筛选、检测和计算不是筛选、检测和计算(右)

相关问题 更多 >