-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db28ce6
commit 47faf95
Showing
1 changed file
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47faf95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From Docker arial.ttf is missing
While modifying plot_one_box_PIL would it be possible to make it so the label is always inside the bounds of the image
Detections on cameras going off the edge of the frame have their label going off the edge of the frame too, its a small issue but you seem to have txt_width and txt_height, if they overflow the image the label could be drawn inside the image?
root@container:/usr/src/app# ls -al /usr/share/fonts/
total 16
drwxr-xr-x 3 root root 4096 Nov 26 08:51 .
drwxr-xr-x 1 root root 4096 Dec 23 05:09 ..
-rw-r--r-- 1 root root 36 Nov 26 08:52 .uuid
drwxr-xr-x 3 root root 4096 Nov 26 08:51 truetype
root@container:/usr/src/app# ls -al /usr/share/fonts/truetype/
total 16
drwxr-xr-x 3 root root 4096 Nov 26 08:51 .
drwxr-xr-x 3 root root 4096 Nov 26 08:51 ..
-rw-r--r-- 1 root root 36 Nov 26 08:52 .uuid
drwxr-xr-x 2 root root 4096 Nov 26 08:51 dejavu
OSError: cannot open resource
cannot open resource
Traceback (most recent call last):
File "/usr/src/app/MultiModel.py", line 267, in Mark
plot_one_box_PIL(xyxy, img, label=f'{ClassName} {int(Percent * 1000)/10}%', color=Color, line_thickness=2)
File "/usr/src/app/utils/plots.py", line 78, in plot_one_box_PIL
font = ImageFont.truetype("Arial.ttf", fontsize)
File "/opt/conda/lib/python3.8/site-packages/PIL/ImageFont.py", line 852, in truetype
return freetype(font)
File "/opt/conda/lib/python3.8/site-packages/PIL/ImageFont.py", line 849, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/opt/conda/lib/python3.8/site-packages/PIL/ImageFont.py", line 209, in init
self.font = core.getfont(
OSError: cannot open resource
47faf95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iceisfun interesting. Yes I think the ttf font availability is a bit of problem with the PIL plotting. We may need a try except statement here that falls back to the PIL default font on load failures. https://pillow.readthedocs.io/en/3.0.x/reference/ImageFont.html#PIL.ImageFont.load_default
We created the PIL plotting function mainly as a placeholder now. It looks a little nicer when plotting results, but it's also slower than cv2, so for now we've kept the cv2 plots as default.
About the off-edge detections, I assume you mean the text/text boxes are off image and not the actual detection boxes (which are clipped) right? Is this only a PIL plotting issue or are the cv2 plots also affected?
47faf95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just use the cv2 plots and yes the text boxes are off the edge of the image, it should probably be something like
textx + textw > imgw:
textx = imgw - textw
so when the text overflows the image it just slides to the left
47faf95
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iceisfun good suggestion! Can you submit a PR with your fix please?