所以,我写了一个小程序来克隆30k +图像的掩码。每个图像和掩模样本都转换为jpeg格式。但是,当我尝试启动程序时,它会创建一些掩码,然后停止,抛出标题中写入的错误。很奇怪OpenCV无法创建jpeg图像,因为它是默认格式。 问题是:如何让OpenCV实际保存那些新创建的掩码? 这是代码:
folders = ["162", "204", "260", "1093", "3297", "5020", "10066", "10870", "10917", "11160", "11331", "17218", "19106", "19306", "19388"]
for folder in folders:
print(folder)
names = os.listdir(folder)
os.chdir("%s/masks"%folder)
image = cv2.imread("%s.jpeg"%folder)
for name in names:
print(name)
cv2.imwrite(img=image, filename=name)