Skip to content

Commit 60893d3

Browse files
committed
* 解决PIL中的警告,使用textbbox替代textsize
1 parent c57920b commit 60893d3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
### 更新日志
22

33

4-
#### OpencvToolsV1.2.8 - 2023-04-07
5-
* 新增cv_show方法
4+
#### OpencvToolsV1.2.9 - 2024-02-26
5+
* 解决PIL中的警告,使用textbbox替代textsize
66
---
7+
78
<details onclose>
89
<summary>查看更多更新日志</summary>
910

1011

12+
#### OpencvToolsV1.2.8 - 2023-04-07
13+
* 新增cv_show方法
14+
---
15+
1116
#### OpencvToolsV1.2.7 - 2023-03-13
1217
* CVShowBoxes支持线条尺寸参数
1318
---

opencv_tools/jade_visualize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def draw_box(im, results,show_score=True,font_path=None,font_size=24):
8080
else:
8181
text = "{} ".format(labels_text[i,])
8282
font = ImageFont.truetype(get_font_path(font_path), font_size, encoding="utf-8") # 参数1:字体文件路径,参数2:字体大小
83-
tw, th = draw.textsize(text,font)
83+
x1,y1,w,h = draw.textbbox((0, 0), text, font=font)
8484
draw.rectangle(
85-
[(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill=color)
86-
draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255),font=font)
85+
[(xmin + x1, ymin - y1), (xmin + w , ymin)], fill=color)
86+
draw.text((xmin, ymin - x1), text, fill=(255, 255, 255),font=font)
8787
im = np.array(im)
8888
return im
8989

0 commit comments

Comments
 (0)