google-colaboratory - 如何使用 for 循环和 glob 进程将图像保存到文件夹中?
问题描述
for fil in glob.glob("Disgust Original/*.jpg"):
data = pyplot.imread(fil)
detector = MTCNN()
faces = detector.detect_faces(data)
if not os.path.exists('Result'):
os.makedirs('Result')
for i in range(len(faces)):
x1, y1, width, height = faces[i]['box']
x2, y2 = x1 + width, y1 + height
pyplot.subplot(1, len(faces), i+1)
pyplot.axis('off')
pyplot.imshow(data[y1:y2, x1:x2])
img = cv2.cvtColor(data[y1:y2, x1:x2], cv2.COLOR_BGR2GRAY)
outfile=("Final gray-"+(fil)+"-Final Result.jpg")
cv2.imwrite('Result/'+outfile,img)
print(outfile)
pyplot.show()
我想知道为什么循环后它没有保存图像,而是只显示它^^”非常感谢您的帮助
解决方案
推荐阅读
- kotlin - 如何使用执行错误检查的自定义设置器初始化属性?
- javascript - 在 chrome 浏览器中使用 indexedDB 时有大小限制吗?
- sql - 如何在 Oracle 中获得自然数字排序顺序?
- google-apps-script - 仅将当前工作表导出到 Excel 的功能,其中包含值和格式
- dns - 具有自定义域的无法访问的 gitlab 页面
- angular - 用户导航前的补丁
- excel - 如何根据相同的 CELL [EXCEL] 更改 CELL 的值
- java - 搜索手机上的所有文件和文件夹?
- sql - 如何在 SQL 中使用 PIVOT 将方法分配给特定参数?
- r - 如何在 R 中重命名具有相似名称和代码的变量?