Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#6951 from whjdark/dygraph
Browse files Browse the repository at this point in the history
修正高分辨率图像下BBOX标签和排序数字字体过小的问题
  • Loading branch information
Evezerest committed Jul 26, 2022
2 parents e753481 + d03b25b commit 76012cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions PPOCRLabel/libs/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,13 @@ def paintEvent(self, event):
pal.setColor(self.backgroundRole(), QColor(232, 232, 232, 255))
self.setPalette(pal)

# adaptive BBOX label & index font size
if self.pixmap:
h, w = self.pixmap.size().height(), self.pixmap.size().width()
fontszie = int(max(h, w) / 48)
for s in self.shapes:
s.fontsize = fontszie

p.end()

def fillDrawing(self):
Expand Down
5 changes: 3 additions & 2 deletions PPOCRLabel/libs/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(self, label=None, line_color=None, difficult=False, key_cls="None",
self.NEAR_VERTEX: (4, self.P_ROUND),
self.MOVE_VERTEX: (1.5, self.P_SQUARE),
}
self.fontsize = 8

self._closed = False

Expand Down Expand Up @@ -156,7 +157,7 @@ def paint(self, painter):
min_y = min(min_y, point.y())
if min_x != sys.maxsize and min_y != sys.maxsize:
font = QFont()
font.setPointSize(8)
font.setPointSize(self.fontsize)
font.setBold(True)
painter.setFont(font)
if self.label is None:
Expand All @@ -174,7 +175,7 @@ def paint(self, painter):
min_y = min(min_y, point.y())
if min_x != sys.maxsize and min_y != sys.maxsize:
font = QFont()
font.setPointSize(8)
font.setPointSize(self.fontsize)
font.setBold(True)
painter.setFont(font)
text = ''
Expand Down

0 comments on commit 76012cc

Please sign in to comment.