2

这是来自 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中,你能帮帮我吗?努力让它发挥作用

4

1 回答 1

1

我找到了找不到图像的解决方案

我变了

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

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

它奏效了

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

于 2015-11-08T12:11:12.703 回答