python+opencv 读取文件夹下的所有图像并批量保存ROI的方法
时间:2021-02-19 15:20:21|栏目:Python代码|点击: 次
如下所示:
import cv2 import os import numpy as np root_path = "I:/Images/2017_08_03/" dir = root_path+"images"+"/" count = 0 for 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使用functools模块中的partial函数生成偏函数
栏 目:Python代码
下一篇:如何导出python安装的所有模块名称和版本号到文件中
本文标题:python+opencv 读取文件夹下的所有图像并批量保存ROI的方法
本文地址:http://www.codeinn.net/misctech/66031.html






