Skip to content

Commit

Permalink
No description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 548179835
  • Loading branch information
lukegb authored and copybara-github committed Jul 14, 2023
1 parent a55d948 commit 354d31d
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def draw_bounding_box_on_image(image,
# If the total height of the display strings added to the top of the bounding
# box exceeds the top of the image, stack the strings below the bounding box
# instead of above.
display_str_heights = [font.getsize(ds)[1] for ds in display_str_list]
display_str_heights = [font.getbbox(ds)[3] for ds in display_str_list]
# Each display_str has a top and bottom margin of 0.05x.
total_display_str_height = (1 + 2 * 0.05) * sum(display_str_heights)

Expand All @@ -224,7 +224,7 @@ def draw_bounding_box_on_image(image,
text_bottom = bottom + total_display_str_height
# Reverse list and print from bottom to top.
for display_str in display_str_list[::-1]:
text_width, text_height = font.getsize(display_str)
_, _, text_width, text_height = font.getbbox(display_str)
margin = np.ceil(0.05 * text_height)
draw.rectangle([(left, text_bottom - text_height - 2 * margin),
(left + text_width, text_bottom)],
Expand Down

0 comments on commit 354d31d

Please sign in to comment.