函数'cvtColor'中的OpenCV!_src.empty()错误 [英] OpenCV !_src.empty() in function 'cvtColor' error

查看:167
本文介绍了函数'cvtColor'中的OpenCV!_src.empty()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆