From 75d2c47d8a14382c9f68ce1f64040186e9baedfa Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Mon, 25 May 2020 20:28:25 +0800 Subject: [PATCH] support multi-line text display --- tools/infer/predict_rec.py | 1 - tools/infer/utility.py | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py index 6fa51e70d4..c005bfb739 100755 --- a/tools/infer/predict_rec.py +++ b/tools/infer/predict_rec.py @@ -117,7 +117,6 @@ def __call__(self, img_list): valid_image_file_list.append(image_file) img_list.append(img) rec_res, predict_time = text_recognizer(img_list) - rec_res, predict_time = text_recognizer(img_list) for ino in range(len(img_list)): print("Predicts of %s:%s" % (valid_image_file_list[ino], rec_res[ino])) print("Total predict time for %d images:%.3f" % diff --git a/tools/infer/utility.py b/tools/infer/utility.py index ce7ae68627..43e68ea5f7 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -176,6 +176,12 @@ def draw_ocr(image, boxes, txts, scores, draw_txt=True, drop_score=0.5): "./doc/simfang.ttf", font_size, encoding="utf-8") new_txt = str(count) + ': ' + txt + ' ' + '%.3f' % ( scores[count]) + while len(new_txt) > 25: + tmp = new_txt + new_txt = tmp[:25] + draw_txt.text( + (20, gap * (count + 1)), new_txt, txt_color, font=font) + new_txt = tmp[25:] draw_txt.text( (20, gap * (count + 1)), new_txt, txt_color, font=font) count += 1