【发布时间】:2018-10-23 10:57:16
【问题描述】:
我正在尝试在我的 opencv 代码中编写图像,如果我在没有目录的情况下编写这很好。但是当我尝试写入目录时,它运行但不写入目录。
for i in xrange(3):
path = 'resultImages/result'
print os.path.join(path,str(i),'.png')
cv.imwrite(os.path.join(path,str(i),'.png'),images[i*3+2])
这里有什么问题吗?
我推荐了OpenCV - Saving images to a particular folder of choice,但没有任何帮助。
【问题讨论】:
-
如果resultImages在自动保存图片的目录中,尝试把'/'放在resultImages前面('/resultImages/result')
-
确保你的 dirpath 存在。
-
@Silencer: 目录路径在那里,也尝试了
('/resultImages/result')但没有运气 -
您是否尝试使用完整路径? 'D:/..../result'
-
尝试使用
os.path.exists(path)来检查路径是否存在...还有os.path.join(path,str(i),'.png')这应该给出类似resultImages/result/0/.png的内容,它应该是类似os.path.join(path,str(i)+'.png')的内容