相关疑难解决方法(0)

AttributeError:'module'对象没有属性'ORB'

当我运行我的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 …
Run Code Online (Sandbox Code Playgroud)

python opencv opencv3.0

19
推荐指数
1
解决办法
2万
查看次数

matplotlib:ImportError:无法导入名称'pyplot'

我使用pip安装了matplotlib lib,但是当我运行此代码时,它给了我这个错误:

shar@shar-Lenovo-G50-30 ~ $ python3 opencv.py
Traceback (most recent call last):
  File "opencv.py", line 3, in <module>
    from matplotlib import pyplot as plt
ImportError: cannot import name 'pyplot'
Run Code Online (Sandbox Code Playgroud)

我的代码是:

import numpy as np
import cv2
from matplotlib import 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 …
Run Code Online (Sandbox Code Playgroud)

python opencv matplotlib

2
推荐指数
1
解决办法
8267
查看次数

标签 统计

opencv ×2

python ×2

matplotlib ×1

opencv3.0 ×1