python读取json格式的标注
方法
https://blog.csdn.net/weixin_68789096/article/details/136698639
import json import cv2 import matplotlib.pyplot as plt import numpy as np path="./dom1/dom_DOM.json" with open(path) as read_file: data = json.load(read_file) shapes=data["shapes"] num=len(shapes) print(num) print(shapes) gray = cv2.imread('./dom1/dom_DOM.jpg', cv2.IMREAD_GRAYSCALE) img_color = cv2.cvtColor(gray, cv2.COLOR_GRAY2RGB) for s in shapes: segment=s["points"] cv2.line(img_color, (int(segment[0][0]), int(segment[0][1])), (int(segment[1][0]), int(segment[1][1])), (0, 255, 0)) plt.figure() plt.title(f"Detected segments N {len(shapes)}") plt.imshow(cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB)) plt.show()
作者:太一吾鱼水
文章未经说明均属原创,学习笔记可能有大段的引用,一般会注明参考文献。
欢迎大家留言交流,转载请注明出处。