labelImg icon indicating copy to clipboard operation
labelImg copied to clipboard

Crashes on Windows when drawing rectangle

Open johnprice-xerox opened this issue 2 years ago • 5 comments

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

johnprice-xerox avatar May 03 '22 09:05 johnprice-xerox

have been able to fix it? I'm also having the same error

AjibolaPy avatar Jun 03 '22 00:06 AjibolaPy

Possible duplicate with #885, #886

nine avatar Jun 09 '22 19:06 nine

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.

ptiszai avatar Nov 09 '22 16:11 ptiszai

Some Corrections :

  1. File canvas.py

x:\xxxxx\Python31x\site-packages\libs\canvas.py

  • line 526 : from :
    p.drawRect(left_top.x(), left_top.y(), rect_width, rect_height)
    
    to :
    p.drawRect(int(left_top.x()), int(left_top.y()), int(rect_width), int(rect_height))
    
  • line 530 : from :
    p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height())
    
    to :
    p.drawLine(int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height()))
    
  • line 531 : 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()))
    
  1. File labelImg.py

x:\xxxxx\Python31x\site-packages\labelImg\labelImg.py

  • line 965 : from :
    bar.setValue(bar.value() + bar.singleStep() * units)
    
    to :
    bar.setValue(int(bar.value() + bar.singleStep() * units))
    

daudhiyaa avatar Jan 24 '23 18:01 daudhiyaa

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()))

musuyaba avatar Feb 01 '24 16:02 musuyaba