函数'cvtColor'中的OpenCV!_src.empty()错误 [英] OpenCV !_src.empty() in function 'cvtColor' error
问题描述
我正在尝试在python中进行基本的颜色转换,但是我似乎无法摆脱以下错误.我已经重新安装了python,opencv,并在python 3.4.3(最新版本)和python 2.7(在我的Mac上)上都尝试过.
I am trying to do a basic colour conversion in python however I can't seem to get past the below error. I have re-installed python, opencv and tried on both python 3.4.3 (latest) and python 2.7 (which is on my Mac).
我使用python的软件包管理器opencv-python安装了opencv.
I installed opencv using python's package manager opencv-python.
以下是失败的代码:
frame = cv2.imread('frames/frame%d.tiff' % count)
frame_HSV= cv2.cvtColor(frame,cv2.COLOR_RGB2HSV)
这是错误消息:
cv2.error: OpenCV(3.4.3) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
推荐答案
发生此错误是因为图像未正确加载.所以您对上一行cv2.imread
有疑问,我的建议是:
This error happened because the image didn't load properly . So you have problem with the previous line cv2.imread
my suggestion is :
-
检查图像是否在您指定的路径中
check if the images exist in the path you give
检查count变量是否具有有效数字
check the count variable if he have valid number
这篇关于函数'cvtColor'中的OpenCV!_src.empty()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!