Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';模块';对象没有属性';ORB';_Python_Opencv_Opencv3.0 - Fatal编程技术网

Python 属性错误:';模块';对象没有属性';ORB';

Python 属性错误:';模块';对象没有属性';ORB';,python,opencv,opencv3.0,Python,Opencv,Opencv3.0,当我运行python代码时 import numpy as np import cv2 import matplotlib.pyplot as plt img1 = cv2.imread('/home/shar/home.jpg',0) # queryImage img2 = cv2.imread('/home/shar/home2.jpg',0) # trainImage # Initiate SIFT detector orb = cv2.ORB() # find t

当我运行python代码时

import numpy as np
import cv2
import matplotlib.pyplot as plt

img1 = cv2.imread('/home/shar/home.jpg',0)          # queryImage
img2 = cv2.imread('/home/shar/home2.jpg',0) # trainImage

# Initiate SIFT detector
orb = cv2.ORB()

# find the keypoints and descriptors with SIFT
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)
# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

# Match descriptors.
matches = bf.match(des1,des2)

# Sort them in the order of their distance.
matches = sorted(matches, key = lambda x:x.distance)

# Draw first 10 matches.
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10], flags=2)

plt.imshow(img3),plt.show()
我得到这个错误:

AttributeError: 'module' object has no attribute 'ORB' 

我正在使用python3和opencv3,我也发现了这一点。我检查了
cv2
模块的实际内容,发现
ORB\u create()
而不是
ORB()

用电话

orb = cv2.ORB_create()
而不是
orb=cv2.orb()
,它会工作

使用OpenCV测试数据集
box.png
box\u in_scene.png
在Python 3.4、Windows上的OpenCV 3上进行验证,结果如下注意对于
outImg
,您必须在
img3=cv2行中输入
None
。drawMatches(img1,kp1,img2,kp2,matches[:10],flags=2)
另请参见您的其他问题


是哪一个,
create\u ORB()
还是
ORB\u create()
?您在文本中使用了一个,但在代码中使用了另一个。对不起,输入错误@berak善意地编辑了一个实例,但错过了另一个。当我在这里输入时已经很晚了,这是我唯一的借口:)都更正为
ORB_create()
我可以实时匹配该功能吗?