The following highlight:
should be changed to:
'''
Takes in the path to the rgb image for the background, then it takes bounding box data, the labels and the place to store the visualization. It outputs a colorized bounding box.
'''
def colorize_bbox_2d(rgb_path, data, id_to_labels, file_path):
rgb_img = Image.open(rgb_path)
fig, ax = plt.subplots(figsize=(10, 10))
ax.imshow(rgb_img)
for bbox_2d in data:
#id = bbox["semanticId"]
id = bbox_2d["semanticId"]
color = data_to_colour(id)
labels = id_to_labels[str(id)]
rect = patches.Rectangle(
xy=(bbox_2d["x_min"], bbox_2d["y_min"]),
width=bbox_2d["x_max"] - bbox_2d["x_min"],
height=bbox_2d["y_max"] - bbox_2d["y_min"],
edgecolor=color,
linewidth=2,
label=labels,
fill=False,
)
ax.add_patch(rect)
plt.legend(loc="upper left")
plt.savefig(file_path)
aka
id = bbox["semanticId"]
should change to id = bbox_2d["semanticId"]
The documentation is located at Visualizing the output folder from Basic Writer() — Omniverse Extensions documentation