首页 > 编程 > Python > 正文

python+opencv 读取文件夹下的所有图像并批量保存ROI的方法

2019-11-25 13:30:32
字体:
来源:转载
供稿:网友

如下所示:

import cv2import os import numpy as np root_path = "I:/Images/2017_08_03/"dir = root_path+"images"+"/"count = 0for root,dir,files in os.walk(dir): for file in files:  srcImg = cv2.imread(root_path+"images"+"/"+str(file))  roiImg = srcImg[36:521, 180:745]  cv2.imwrite(root_path+"Image"+"/"+str(file),roiImg)  count +=1  if count%400==0:   print count

以上这篇python+opencv 读取文件夹下的所有图像并批量保存ROI的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表