如何在Tensorflow对象检测模块中增加边界框的字体大小?

时间:2017-10-26 09:05:49

标签: tensorflow object-detection

我已将其字体大小从visual_utils.py

中draw_bounding_box_on_image()内的默认大小24增加到30

font = ImageFont.truetype('arial.ttf',30)

但字体大小仍未改变。

enter image description here

2 个答案:

答案 0 :(得分:5)

i found the issue.
On Mac we need to give the full path.
ImageFont.truetype('/Library/Fonts/Arial.ttf', 30)

另外,我们可以将.ttf文件放在当前文件夹中并使用

 ImageFont.truetype('./Arial.ttf', 30)

答案 1 :(得分:0)

对于 ubuntu 操作系统,我做了以下操作

    import matplotlib.font_manager as fm
...
  try:
    font = ImageFont.truetype(fm.findfont(fm.FontProperties(family='DejaVu Sans')), 50)
  except IOError:
    font = ImageFont.load_default()

它奏效了:) 附注。我想它适用于任何操作系统。