From 81f29c936f2e1d03b6d7344ab366c73238cac5f4 Mon Sep 17 00:00:00 2001 From: whjdark Date: Thu, 21 Jul 2022 15:28:03 +0800 Subject: [PATCH] new commit --- PPOCRLabel/libs/canvas.py | 7 +++++++ PPOCRLabel/libs/shape.py | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PPOCRLabel/libs/canvas.py b/PPOCRLabel/libs/canvas.py index 780ca71a..81f37995 100644 --- a/PPOCRLabel/libs/canvas.py +++ b/PPOCRLabel/libs/canvas.py @@ -624,6 +624,13 @@ class Canvas(QWidget): 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): diff --git a/PPOCRLabel/libs/shape.py b/PPOCRLabel/libs/shape.py index 1b32a6af..4e0b1f08 100644 --- a/PPOCRLabel/libs/shape.py +++ b/PPOCRLabel/libs/shape.py @@ -66,6 +66,7 @@ class Shape(object): self.NEAR_VERTEX: (4, self.P_ROUND), self.MOVE_VERTEX: (1.5, self.P_SQUARE), } + self.fontsize = 8 self._closed = False @@ -157,7 +158,7 @@ class Shape(object): 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: @@ -175,7 +176,7 @@ class Shape(object): 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 = '' -- GitLab