Read via QImageReader (#650)
* Now read via QImageReader * Remove comment-out unused lines
This commit is contained in:
parent
08db03a36d
commit
058d7a7e80
@ -1046,6 +1046,9 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.labelFile = None
|
self.labelFile = None
|
||||||
self.canvas.verified = False
|
self.canvas.verified = False
|
||||||
|
|
||||||
|
if isinstance(self.imageData, QImage):
|
||||||
|
image = self.imageData
|
||||||
|
else:
|
||||||
image = QImage.fromData(self.imageData)
|
image = QImage.fromData(self.imageData)
|
||||||
if image.isNull():
|
if image.isNull():
|
||||||
self.errorMessage(u'Error opening file',
|
self.errorMessage(u'Error opening file',
|
||||||
@ -1518,8 +1521,9 @@ def inverted(color):
|
|||||||
|
|
||||||
def read(filename, default=None):
|
def read(filename, default=None):
|
||||||
try:
|
try:
|
||||||
with open(filename, 'rb') as f:
|
reader = QImageReader(filename)
|
||||||
return f.read()
|
reader.setAutoTransform(True)
|
||||||
|
return reader.read()
|
||||||
except:
|
except:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,9 @@ class LabelFile(object):
|
|||||||
#imgFileNameWithoutExt = os.path.splitext(imgFileName)[0]
|
#imgFileNameWithoutExt = os.path.splitext(imgFileName)[0]
|
||||||
# Read from file path because self.imageData might be empty if saving to
|
# Read from file path because self.imageData might be empty if saving to
|
||||||
# Pascal format
|
# Pascal format
|
||||||
|
if isinstance(imageData, QImage):
|
||||||
|
image = imageData
|
||||||
|
else:
|
||||||
image = QImage()
|
image = QImage()
|
||||||
image.load(imagePath)
|
image.load(imagePath)
|
||||||
imageShape = [image.height(), image.width(),
|
imageShape = [image.height(), image.width(),
|
||||||
@ -70,6 +73,9 @@ class LabelFile(object):
|
|||||||
#imgFileNameWithoutExt = os.path.splitext(imgFileName)[0]
|
#imgFileNameWithoutExt = os.path.splitext(imgFileName)[0]
|
||||||
# Read from file path because self.imageData might be empty if saving to
|
# Read from file path because self.imageData might be empty if saving to
|
||||||
# Pascal format
|
# Pascal format
|
||||||
|
if isinstance(imageData, QImage):
|
||||||
|
image = imageData
|
||||||
|
else:
|
||||||
image = QImage()
|
image = QImage()
|
||||||
image.load(imagePath)
|
image.load(imagePath)
|
||||||
imageShape = [image.height(), image.width(),
|
imageShape = [image.height(), image.width(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user