From 5c38b6bcddce895d646e944e3cddcb5b43bf8b8b Mon Sep 17 00:00:00 2001 From: "Sam.An" <56215891+sammiee5311@users.noreply.github.com> Date: Tue, 28 Dec 2021 12:05:21 +0900 Subject: [PATCH] Fix draw annotations error (#833) --- labelImg.py | 2 +- libs/canvas.py | 6 +++--- libs/shape.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/labelImg.py b/labelImg.py index eca22e72..70718987 100755 --- a/labelImg.py +++ b/labelImg.py @@ -962,7 +962,7 @@ class MainWindow(QMainWindow, WindowMixin): def scroll_request(self, delta, orientation): units = - delta / (8 * 15) bar = self.scroll_bars[orientation] - bar.setValue(bar.value() + bar.singleStep() * units) + bar.setValue(int(bar.value() + bar.singleStep() * units)) def set_zoom(self, value): self.actions.fitWidth.setChecked(False) diff --git a/libs/canvas.py b/libs/canvas.py index ddb652a5..1107b5fa 100644 --- a/libs/canvas.py +++ b/libs/canvas.py @@ -525,12 +525,12 @@ class Canvas(QWidget): p.setPen(self.drawing_rect_color) brush = QBrush(Qt.BDiagPattern) p.setBrush(brush) - p.drawRect(left_top.x(), left_top.y(), rect_width, rect_height) + p.drawRect(int(left_top.x()), int(left_top.y()), int(rect_width), int(rect_height)) if self.drawing() and not self.prev_point.isNull() and not self.out_of_pixmap(self.prev_point): p.setPen(QColor(0, 0, 0)) - p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height()) - p.drawLine(0, self.prev_point.y(), self.pixmap.width(), self.prev_point.y()) + p.drawLine(int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height())) + p.drawLine(0, int(self.prev_point.y()), int(self.pixmap.width()), int(self.prev_point.y())) self.setAutoFillBackground(True) if self.verified: diff --git a/libs/shape.py b/libs/shape.py index 04cf1f96..361f2af8 100644 --- a/libs/shape.py +++ b/libs/shape.py @@ -128,7 +128,7 @@ class Shape(object): self.label = "" if min_y < min_y_label: min_y += min_y_label - painter.drawText(min_x, min_y, self.label) + painter.drawText(int(min_x), int(min_y), self.label) if self.fill: color = self.select_fill_color if self.selected else self.fill_color