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

来源:互联网 发布:网络攻防渗透 编辑:程序博客网 时间:2024/05/22 02:00
import cv2import osimport numpy as nproot_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

阅读全文
0 0
原创粉丝点击