本文主要是介绍error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor‘ | 简记,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
运行代码如下:
def getRes(path,threshold=100):image = cv2.imread(path)gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
报错如下:
Traceback (most recent call last):File "iqa.py", line 53, in <module>getRes(path, threshold)File "iqa.py", line 13, in getResgray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.5.1) /tmp/pip-req-build-1syr35c1/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
分析原因如下:
- 传入的图片路径错误,图片找不到 ,导致图片读取失败;
这篇关于error: (-215:Assertion failed) !_src.empty() in function ‘cvtColor‘ | 简记的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!