def frame_to_json(bboxes, targets):
"""
{'polygon': [{'x': [1,2,3], 'y': [2,3,4], 'object': 3}]}
Also decorated (see decorate_frame with pretty_names, polygons, targets)
"""
assert(len(bboxes) == len(targets))
if len(bboxes):
bb = bboxes.astype(np.int32)
return {'polygon':
[{'x': [int(b[0]), int(b[0]), int(b[2]), int(b[2])],
'y': [int(b[1]), int(b[3]), int(b[3]), int(b[1])],
'object': int(object_id)} \
for object_id, b in zip(targets, bb)]}
else:
return {}
评论列表
文章目录