Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix QPointF IndexError: list index out of range #11393

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion PPOCRLabel/libs/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from PyQt5.QtCore import QPointF
from PyQt5.QtGui import QColor, QPen, QPainterPath, QFont
from libs.utils import distance
from ppocr.utils.logging import get_logger

DEFAULT_LINE_COLOR = QColor(0, 255, 0, 128)
DEFAULT_FILL_COLOR = QColor(255, 0, 0, 128)
Expand Down Expand Up @@ -92,8 +93,15 @@ def rotatePoint(self, p, theta):
return pRes

def close(self):
self.center = QPointF((self.points[0].x() + self.points[2].x()) / 2,
try:
self.center = QPointF((self.points[0].x() + self.points[2].x()) / 2,
(self.points[0].y() + self.points[2].y()) / 2)
except:
self.center = None
logger = get_logger()
logger.warning(
'The XY coordinates of QPointF are not detectable!'
)
self._closed = True

def reachMaxPoints(self):
Expand Down