首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >AttributeError:“”module“”对象没有属性“”ORB“

AttributeError:“”module“”对象没有属性“”ORB“
EN

Stack Overflow用户
提问于 2015-07-26 03:58:40
回答 1查看 18.4K关注 0票数 20

当我运行python代码时

代码语言:javascript
复制
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()

我得到了这个错误:

代码语言:javascript
复制
AttributeError: 'module' object has no attribute 'ORB' 

我使用的是python3和opencv3

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-26 08:01:18

我还发现了这个。我检查了cv2模块的实际内容,发现是ORB_create()而不是ORB()

使用这条线

代码语言:javascript
复制
orb = cv2.ORB_create()

而不是orb = cv2.ORB(),它将会工作。

在Windows上的Python3.4、OpenCV 3上使用OpenCV测试数据集box.pngbox_in_scene.png进行了验证,结果如下。请注意,您必须将None outImg放在行img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10], flags=2) 中-请参阅另一个问题的my answer

票数 54
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31630559

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档