import json
import jsonpath
import numpy as np
import cv2
import matplotlib.pyplot as plt
# 1679913605185815
# 1679913605085796
with open(
"json文件路径",
'r') as load_f:
load_dict = json.load(load_f)
i = 0
for i in range(10):
j = i + 1
points_j = load_dict['labeled_data']['groups'][i]["objects"][0]['points']
x_j = jsonpath.jsonpath(points_j, '$..x')
y_j = jsonpath.jsonpath(points_j, '$..y')
img = cv2.imread("图片路径")
data = np.array(list(zip(x_j, y_j)))
datas = data.astype(np.int32)
# print(datas)
lineType = cv2.LINE_8
point_size = 2
thickness = 2
point_color = (218, 32, 20)
for point in datas:
cv2.circle(img, point, point_size, point_color, thickness)
# print(point)
cv2.imshow('img', img)
cv2.waitKey(2000)
save_path = 'drawing_1_%d.jpg' % j
cv2.imwrite(save_path, img)
cv2.destroyAllWindows()
python+opencv 从json文件中获得坐标列表,然后在本地图片上描点
最新推荐文章于 2024-09-11 11:10:09 发布