From 34420d40534be732e3ffcd34765f6c9ee0e83f3c Mon Sep 17 00:00:00 2001 From: tzutalin Date: Fri, 24 Feb 2017 22:11:38 +0800 Subject: [PATCH] Fix the wrong path/width/height in annotation files --- labelImg.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/labelImg.py b/labelImg.py index 094d853a..489d0565 100755 --- a/labelImg.py +++ b/labelImg.py @@ -638,7 +638,8 @@ class MainWindow(QMainWindow, WindowMixin): shape.fill_color = QColor(*fill_color) self.canvas.loadShapes(s) - def saveLabels(self, filePath): + def saveLabels(self, annotationFilePath): + annotationFilePath = u(annotationFilePath) lf = LabelFile() def format_shape(s): return dict(label=s.label, @@ -651,15 +652,15 @@ class MainWindow(QMainWindow, WindowMixin): shapes = [format_shape(shape) for shape in self.canvas.shapes] # Can add differrent annotation formats here try: - unicodeFilePath = u(filePath) + annotationFilePath = u(annotationFilePath) if self.usingPascalVocFormat is True: - lf.savePascalVocFormat(unicodeFilePath, shapes, unicodeFilePath, self.imageData, + print ('Img: ' + self.filePath + ' Xml: ' + annotationFilePath) + lf.savePascalVocFormat(annotationFilePath, shapes, self.filePath, self.imageData, self.lineColor.getRgb(), self.fillColor.getRgb()) else: - lf.save(unicodeFilePath, shapes, unicodeFilePath, self.imageData, + lf.save(annotationFilePath, shapes, self.filePath, self.imageData, self.lineColor.getRgb(), self.fillColor.getRgb()) self.labelFile = lf - self.filePath = unicodeFilePath return True except LabelFileError as e: self.errorMessage(u'Error saving label data',