比如我们通过轮廓提取到一连串的坐标,和标签,如何才能将其直接变为图像分割的json格式呢,这样就不需要自己手动一个个去标注了。
然后是将轮廓变为json格式,直接上代码:
简略代码:
import json
zuobiao = [[100,200],[300,400],[500,600]]
def process_text_to_json(zuobiao):
location_data = []
location_data.append({"key1": zuobiao[0], "city": zuobiao[1], "description": zuobiao[2]})
location_data = {"location_data": location_data}
return json.dumps(location_data,indent=4)
x = process_text_to_json(zuobiao)
print(x)
完整代码:
import json
zuobiao = [[100,200],[300,400],[500,600]]
def process_text_to_json(zuobiao):
dict =