Skip to content
Snippets Groups Projects
Commit 9cb4cdd4 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Use platform-independent method for getting font

parent adf7ef0f
No related branches found
No related tags found
No related merge requests found
import numpy as np
from matplotlib import font_manager
from PIL import Image, ImageDraw, ImageFont
from model_server.base.process import rescale
def _get_font():
return ImageFont.truetype(
font_manager.findfont(
font_manager.FontProperties(
family='sans-serif',
weight='bold'
)
)
)
def draw_boxes_on_3d_image(roiset, draw_full_depth=False, **kwargs):
h, w, chroma, nz = roiset.acc_raw.shape
font_size = kwargs.get('font_size', 18)
......@@ -25,7 +37,7 @@ def draw_boxes_on_3d_image(roiset, draw_full_depth=False, **kwargs):
for ci in range(0, len(channels)):
pilimg = Image.fromarray(roiset.acc_raw.data[:, :, channels[ci], zi])
draw = ImageDraw.Draw(pilimg)
draw.font = ImageFont.truetype(font="arial.ttf", size=font_size)
draw.font = _get_font()
for roi in subset.itertuples('Roi'):
xm = round((roi.x0 + roi.x1) / 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment