import os
import cv2
for i in sorted(os.listdir("./images_pad")):
id = os.path.splitext(i)[0]
with open("./labels_pad/" + id + ".txt", "r") as f:
for line in f:
#print(line)
x1 = eval(line.split(" ")[4])
y1 = eval(line.split(" ")[5])
x2 = eval(line.split(" ")[6])
y2 = eval(line.split(" ")[7])
start_point = (int(x1), int(y1))
end_point = (int(x2), int(y2))
color = (255, 0, 0)
thickness = 2
image_path = "./images_pad/" + id + ".jpeg"
img_raw = cv2.imread(image_path)
# Using cv2.rectangle() method
# Draw a rectangle with blue line borders of thickness of 2 px
image = cv2.rectangle(img_raw, start_point, end_point, color, thickness)
infer_image = "./images_infer/" + id + ".jpeg"
print(infer_image)
cv2.imwrite(infer_image , image)