Python 官方文档:入门教程 => 点击学习
调用OpenCV模块的cvtColor处理图片: img_rgb = r'G:\手机照片2022\IMG_122440.jpg'img_gray = cv2.cvtColor(img_rgb, cv2
调用OpenCV模块的cvtColor
处理图片:
img_rgb = r'G:\手机照片2022\IMG_122440.jpg'img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
发生了报错,报错内容为:
[ WARN:0@0.011] global D:\a\opencv-python\opencv-Python\opencv\modules\imGCodecs\src\loadsave.cpp (239) cv::findDecoder imread_('G:\手机照片2022\IMG_122440.jpg'): can't open/read file: check file path/integrityTraceback (most recent call last): File "G:\Test39.py", line 26, in control_to_sketch(image, to_image) File "G:Test39.py", line 10, in control_to_sketch img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
报错原因:第1行的警告其实有给出了答案,就是路径问题
,不能打开或读取文件,需要改一下路径(can't open/read file: check file path/integrity
)。
解决方法:
img_rgb = r'G:\mobile_photo_2022\IMG_122440.jpg'img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
来源地址:https://blog.csdn.net/qq_45476428/article/details/127287685
--结束END--
本文标题: cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182
本文链接: https://lsjlt.com/news/389056.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0