# --把4点标注的json文件转化为(x_c,y_c,h,w,theta)的yolo txt 格式
import json
import os
import math
import random
my_class = ["bottle"]
def convert(image_id):
in_file = 'annotations/%s.json' % image_id
out_file = open('labels/%s.txt' % image_id, 'w')
with open(in_file) as f_obj:
label = json.load(f_obj)
for bbox in label["shapes"]:
vertices = bbox["points"] # 顶点列表
a, b, c, d = vertices
x_c = (a[0]+b[0]+c[0]+d[0])/4
y_c = (a[1] + b[1] + c[1] + d[1]) /
json类型文件转为yolo可识别的txt文件
最新推荐文章于 2024-04-20 20:00:14 发布