Skip to content

Commit

Permalink
Merge pull request #17 from KerasKorea/utils-visualization-thickness
Browse files Browse the repository at this point in the history
box thickness relative to image size(#8)
  • Loading branch information
MijeongJeon authored Oct 6, 2019
2 parents f266625 + 29b32f1 commit c12889e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions utils/show_bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def draw_bounding_box_on_image(image, box, display_class, color='red', thickness

draw = ImageDraw.Draw(image)
im_width, im_height = image.size

thk_multiply = 50
img_fraction = 0.05
while thk_multiply*thickness < img_fraction*image.size[0]:
thickness += 8

if is_normalized:
(left, right, top, bottom) = (xmin * im_width, xmax * im_width, ymin * im_height, ymax * im_height)
Expand All @@ -30,8 +35,8 @@ def draw_bounding_box_on_image(image, box, display_class, color='red', thickness

# font size
#font = ImageFont.load_default()
img_fraction = 0.05
font_path = '/Library/Fonts/Arial.ttf'

font_path = 'C:\Windows\Fonts\Arial.ttf'
font = ImageFont.truetype(font_path, 24)
#font = ImageFont.truetype(fm.findfont(fm.FontProperties(family=combo.get())), 24)
fontsize = 1
Expand All @@ -40,6 +45,7 @@ def draw_bounding_box_on_image(image, box, display_class, color='red', thickness
fontsize += 1
font = ImageFont.truetype(font_path, size=fontsize)


text_width, text_height = font.getsize(display_class)
margin = np.ceil(0.05 * text_height)

Expand Down

0 comments on commit c12889e

Please sign in to comment.