我在相机中拍摄了一些图像,并尝试使用opencv库调整其大小,但是我认为我无法读取图像,我不知道为什么。谢谢您的帮助。
我有一个python 3.8版本和更新的opencv库版本。我想的背景并不多。
import os,cv2
count=0
for file in os.listdir('E:\Projects\Python\Resixing images\Images'):
if file.endswith('.jpg'):
print(file)
img=cv2.imread(file)
img2=img.copy()
img2=cv2.resize(img2,(700,700))
name="resize"+str(count)+".jpg"
cv2.imwrite(name,img2)
count+=1
我收到一条错误消息
P_20191107_214848_SRES.jpg 追溯(最近一次通话): 第7行中的文件“ E:\ Projects \ Python \ Resixing images \ image changes res.py” img2 = img.copy() AttributeError:“ NoneType”对象没有属性“ copy” [完成于9.7秒]