opencv-python基本ORB特征检测在函数cv :: drawKeypoints

时间:2015-11-08 00:08:11

标签: python opencv orb

这是opencv-python文档的基本代码:

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

img = cv2.imread('simple.jpg',0)

# Initiate STAR detector
orb = cv2.ORB()

# find the keypoints with ORB
kp = orb.detect(img,None)

# compute the descriptors with ORB
kp, des = orb.compute(img, kp)

# draw only keypoints location,not size and orientation
img2 = cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)
plt.imshow(img2),plt.show()

它给了我这个错误:

Traceback (most recent call last):
File "C:\Python27\test.py", line 18, in <module>
img2 = cv2.drawKeypoints(img,kp,color=(0,255,0), flags=0)
error: ..\..\..\..\opencv\modules\features2d\src\draw.cpp:115: error:       (-215) !outImage.empty() in function cv::drawKeypoints

我不得不提到这个错误发生在opencv-PYTHON中,你能帮帮我吗?真正努力使其发挥作用

1 个答案:

答案 0 :(得分:1)

我找到了解决方案 它无法找到图像

我改变了

img = cv2.imread('simple.jpg',0)

img = cv2.imread('c:\\python27\\sample.jpg', cv2.IMREAD_GRAYSCALE)

并且有效

请注意,我用于样本图像的图像是我自己的灰度图像之一。