diff --git a/deploy/pptracking/python/mot/visualize.py b/deploy/pptracking/python/mot/visualize.py index e60b732808fea40f7c010aafe6780e5b1a7a6908..66d3a66ebddde474670b95d98f5b24eb3fb647c4 100644 --- a/deploy/pptracking/python/mot/visualize.py +++ b/deploy/pptracking/python/mot/visualize.py @@ -17,12 +17,22 @@ from __future__ import division import os import cv2 import numpy as np +import PIL from PIL import Image, ImageDraw, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True from collections import deque from ppdet.utils.compact import imagedraw_textsize_c +def imagedraw_textsize_c(draw, text): + if int(PIL.__version__.split('.')[0]) < 10: + tw, th = draw.textsize(text) + else: + left, top, right, bottom = draw.textbbox((0, 0), text) + tw, th = right - left, bottom - top + + return tw, th + def visualize_box_mask(im, results, labels, threshold=0.5): """ diff --git a/deploy/python/visualize.py b/deploy/python/visualize.py index 51e01b9d92e1e56013103a4f9fe0c54659ba3c00..9e96c29df06946541b8ec99411f510bf78357f5e 100644 --- a/deploy/python/visualize.py +++ b/deploy/python/visualize.py @@ -16,12 +16,21 @@ from __future__ import division import os import cv2 +import math import numpy as np +import PIL from PIL import Image, ImageDraw, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True -import math -from ppdet.utils.compact import imagedraw_textsize_c +def imagedraw_textsize_c(draw, text): + if int(PIL.__version__.split('.')[0]) < 10: + tw, th = draw.textsize(text) + else: + left, top, right, bottom = draw.textbbox((0, 0), text) + tw, th = right - left, bottom - top + + return tw, th + def visualize_box_mask(im, results, labels, threshold=0.5): """