自定义TF对象检测包围盒的厚度和厚度标签字体大小 [英] Customizing TF Object Detection bounding box thickness & label font size

查看:180
本文介绍了自定义TF对象检测包围盒的厚度和厚度标签字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 https://github.com/进行运行预测tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb .

  • OS平台和发行版(例如Linux Ubuntu 16.04):

Linux Ubuntu 16.04

Linux Ubuntu 16.04

要自定义标签字体大小和边框的厚度作为我的标签文字& bbox在图像检测中太厚.

Would like to customize label font size & bounding box thickness as my label text & bbox are too thick in image detections.

谢谢您的帮助!如果您自己完成此操作,请继续学习! :)

Thank you for any help! If you have done this yourself please pass along your learnings! :)

推荐答案

Ubuntu 16.04似乎不附带arial.ttf字体-不幸的是,这是vis_util.visualize_boxes_and_labels_on_image_array默认使用的内容,除非更改以下内容,否则无法配置. python代码.当找不到该字体时,它会使用默认的位图字体,但是对于许多用途而言,分辨率都太低,尤其是在DPI设置较低的情况下.

Ubuntu 16.04 seemingly does not ship with the arial.ttf font - and this is unfortunately what vis_util.visualize_boxes_and_labels_on_image_array uses by default and it is not configurable except by changing the python code. When it can't find that font it uses a default bitmap font, however the resolution is too low for many purposes, especially at low DPI settings.

但是,您可以通过多种方式解决此问题:

However you can workaround this problem in a number of ways:

  • 使用以下语言安装Microsoft核心字体:sudo apt-get install ttf-mscorefonts-installer(但是这对我不起作用-不确定原因)
  • 或将非常相似的字体DejaVuSans.ttf复制到目录/usr/share/fonts/truetype/dejavu
  • 中名称为arial.ttf的文件中
  • 或将DejaVuSans.ttf复制到object_detection目录中名称为arial.ttf的文件中(假设您正在此处运行代码)
  • Install the Microsoft core fonts with: sudo apt-get install ttf-mscorefonts-installer (this however did not work for me - not sure why)
  • Or copy the very similar font DejaVuSans.ttf to a file with the name arial.ttf in the directory /usr/share/fonts/truetype/dejavu
  • Or copy DejaVuSans.ttf to a file with the name arial.ttf in your object_detection directory (assuming you are running your code there)

然后,您可以使用DPI=100可视化框和标签,并且仍然可以读取字体.

Then you can visualize your boxes and labels with DPI=100 and still read the font.

之前-具有默认位图字体的100 DPI:

Before - 100 DPI with the default bitmap font:

之后-使用arial.ttf

这篇关于自定义TF对象检测包围盒的厚度和厚度标签字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆