18 lines
791 B
Python
18 lines
791 B
Python
import os
|
|
import cv2
|
|
root_path = "/data/Hatcher/con/8227/"
|
|
result_path = "/data/Hatcher/con/result/"
|
|
site = [[20,20,110,103],[111,20 , 225,103],[264,20 , 396,103],[416,20 , 550,103],[552,20 , 690,103],[720,20 , 850,103],[872,20 , 1000,103]]
|
|
if not os.path.exists(result_path):
|
|
os.mkdir(result_path)
|
|
file_list = os.listdir(root_path)
|
|
num = 0
|
|
for file_path in file_list:
|
|
image_list = os.listdir(os.path.join(root_path,file_path))
|
|
for image_path in image_list:
|
|
print(image_path)
|
|
img = cv2.imread(os.path.join(os.path.join(root_path,file_path),image_path))
|
|
for site_1 in site:
|
|
Img = img.copy()[site_1[1]:site_1[3], site_1[0]:site_1[2], :]
|
|
cv2.imwrite(os.path.join(result_path,"{}.jpg".format(str(num).zfill(4))),Img)
|
|
num+=1 |