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_
labelme标注数据某个标签类别切图
最新推荐文章于 2023-04-04 16:18:45 发布