Skip to content

Commit

Permalink
allow old pillow for paddle ocr (#2627)
Browse files Browse the repository at this point in the history
CVS-159845
  • Loading branch information
eaidova authored Jan 6, 2025
1 parent 776076c commit bac685d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions notebooks/paddle-ocr-webcam/pre_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,15 @@ def draw_ocr_box_txt(image, boxes, txts, scores=None, drop_score=0.5, font_path=
font = ImageFont.truetype(font_path, font_size)
cur_y = box[0][1]
for c in txt:
char_size = font.getbox(c)
try:
char_size = font.getbox(c)
y_idx = -1
except AttributeError:
char_size = font.getsize(c)
y_idx = 1

draw_right.text((box[0][0] + 3, cur_y), c, fill=(0, 0, 0), font=font)
cur_y += char_size[-1]
cur_y += char_size[y_idx]
else:
font_size = max(int(box_height * 0.8), 10)
font = ImageFont.truetype(font_path, font_size)
Expand Down

0 comments on commit bac685d

Please sign in to comment.