import cv2
import glob
path = "/box"
save_path = "/box_cls/"
files = glob.glob(path+'/*.box')
for file in files:
filename = file.split('/')[-1]
img = cv2.imread(img_path+"/"+filename[:len(filename)-3]+"tif")
H,W = img.shape[:2]
with open(file) as f:
for line in f.readlines():
x, y, h, w = [int(x) for x in line.split('\t')[:4]]
x, y = x, H - y
cv2.rectangle(img, (x, y), (x + h, y - w), (50, 200, 50), 5)
cv2.imwrite(save_path+"/"+filename+".jpg",img)
save_path = "/box_cls/"
files = glob.glob(path+'/*.box')
for file in files:
filename = file.split('/')[-1]
img = cv2.imread(img_path+"/"+filename[:len(filename)-3]+"tif")
H,W = img.shape[:2]
with open(file) as f:
for line in f.readlines():
x, y, h, w = [int(x) for x in line.split('\t')[:4]]
x, y = x, H - y
cv2.rectangle(img, (x, y), (x + h, y - w), (50, 200, 50), 5)
cv2.imwrite(save_path+"/"+filename+".jpg",img)