gpt4 book ai didi

python - opencv-python 基本 ORB 特征检测在函数 cv::drawKeypoints 中给出错误 -215

转载 作者:太空宇宙 更新时间:2023-11-03 21:45:03 25 4
gpt4 key购买 nike

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

最佳答案

我找到了解决方案找不到图片

我变了

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

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

成功了

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

关于python - opencv-python 基本 ORB 特征检测在函数 cv::drawKeypoints 中给出错误 -215,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33589301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com