Skip to content

Instantly share code, notes, and snippets.

@syanyong
Last active May 4, 2023 07:04
Show Gist options
  • Save syanyong/5fd83ff7d006d4566e115f9dbf203905 to your computer and use it in GitHub Desktop.
Save syanyong/5fd83ff7d006d4566e115f9dbf203905 to your computer and use it in GitHub Desktop.
# Plot bounding box from Pytorch Hub
def plot_boxes(result_dict, frame):
for ob in result_dict:
rec_start = (int(ob['xmin']), int(ob['ymin']))
rec_end = (int(ob['xmax']), int(ob['ymax']))
color = (255, 0, 0)
thickness = 3
cv2.rectangle(frame, rec_start, rec_end, color, thickness)
cv2.putText(frame, "%s %0.2f" % (ob['name'], ob['confidence']), rec_start, cv2.FONT_HERSHEY_DUPLEX, 2, color, thickness)
return frame
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment