labelImg
labelImg copied to clipboard
Crashes on Windows when drawing rectangle
Traceback (most recent call last): File "C:\Users\5052xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\libs\canvas.py", line 530, in paintEvent p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height()) TypeError: arguments did not match any overloaded call: drawLine(self, QLineF): argument 1 has unexpected type 'float' drawLine(self, QLine): argument 1 has unexpected type 'float' drawLine(self, int, int, int, int): argument 1 has unexpected type 'float' drawLine(self, QPoint, QPoint): argument 1 has unexpected type 'float' drawLine(self, Union[QPointF, QPoint], Union[QPointF, QPoint]): argument 1 has unexpected type 'float'
- **OS: Windows 10 and Windows server 2019 Datacenter
- PyQt version: 1.8.6
have been able to fix it? I'm also having the same error
Possible duplicate with #885, #886
Solution. Error in Qt5. float to int conversion Changed: x:\xxxxx\python-310\Lib\site-packages\libs\canvas.py 526 line: default: p.drawRect(left_top.x(), left_top.y(), rect_width), int(rect_height) new: p.drawRect(int(left_top.x()), int(left_top.y()), int(rect_width), int(rect_height)) 530 line: default: p.drawLine( self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height()) new: p.drawLine( int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height())) 531 line: default: p.drawLine( 0, self.prev_point.y(), self.pixmap.width(), self.prev_point.y()) new: p.drawLine( 0, int(self.prev_point.y()), int(self.pixmap.width()), int(self.prev_point.y())) Changed: x:\xxxxx\python-310\Lib\site-packages\labelImg\labelImg.py 965 line: default: bar.setValue(bar.value() + bar.singleStep() * units) new: bar.setValue(int(bar.value() + bar.singleStep() * units))
Good work.
Some Corrections :
- File
canvas.py
x:\xxxxx\Python31x\site-packages\libs\canvas.py
- line
526
: from :
to :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))
- line
530
: from :
to :p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height())
p.drawLine(int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height()))
- line
531
: from :
to :p.drawLine(0, self.prev_point.y(), self.pixmap.width(), self.prev_point.y())
p.drawLine(0, int(self.prev_point.y()), int(self.pixmap.width()), int(self.prev_point.y()))
- File
labelImg.py
x:\xxxxx\Python31x\site-packages\labelImg\labelImg.py
- line
965
: from :
to :bar.setValue(bar.value() + bar.singleStep() * units)
bar.setValue(int(bar.value() + bar.singleStep() * units))
And i got new error on line 532
on canvas.py
Traceback (most recent call last):
File "e:\me\wilted-plant-faster-rcnn\.venv\lib\site-packages\libs\canvas.py", line 532, in paintEvent
p.drawLine(0, self.prev_point.y(), self.pixmap.width(), self.prev_point.y())
TypeError: arguments did not match any overloaded call:
drawLine(self, l: QLineF): argument 1 has unexpected type 'int'
drawLine(self, line: QLine): argument 1 has unexpected type 'int'
drawLine(self, x1: int, y1: int, x2: int, y2: int): argument 2 has unexpected type 'float'
drawLine(self, p1: QPoint, p2: QPoint): argument 1 has unexpected type 'int'
drawLine(self, p1: Union[QPointF, QPoint], p2: Union[QPointF, QPoint]): argument 1 has unexpected type 'int'
So in the line 532, change this line from:
p.drawLine(0, self.prev_point.y(), self.pixmap.width(), self.prev_point.y())
to:
p.drawLine(0, int(self.prev_point.y()), int(self.pixmap.width()), int(self.prev_point.y()))