python+opencv 讀取文件夾下的所有圖像並批量保存ROI

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章