labelImg.py/loadLabels: correct shapes that are out of image bounds.
This commit is contained in:
parent
e18ccf3be1
commit
40b30f1cee
@ -758,6 +758,15 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
for label, points, line_color, fill_color, difficult in shapes:
|
for label, points, line_color, fill_color, difficult in shapes:
|
||||||
shape = Shape(label=label)
|
shape = Shape(label=label)
|
||||||
for x, y in points:
|
for x, y in points:
|
||||||
|
|
||||||
|
# Ensure the labels are within the bounds of the image. If not, fix them.
|
||||||
|
if x < 0 or x > self.canvas.pixmap.width() or y < 0 or y > self.canvas.pixmap.height():
|
||||||
|
x = max(x, 0)
|
||||||
|
y = max(y, 0)
|
||||||
|
x = min(x, self.canvas.pixmap.width())
|
||||||
|
y = min(y, self.canvas.pixmap.height())
|
||||||
|
self.setDirty()
|
||||||
|
|
||||||
shape.addPoint(QPointF(x, y))
|
shape.addPoint(QPointF(x, y))
|
||||||
shape.difficult = difficult
|
shape.difficult = difficult
|
||||||
shape.close()
|
shape.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user