import glob
import json
import os
import cv2
from IOU import CaculateIOU
# json_list=glob.glob(r'D:\Personal\Desktop\res\*.json')
def cut_img(json_path,img_name,img_dir):
json_result = json.load(open(json_path, 'r', encoding='utf-8'))
annotations_result = json_result["shapes"]
question_coord_list,other_coord_list=[],[]
count = 0
for i, each in enumerate(annotations_result):
label_name = each["label"]
type = each["shape_type"]
coord = each["points"]
labelme_name = label_name.split("_")[0]
if labelme_name in["sub","question"] and type=="rectangle":
each_coord = []
each_coord.extend(coord[0])
each_coord.extend(coord[1])
each_coord=list(map(int,each_coord))
img=cv2.imread(os.path.join(img_