问题描述
- OS平台和发行版(例如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
中名称为 - 或将
DejaVuSans.ttf
复制到object_detection
目录中名称为arial.ttf
的文件中(假设您正在此处运行代码)
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 namearial.ttf
in the directory/usr/share/fonts/truetype/dejavu
- Or copy
DejaVuSans.ttf
to a file with the namearial.ttf
in yourobject_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对象检测包围盒的厚度和厚度标签字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!