Skip to content

Commit

Permalink
support multi-line text display
Browse files Browse the repository at this point in the history
  • Loading branch information
LDOUBLEV committed May 25, 2020
1 parent 8a6f106 commit 75d2c47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion tools/infer/predict_rec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" %
Expand Down
6 changes: 6 additions & 0 deletions tools/infer/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 75d2c47

Please sign in to comment.