slice indices must be integers or None or have an __index__ method

1、问题描述

今天使用opencv的imwrite方法的时候,提示了如下错误
在这里插入图片描述

2、解决方案

原来是我的cv.imwrite里面写文件名的时候忘记给图片加后缀名了。
cv.imwrite('/home/barry/PycharmProject/LL/Image/img_result',img)
改成:
cv.imwrite('/home/barry/PycharmProject/LL/Image/img_result.jpg',img)

就可以了

猜你喜欢

转载自blog.csdn.net/xdg15294969271/article/details/121520794