Skip to content

Instantly share code, notes, and snippets.

@victormurcia
Created October 20, 2022 23:07
Show Gist options
  • Select an option

  • Save victormurcia/49141b03ed2720d427d252101bd0c831 to your computer and use it in GitHub Desktop.

Select an option

Save victormurcia/49141b03ed2720d427d252101bd0c831 to your computer and use it in GitHub Desktop.
Extract bounding box coordinates for a specific bounding box in current frame from json
#Extract bounding box coordinates for a specific bounding box in current frame from json
def makeRectangleFromJSON(bb_dict,whichBB):
"""
Args:
bb_dict: (dict) dictionary from json file
whichBB: (int) what bounding box is being processed
Returns:
x1 ,y1 ,x2 ,y2: (tuple) tuple containing pixel coordinates for the upper-left and lower-right corners of the bounding box
"""
x1 ,y1 ,x2 ,y2 = bb_dict[whichBB][0],bb_dict[whichBB][1],bb_dict[whichBB][2],bb_dict[whichBB][3]
#print(x1 ,y1 ,x2 ,y2, ' These are the coordinates for bounding box ', whichBB)
return(x1 ,y1 ,x2 ,y2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment